Collection Memberships

Note

The Collection Memberships API is currently in Beta. It can be considered reasonably stable for beginning development work, but as it is a work in progress, it may still have small breaking changes introduced without warning.

Listing Memberships

GET /api2/memberships
Query Parameters:
 
  • user_id (optional) – Used to filter results by user.
  • group_id (optional) – Used to filter results by group.
  • collection_id (optional) – Used to filter results by collection.
  • role_id (optional) – Used to filter results by role.

Example Response:

HTTP/1.1 200 OK
Content-Type: application/json

{
  "items": [
    {
      "group": {
        "display_name": "Registered Users",
        "id": "2"
      },
      "collection": {
        "display_name": "My Site",
        "id": "1"
      },
      "created_on": "2014-08-18T23:20:07Z",
      "role": {
        "display_name": "Contributor",
        "id": "2"
      },
      "user": null,
      "modified_on": "2014-08-18T23:20:07Z",
      "id": "1"
      "links": {
        "self": "/api2/memberships/1"
      }
    },
    {
      "group": {
        "display_name": "Public",
        "id": "1"
      },
      "collection": {
        "display_name": "Public",
        "id": "2"
      },
      "created_on": "2014-08-18T23:20:07Z",
      "role": {
        "display_name": "Viewer",
        "id": "3"
      },
      "user": null,
      "modified_on": "2014-08-18T23:20:07Z",
      "id": "2"
      "links": {
        "self": "/api2/memberships/2"
      }
    },
  ],
  "links": {
    "self": "/api2/memberships",
    "prev": null,
    "next": null
  }
}

Fetching a Membership

GET /api2/memberships/(membership_id)

Fetch an individual membership by its unique ID.

Example Response:

HTTP/1.1 200 OK
Content-Type: application/json

{
  "group": {
    "display_name": "Registered Users",
    "id": "2"
  },
  "collection": {
    "display_name": "My Site",
    "id": "1"
  },
  "created_on": "2014-08-18T23:20:07Z",
  "role": {
    "display_name": "Contributor",
    "id": "2"
  },
  "user": null,
  "modified_on": "2014-08-18T23:20:07Z",
  "id": "1"
  "links": {
    "self": "/api2/memberships/1"
  }
}

Listing Calculated Roles

GET /api2/memberships/calculate-roles-perms

List the calculated roles for a user or a group.

Query Parameters:
 
  • user_id (conditional) – The user to calculate roles for.
  • group_id (conditional) – The group to calculate roles for.
  • collection_id (optional) – Used to filter results by collection.

Note

Exactly one of group_id and user_id should be specified. Having both will return a 400 error.

Example Response:

HTTP/1.1 200 OK
Content-Type: application/json

{
  "items": [
    {
      "collection": {
        "display_name": "My Site",
        "id": "1",
      },
      "roles": [
        {
          "display_name": "Contributor",
          "id": "2",
        }
      ],
      "permissions": [
        "media-read",
        "media-create",
        "media-play",
        "media-download",
        "media-like",
        "comment-read",
        "comment-create",
        "collection-read"
      ]
    },
    {
      "collection": {
        "display_name": "Public",
        "id": "2",
      },
      "roles": [
        {
          "display_name": "Viewer",
          "id": "3",
        }
      ],
      "permissions": [
        "media-read",
        "media-play",
        "media-download",
        "comment-read",
        "collection-read"
      ]
    }
  ],
  "links": {
    "self": "/api2/memberships/calculate-roles-perms?user_id=1",
    "prev": null,
    "next": null
  }
}

Creating a Membership

POST /api2/memberships
Json Parameters:
 
  • role_id (required) – The role to use for this membership.
  • collection_id (required) – The collection to create a membership in.
  • user_id (conditional) – The user id for the user to be used with this membership.
  • group_id (conditional) – The group id for the group to be used with this membership.

Note

Exactly one of group_id and user_id should be specified. Having both will return a 400 error.

Note

New memberships will override any old memberships for the current user/collection, group/collection pair.

Example Response:

HTTP/1.1 201 Created
Content-Type: application/json

{
  "group": {
    "display_name": "Faculty",
    "id": "2"
  },
  "collection": {
    "display_name": "My Site",
    "id": "1"
  },
  "created_on": "2014-08-18T23:20:07Z",
  "role": {
    "display_name": "Manager",
    "id": "2"
  },
  "user": null,
  "modified_on": "2014-08-18T23:20:07Z",
  "id": "3"
  "links": {
    "self": "/api2/memberships/3"
  }
}

Updating a Membership

POST /api2/memberships/(membership_id)
Json Parameters:
 
  • role_id (required) – The role to use for this membership.
  • user_id (optional) – The user id for the user to be used with this membership.
  • group_id (optional) – The group id for the group to be used with this membership.

Note

One of group_id and user_id may be specified. Having both will return a 400 error.

Example Response:

HTTP/1.1 200 OK
Content-Type: application/json

{
  "group": {
    "display_name": "Faculty",
    "id": "2"
  },
  "collection": {
    "display_name": "My Site",
    "id": "1"
  },
  "created_on": "2014-08-18T23:20:07Z",
  "role": {
    "display_name": "Contributor",
    "id": "2"
  },
  "user": null,
  "modified_on": "2014-08-18T23:20:07Z",
  "id": "3"
  "links": {
    "self": "/api2/memberships/3"
  }
}

Deleting Memberships

DELETE /api2/memberships/(membership_id)

Delete a group.

This endpoint is idempotent; attempting to delete a group that does not exist will return a successful response.

Example Response:

HTTP/1.1 204 No Content

Previous topic

Collections

Next topic

Media

This Page