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.
/pulp/api/v2/roles/
- 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
- 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
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.
/pulp/api/v2/roles/<role_id>/
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
- 200 - if the update was executed and successful
- 404 - if there is no role with the given id
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.
/pulp/api/v2/roles/<role_id>/
- 200 - if the role was successfully deleted
- 404 - if there is no role with the given id
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.
/pulp/api/v2/roles/<role_id>/users/
- login (string) - login of the user to be added to the role
- 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
Sample Request:
{
"login": "test-login"
}
Remove a User from a Role¶
Removes a user from an existing role.
/pulp/api/v2/roles/<role_id>/users/<user_login>/
- 200 - if the user was successfully deleted
- 404 - if there is no role with the given id