|
| 1 | +// module included in the following assemblies: |
| 2 | + |
| 3 | +// * use_quay/master.adoc |
| 4 | + |
| 5 | +:_content-type: CONCEPT |
| 6 | +[id="repo-manage-user-permissions"] |
| 7 | += Managing user permissions by using the {productname} API |
| 8 | + |
| 9 | +Use the following procedure to manage user permissions by using the {productname} API. |
| 10 | + |
| 11 | +.Procedure |
| 12 | + |
| 13 | +. Use the link:https://docs.redhat.com/en/documentation/red_hat_quay/3.13/html-single/red_hat_quay_api_guide/index#getuserpermissions[`GET /api/v1/repository/{repository}/permissions/user/{username}`] endpoint to obtain repository permissions for a user. For example: |
| 14 | ++ |
| 15 | +[source,terminal] |
| 16 | +---- |
| 17 | +$ curl -X GET \ |
| 18 | + -H "Authorization: Bearer <access_token>" \ |
| 19 | + "https://quay-server.example.com/api/v1/repository/<repository_path>/permissions/user/<username>" |
| 20 | +---- |
| 21 | ++ |
| 22 | +.Example output |
| 23 | ++ |
| 24 | +[source,terminal] |
| 25 | +---- |
| 26 | +$ {"role": "read", "name": "testuser", "is_robot": false, "avatar": {"name": "testuser", "hash": "f660ab912ec121d1b1e928a0bb4bc61b15f5ad44d5efdc4e1c92a25e99b8e44a", "color": "#6b6ecf", "kind": "user"}, "is_org_member": false} |
| 27 | +---- |
| 28 | + |
| 29 | +. All user permissions can be returned with the link:https://docs.redhat.com/en/documentation/red_hat_quay/3.13/html-single/red_hat_quay_api_guide/index#listrepouserpermissions[`GET /api/v1/repository/{repository}/permissions/user/`] endpoint: |
| 30 | ++ |
| 31 | +[source,terminal] |
| 32 | +---- |
| 33 | +$ curl -X GET \ |
| 34 | + -H "Authorization: Bearer <access_token>" \ |
| 35 | + "https://quay-server.example.com/api/v1/repository/<namespace>/<repository>/permissions/user/" |
| 36 | +---- |
| 37 | ++ |
| 38 | +.Example output |
| 39 | ++ |
| 40 | +[source,terminal] |
| 41 | +---- |
| 42 | +{"permissions": {"quayadmin": {"role": "admin", "name": "quayadmin", "is_robot": false, "avatar": {"name": "quayadmin", "hash": "6d640d802fe23b93779b987c187a4b7a4d8fbcbd4febe7009bdff58d84498fba", "color": "#f7b6d2", "kind": "user"}, "is_org_member": true}, "test+example": {"role": "admin", "name": "test+example", "is_robot": true, "avatar": {"name": "test+example", "hash": "3b03050c26e900500437beee4f7f2a5855ca7e7c5eab4623a023ee613565a60e", "color": "#a1d99b", "kind": "robot"}, "is_org_member": true}}} |
| 43 | +---- |
| 44 | + |
| 45 | +. Alternatively, you can use the link:https://docs.redhat.com/en/documentation/red_hat_quay/3.13/html-single/red_hat_quay_api_guide/index#getusertransitivepermission[`GET /api/v1/repository/{repository}/permissions/user/{username}/transitive`] endpoint to return only the repository permission for the user: |
| 46 | ++ |
| 47 | +[source,terminal] |
| 48 | +---- |
| 49 | +$ curl -X GET \ |
| 50 | + -H "Authorization: Bearer <access_token>" \ |
| 51 | + "https://quay-server.example.com/api/v1/repository/<repository_path>/permissions/user/<username>/transitive" |
| 52 | +---- |
| 53 | ++ |
| 54 | +.Example output |
| 55 | ++ |
| 56 | +[source,terminal] |
| 57 | +---- |
| 58 | +{"permissions": [{"role": "admin"}]} |
| 59 | +---- |
| 60 | + |
| 61 | +. You can change the user's permissions, such as making the user an `admin` by using the link:https://docs.redhat.com/en/documentation/red_hat_quay/3.13/html-single/red_hat_quay_api_guide/index#changeuserpermissions[`PUT /api/v1/repository/{repository}/permissions/user/{username}`] endpoint. For example: |
| 62 | ++ |
| 63 | +[source,terminal] |
| 64 | +---- |
| 65 | +$ curl -X PUT \ |
| 66 | + -H "Authorization: Bearer <access_token>" \ |
| 67 | + -H "Content-Type: application/json" \ |
| 68 | + -d '{"role": "<role>"}' \ |
| 69 | + "https://quay-server.example.com/api/v1/repository/<repository_path>/permissions/user/<username>" |
| 70 | +---- |
| 71 | ++ |
| 72 | +.Example output |
| 73 | ++ |
| 74 | +[source,terminal] |
| 75 | +---- |
| 76 | +{"role": "admin", "name": "testuser", "is_robot": false, "avatar": {"name": "testuser", "hash": "f660ab912ec121d1b1e928a0bb4bc61b15f5ad44d5efdc4e1c92a25e99b8e44a", "color": "#6b6ecf", "kind": "user"}, "is_org_member": false} |
| 77 | +---- |
| 78 | + |
| 79 | +. User permissions can be deleted by using the link:https://docs.redhat.com/en/documentation/red_hat_quay/3.13/html-single/red_hat_quay_api_guide/index#deleteuserpermissions[`DELETE /api/v1/repository/{repository}/permissions/user/{username}`] endpoint. For example: |
| 80 | ++ |
| 81 | +[source,terminal] |
| 82 | +---- |
| 83 | +$ curl -X DELETE \ |
| 84 | + -H "Authorization: Bearer <access_token>" \ |
| 85 | + "https://quay-server.example.com/api/v1/repository/<namespace>/<repository>/permissions/user/<username>" |
| 86 | +---- |
| 87 | ++ |
| 88 | +This command does not return output. |
0 commit comments