|
| 1 | +:_content-type: CONCEPT |
| 2 | +[id="robot-account-permissions-api"] |
| 3 | += Obtaining robot account information by using the {productname} API |
| 4 | + |
| 5 | +Robot account information, such as permissions, can be obtained for both organizations and users by using the {productname} API. |
| 6 | + |
| 7 | +.Prerequisites |
| 8 | + |
| 9 | +* You have link:https://access.redhat.com/documentation/en-us/red_hat_quay/3/html-single/red_hat_quay_api_guide/index#creating-oauth-access-token[Created an OAuth access token]. |
| 10 | +* You have set `BROWSER_API_CALLS_XHR_ONLY: false` in your `config.yaml` file. |
| 11 | +
|
| 12 | +.Procedure |
| 13 | + |
| 14 | +* Use the link:https://docs.redhat.com/en/documentation/red_hat_quay/3/html-single/red_hat_quay_api_guide/index#getorgrobot[`GET /api/v1/organization/{orgname}/robots/{robot_shortname}`] API endpoint to return information for a robot for an organization: |
| 15 | ++ |
| 16 | +[source,terminal] |
| 17 | +---- |
| 18 | +curl -X GET \ |
| 19 | + -H "Authorization: Bearer <bearer_token>" \ |
| 20 | + "https://quay-server.example.com/api/v1/organization/<ORGNAME>/robots/<ROBOT_SHORTNAME>" |
| 21 | +---- |
| 22 | ++ |
| 23 | +.Example output |
| 24 | ++ |
| 25 | +[source,terminal] |
| 26 | +---- |
| 27 | +{"name": "test+example", "created": "Mon, 25 Nov 2024 16:25:16 -0000", "last_accessed": null, "description": "", "token": "BILZ6YTVAZAKOGMD9270OKN3SOD9KPB7OLKEJQOJE38NBBRUJTIH7T5859DJL31Q", "unstructured_metadata": {}} |
| 28 | +---- |
| 29 | +
|
| 30 | +* Use the link:https://docs.redhat.com/en/documentation/red_hat_quay/{producty}/html-single/red_hat_quay_api_guide/index#getorgrobotpermissions[`GET /api/v1/organization/{orgname}/robots/{robot_shortname}/permissions`] endpoint to return the list of permissions for a specific organization robot: |
| 31 | ++ |
| 32 | +[source,terminal] |
| 33 | +---- |
| 34 | +$ curl -X GET \ |
| 35 | + -H "Authorization: Bearer <bearer_token>" \ |
| 36 | + "https://quay-server.example.com/api/v1/organization/<ORGNAME>/robots/<ROBOT_SHORTNAME>/permissions" |
| 37 | +---- |
| 38 | ++ |
| 39 | +.Example output |
| 40 | ++ |
| 41 | +[source,terminal] |
| 42 | +---- |
| 43 | +{"permissions": [{"repository": {"name": "testrepo", "is_public": true}, "role": "admin"}]} |
| 44 | +---- |
| 45 | +
|
| 46 | +* Use the link:https://docs.redhat.com/en/documentation/red_hat_quay/3/html-single/red_hat_quay_api_guide/index#getuserrobot[`GET /api/v1/user/robots/{robot_shortname}`] API endpoint to return the user's robot with the specified name: |
| 47 | ++ |
| 48 | +[source,terminal] |
| 49 | +---- |
| 50 | +$ curl -X GET \ |
| 51 | + -H "Authorization: Bearer <bearer_token>" \ |
| 52 | + "https://quay-server.example.com/api/v1/user/robots/<ROBOT_SHORTNAME>" |
| 53 | +---- |
| 54 | ++ |
| 55 | +.Example output |
| 56 | ++ |
| 57 | +[source,terminal] |
| 58 | +---- |
| 59 | +{"name": "quayadmin+mirror_robot", "created": "Wed, 15 Jan 2025 17:22:09 -0000", "last_accessed": null, "description": "", "token": "QBFYWIWZOS1I0P0R9N1JRNP1UZAOPUIR3EB4ASPZKK9IA1SFC12LTEF7OJHB05Z8", "unstructured_metadata": {}} |
| 60 | +---- |
| 61 | +
|
| 62 | +* Use the link:https://docs.redhat.com/en/documentation/red_hat_quay/3/html-single/red_hat_quay_api_guide/index#getuserrobotpermissions[`GET /api/v1/user/robots/{robot_shortname}/permissions`] API endpoint to return a list of permissions for the user robot: |
| 63 | ++ |
| 64 | +[source,terminal] |
| 65 | +---- |
| 66 | +$ curl -X GET \ |
| 67 | + -H "Authorization: Bearer <bearer_token>" \ |
| 68 | + "https://quay-server.example.com/api/v1/user/robots/<ROBOT_SHORTNAME>/permissions" |
| 69 | +---- |
| 70 | ++ |
| 71 | +.Example output |
| 72 | ++ |
| 73 | +[source,terminal] |
| 74 | +---- |
| 75 | +{"permissions": [{"repository": {"name": "busybox", "is_public": false}, "role": "write"}]} |
| 76 | +---- |
0 commit comments