PUT /users/<sid>

Replace the content of the specified user object. For example, you can update a user's email address or role assignments. Authentication is required.

Request format

When Forming RBAC API requests to this endpoint, the content type is application/json. The body must be a JSON object using all keys supplied in the GET /users/<sid> endpoint response, modified as needed to update the user. For descriptions of each key, refer to Users endpoints keys. Not all keys can be updated, such as last_login.

The role_ids array indicates the roles to assign to the user. An empty role_ids array removes all roles directly assigned to the user.

An example, this JSON body is for a local user:

{"id": "c8b2c380-5889-11e4-8ed6-0800200c9a66",
"login": "Amari",
"email": "amariperez@example.com",
"display_name": "Amari Perez",
"role_ids": [1, 2, 3],
"is_group" : false,
"is_remote" : false,
"is_superuser" : false,
"is_revoked": false,
"last_login": "2014-05-04T02:32:00Z"}

And this body is for a remote user:

{"id": "3271fde0-588a-11e4-8ed6-0800200c9a66",
"login": "Jean",
"email": "jeanjackson@example.com",
"display_name": "Jean Jackson",
"role_ids": [4, 1],
"inherited_role_ids": [],
"group_ids: [],
"is_group" : false,
"is_remote" : true,
"is_superuser" : false,
"is_revoked": false,
"last_login": "2014-05-04T02:32:00Z"}

Here is an example of a complete curl request to this endpoint:

curl -X PUT "https://$(puppet config print server):4433/rbac-api/v1/users/c97c716a-5f42-49d8-b5a4-d0888a879d21" \
-H "X-Authentication:$(puppet-access show)" \
-H "Content-type:   application/json" \
-d '{"id": "c97c716a-5f42-49d8-b5a4-d0888a879d21",
     "login": "replace-test",
     "email": "replace-test@example.com",
     "display_name": "Replaced User",
     "role_ids": [],
     "is_group": false,
     "is_remote": false,
     "is_superuser": false,
     "is_revoked": false,
     "last_login": "2014-05-04T02:32:00Z"}'

Response format

Returns 200 OK and a user object showing the changes made. For example:

{"email":"replace-test@example.com",
  "is_revoked":false,
  "last_login":null,
  "is_remote":false,
  "login":"replace-test",
  "is_superuser":false,
  "id":"c97c716a-5f42-49d8-b5a4-d0888a879d21",
  "role_ids":[],
  "display_name":"Replaced User",
  "is_group":false}

Error responses

If the user's login user conflicts with an existing user login, the endpoint returns a 409 Conflict response.

For other errors, refer to RBAC service errors .