|
| 1 | +[id="service-key-manage-api"] |
| 2 | += Managing service keys as a superuser with the {productname} API |
| 3 | + |
| 4 | +Superusers have the ability to create, list, change, and delete service keys by using the {productname} API. |
| 5 | + |
| 6 | +.Procedure |
| 7 | + |
| 8 | +* Use the link:https://docs.redhat.com/en/documentation/red_hat_quay/3.13/html-single/red_hat_quay_api_guide/index#createservicekey[`POST /api/v1/superuser/keys`] endpoint to create a service key: |
| 9 | ++ |
| 10 | +[source,terminal] |
| 11 | +---- |
| 12 | +$ curl -X POST \ |
| 13 | + -H "Authorization: Bearer <bearer_token>" \ |
| 14 | + -H "Content-Type: application/json" \ |
| 15 | + -d '{ |
| 16 | + "service": "<service_name>", |
| 17 | + "expiration": <unix_timestamp> |
| 18 | + }' \ |
| 19 | + "<quay_server>/api/v1/superuser/keys" |
| 20 | +---- |
| 21 | ++ |
| 22 | +.Example output |
| 23 | ++ |
| 24 | +[source,terminal] |
| 25 | +---- |
| 26 | +{"message":""} |
| 27 | +---- |
| 28 | + |
| 29 | +* Use the link:https://docs.redhat.com/en/documentation/red_hat_quay/3.13/html-single/red_hat_quay_api_guide/index#approveservicekey[`POST /api/v1/superuser/approvedkeys/{kid}`] endpoint to approved a service key: |
| 30 | ++ |
| 31 | +[source,terminal] |
| 32 | +---- |
| 33 | +$ curl -X POST \ |
| 34 | + -H "Authorization: Bearer <bearer_token>" \ |
| 35 | + -H "Content-Type: application/json" \ |
| 36 | + -d '{ |
| 37 | + "notes": "<approval_notes>" |
| 38 | + }' \ |
| 39 | + "https://<quay_server>/api/v1/superuser/approvedkeys/<kid>" |
| 40 | +---- |
| 41 | ++ |
| 42 | +This command does not return output in the CLI. |
| 43 | + |
| 44 | +* Use the link:https://docs.redhat.com/en/documentation/red_hat_quay/{producty}/html-single/red_hat_quay_api_guide/index#listservicekeys[`GET /api/v1/superuser/keys`] endpoint to list service keys: |
| 45 | ++ |
| 46 | +[source,terminal] |
| 47 | +---- |
| 48 | +$ curl -X GET \ |
| 49 | + -H "Authorization: Bearer <bearer_token>" \ |
| 50 | + "https://<quay_server>/api/v1/superuser/keys" |
| 51 | +---- |
| 52 | ++ |
| 53 | +.Example output |
| 54 | ++ |
| 55 | +[source,terminal] |
| 56 | +---- |
| 57 | +{"keys":[{"approval":{"approval_type":"ServiceKeyApprovalType.AUTOMATIC","approved_date":"Mon, 20 Jan 2025 14:46:01 GMT","approver":null,"notes":""},"created_date":"Mon, 20 Jan 2025 14:46:01 GMT","expiration_date":"Wed, 05 Feb 2025 22:03:37 GMT","jwk":{"e":"AQAB","kid":"<example>","kty":"RSA","n":"<example>"},"kid":"7fr8soqXGgea8JqjwgItjjJT9GKlt-bMyMCDmvzy6WQ","metadata":{"created_by":"CLI tool"},"name":"http://quay-server.example.com:80","rotation_duration":null,"service":"quay"}]} |
| 58 | +---- |
| 59 | + |
| 60 | +* Use the link:https://docs.redhat.com/en/documentation/red_hat_quay/3.13/html-single/red_hat_quay_api_guide/index#getservicekey[`GET /api/v1/superuser/keys/{kid}`] endpoint to retrieve information about a service account by its kid: |
| 61 | ++ |
| 62 | +[source,terminal] |
| 63 | +---- |
| 64 | +$ curl -X GET \ |
| 65 | + -H "Authorization: Bearer <bearer_token>" \ |
| 66 | + "https://<quay_server>/api/v1/superuser/keys/<kid>" |
| 67 | +---- |
| 68 | ++ |
| 69 | +.Example output |
| 70 | ++ |
| 71 | +[source,terminal] |
| 72 | +---- |
| 73 | +{"approval":{"approval_type":"ServiceKeyApprovalType.AUTOMATIC","approved_date":"Mon, 20 Jan 2025 14:46:01 GMT","approver":null,"notes":""},"created_date":"Mon, 20 Jan 2025 14:46:01 GMT","expiration_date":"Wed, 05 Feb 2025 22:03:37 GMT","jwk":{"e":"AQAB","kid":"7fr8soqXGgea8JqjwgItjjJT9GKlt-bMyMCDmvzy6WQ","kty":"RSA","n":"5iMX7RQ_4F_zdb1qonMsuWUDauCOqEyRpD8L_EhgnwDxrgMHuOlJ4_7sEOrOa3Jkx3QhwIW6LJCP69PR5X0wvz6vmC1DoWEaWv41bAq23Knzj7gUU9-N_fkZPZN9NQwZ-D-Zqg9L1c_cJF93Dy93py8_JswWFDj1FxMaThJmrX68wBwjhF-JLYqgCAGFyezzJ3oTpO-esV9v6R7skfkaqtx_cjLZk_0cKB4VKTtxiy2A8D_5nANTOSSbZLXNh2Vatgh3yrOmnTTNLIs0YO3vFIuylEkczHlln-40UMAzRB3HNspUySyzImO_2yGdrA762LATQrOzJN8E1YKCADx5CQ"},"kid":"7fr8soqXGgea8JqjwgItjjJT9GKlt-bMyMCDmvzy6WQ","metadata":{"created_by":"CLI tool"},"name":"http://quay-server.example.com:80","rotation_duration":null,"service":"quay"} |
| 74 | +---- |
| 75 | + |
| 76 | +* Use the link:https://docs.redhat.com/en/documentation/red_hat_quay/3.13/html-single/red_hat_quay_api_guide/index#updateservicekey[`PUT /api/v1/superuser/keys/{kid}`] endpoint to update your service key, such as the metadata: |
| 77 | ++ |
| 78 | +[source,terminal] |
| 79 | +---- |
| 80 | +$ curl -X PUT \ |
| 81 | + -H "Authorization: Bearer <bearer_token>" \ |
| 82 | + -H "Content-Type: application/json" \ |
| 83 | + -d '{ |
| 84 | + "name": "<service_key_name>", |
| 85 | + "metadata": {"<key>": "<value>"}, |
| 86 | + "expiration": <unix_timestamp> |
| 87 | + }' \ |
| 88 | + "https://<quay_server>/api/v1/superuser/keys/<kid>" |
| 89 | +---- |
| 90 | ++ |
| 91 | +.Example output |
| 92 | ++ |
| 93 | +[source,terminal] |
| 94 | +---- |
| 95 | +{"approval":{"approval_type":"ServiceKeyApprovalType.AUTOMATIC","approved_date":"Mon, 20 Jan 2025 14:46:01 GMT","approver":null,"notes":""},"created_date":"Mon, 20 Jan 2025 14:46:01 GMT","expiration_date":"Mon, 03 Mar 2025 10:40:00 GMT","jwk":{"e":"AQAB","kid":"7fr8soqXGgea8JqjwgItjjJT9GKlt-bMyMCDmvzy6WQ","kty":"RSA","n":"5iMX7RQ_4F_zdb1qonMsuWUDauCOqEyRpD8L_EhgnwDxrgMHuOlJ4_7sEOrOa3Jkx3QhwIW6LJCP69PR5X0wvz6vmC1DoWEaWv41bAq23Knzj7gUU9-N_fkZPZN9NQwZ-D-Zqg9L1c_cJF93Dy93py8_JswWFDj1FxMaThJmrX68wBwjhF-JLYqgCAGFyezzJ3oTpO-esV9v6R7skfkaqtx_cjLZk_0cKB4VKTtxiy2A8D_5nANTOSSbZLXNh2Vatgh3yrOmnTTNLIs0YO3vFIuylEkczHlln-40UMAzRB3HNspUySyzImO_2yGdrA762LATQrOzJN8E1YKCADx5CQ"},"kid":"7fr8soqXGgea8JqjwgItjjJT9GKlt-bMyMCDmvzy6WQ","metadata":{"created_by":"CLI tool","environment":"production"},"name":"quay-service-key-updated","rotation_duration":null,"service":"quay"} |
| 96 | +---- |
| 97 | + |
| 98 | +* Use the link:https://docs.redhat.com/en/documentation/red_hat_quay/3.13/html-single/red_hat_quay_api_guide/index#deleteservicekey[`DELETE /api/v1/superuser/keys/{kid}`] endpoint to delete a service key: |
| 99 | ++ |
| 100 | +[source,terminal] |
| 101 | +---- |
| 102 | +$ curl -X DELETE \ |
| 103 | + -H "Authorization: Bearer <bearer_token>" \ |
| 104 | + "https://<quay_server>/api/v1/superuser/keys/<kid>" |
| 105 | +---- |
| 106 | ++ |
| 107 | +This command does not return output in the CLI. |
0 commit comments