Create, Update, and Delete

This page details role creation, updates and deletion.

If you are updating a role for something besides its name and description, it is likely you want to update the permissions associated with the role instead. Please see the Permissions API for more detail.

Create a Role

Create a new role. Role id must be unique across all roles.

Method: POST
Path: /pulp/api/v2/roles/
Permission: create
Request Body Contents:
  • role_id (string) - unique id for the role
  • display_name (string) - (optional) user-friendly name for the role
  • description (string) - (optional) user-friendly text describing the role
Response Codes:
  • 201 - if the role was successfully created
  • 400 - if one or more of the parameters is invalid
  • 409 - if there is already a role with the given id
Return: details of created role

Sample Request:

{
 "display_name": "Role Test",
 "description": "Demo Role",
 "role_id": "role-test"
}

Sample 201 Response Body:

{
 "display_name": "Role Test",
 "description": "Demo Role",
 "_ns": "roles",
 "_href": "/pulp/api/v2/roles/role-test/",
 "_id": {
   "$oid": "502cb2d7e5e710772d000049"
 },
 "id": "role-test",
 "permissions": {}
}

Update a Role

The update role call is used to change the details of an existing role.

Method: PUT
Path: /pulp/api/v2/roles/<role_id>/
Permission: update
Request Body Contents: The body of the request is a JSON document with a root element called delta. The contents of delta are the values to update. Only changed parameters need be specified. The following keys are allowed in the delta object.
  • display_name (string) - (optional) user-friendly name for the role
  • description (string) - (optional) user-friendly text describing the role
Response Codes:
  • 200 - if the update was executed and successful
  • 404 - if there is no role with the given id
Return: database representation of the role including changes made by the update

Sample Request:

{
 "delta": {
   "display_name": "New Role Test",
   "description": "New Demo Role"
 }
}

Sample 200 Response Body:

{
 "display_name": "New Role Test",
 "description": "New Demo Role",
 "_ns": "roles",
 "_href": "/pulp/api/v2/roles/role-test/",
 "_id": {
   "$oid": "502cb2d7e5e710772d000049"
 },
 "id": "role-test"
}

Delete a Role

Deletes a role from the Pulp server. Users bindings are removed from the role and permissions granted to the users because of the role are revoked as well unless those permissions are granted by other role as well.

Method: DELETE
Path: /pulp/api/v2/roles/<role_id>/
Permission: delete
Query Parameters:
Response Codes:
  • 200 - if the role was successfully deleted
  • 404 - if there is no role with the given id
Return: null

Add a User to a Role

Add a user to an existing role. Note that user with given login is NOT created as part of this operation. User with a given login should already exist.

Method: POST
Path: /pulp/api/v2/roles/<role_id>/users/
Permission: update
Request Body Contents:
  • login (string) - login of the user to be added to the role
Response Codes:
  • 200 - if the user was successfully added
  • 400 - if one or more of the parameters is invalid
  • 404 - if there is no role with the given id
Return: null

Sample Request:

{
 "login": "test-login"
}

Remove a User from a Role

Removes a user from an existing role.

Method: DELETE
Path: /pulp/api/v2/roles/<role_id>/users/<user_login>/
Permission: delete
Request Body Contents:
Response Codes:
  • 200 - if the user was successfully deleted
  • 404 - if there is no role with the given id
Return: null