6.14. Red Hat Quay API を使用したロボットアカウントの作成および設定
Red Hat Quay API を使用して、組織およびユーザーの両方でロボットアカウントを作成、取得、変更、および削除できます。
6.14.1. Red Hat Quay API を使用したロボットアカウントの作成
Red Hat Quay API を使用してロボットアカウントを作成するには、次の手順に従います。
前提条件
- OAuth アクセストークンを作成 した。
-
config.yaml
ファイルでBROWSER_API_CALLS_XHR_ONLY: false
を設定している。
手順
次のコマンドを入力し、
PUT /api/v1/organization/{orgname}/robots/{robot_shortname}
エンドポイントを使用して組織の新しいロボットアカウントを作成します。$ curl -X PUT -H "Authorization: Bearer <bearer_token>" "https://<quay-server.example.com>/api/v1/organization/<organization_name>/robots/<robot_name>"
出力例
{"name": "orgname+robot-name", "created": "Fri, 10 May 2024 15:11:00 -0000", "last_accessed": null, "description": "", "token": "<example_secret>", "unstructured_metadata": null}
次のコマンドを入力し、
PUT /api/v1/user/robots/{robot_shortname}
エンドポイントを使用して現在のユーザーの新しいロボットアカウントを作成します。$ curl -X PUT -H "Authorization: Bearer <bearer_token>" "https://<quay-server.example.com>/api/v1/user/robots/<robot_name>"
出力例
{"name": "quayadmin+robot-name", "created": "Fri, 10 May 2024 15:24:57 -0000", "last_accessed": null, "description": "", "token": "<example_secret>", "unstructured_metadata": null}
6.14.2. Red Hat Quay API を使用したロボットアカウント情報の取得
パーミッションなどのロボットアカウント情報は、Red Hat Quay API を使用して組織とユーザーの両方に対して取得できます。
前提条件
- OAuth アクセストークンを作成 した。
-
config.yaml
ファイルでBROWSER_API_CALLS_XHR_ONLY: false
を設定している。
手順
GET /api/v1/organization/{orgname}/robots/{robot_shortname}
API エンドポイントを使用して、組織のロボットの情報を返します。curl -X GET \ -H "Authorization: Bearer <bearer_token>" \ "https://quay-server.example.com/api/v1/organization/<ORGNAME>/robots/<ROBOT_SHORTNAME>"
出力例
{"name": "test+example", "created": "Mon, 25 Nov 2024 16:25:16 -0000", "last_accessed": null, "description": "", "token": "BILZ6YTVAZAKOGMD9270OKN3SOD9KPB7OLKEJQOJE38NBBRUJTIH7T5859DJL31Q", "unstructured_metadata": {}}
GET /api/v1/organization/{orgname}/robots/{robot_shortname}/permissions
エンドポイントを使用して、特定の組織のロボットのパーミッション一覧を返します。$ curl -X GET \ -H "Authorization: Bearer <bearer_token>" \ "https://quay-server.example.com/api/v1/organization/<ORGNAME>/robots/<ROBOT_SHORTNAME>/permissions"
出力例
{"permissions": [{"repository": {"name": "testrepo", "is_public": true}, "role": "admin"}]}
GET /api/v1/user/robots/{robot_shortname}
API エンドポイントを使用して、指定された名前のユーザーのロボットを返します。$ curl -X GET \ -H "Authorization: Bearer <bearer_token>" \ "https://quay-server.example.com/api/v1/user/robots/<ROBOT_SHORTNAME>"
出力例
{"name": "quayadmin+mirror_robot", "created": "Wed, 15 Jan 2025 17:22:09 -0000", "last_accessed": null, "description": "", "token": "QBFYWIWZOS1I0P0R9N1JRNP1UZAOPUIR3EB4ASPZKK9IA1SFC12LTEF7OJHB05Z8", "unstructured_metadata": {}}
GET /api/v1/user/robots/{robot_shortname}/permissions
API エンドポイントを使用して、ユーザーロボットのパーミッションの一覧を返します。$ curl -X GET \ -H "Authorization: Bearer <bearer_token>" \ "https://quay-server.example.com/api/v1/user/robots/<ROBOT_SHORTNAME>/permissions"
出力例
{"permissions": [{"repository": {"name": "busybox", "is_public": false}, "role": "write"}]}
6.14.3. Red Hat Quay API を使用したロボットアカウントの削除
Red Hat Quay API を使用してロボットアカウントを削除するには、次の手順に従います。
前提条件
- OAuth アクセストークンを作成 した。
-
config.yaml
ファイルでBROWSER_API_CALLS_XHR_ONLY: false
を設定している。
手順
次のコマンドを入力し、
DELETE /api/v1/organization/{orgname}/robots/{robot_shortname}
エンドポイントを使用して組織のロボットアカウントを削除します。curl -X DELETE \ -H "Authorization: Bearer <bearer_token>" \ "<quay-server.example.com>/api/v1/organization/<organization_name>/robots/<robot_shortname>"
API を使用してロボットアカウントを削除する場合、CLI は情報を返しません。削除を確認するには、Red Hat Quay UI を確認するか、次の
GET /api/v1/organization/{orgname}/robots
コマンドを入力して、ロボットアカウントの詳細が返されるかどうかを確認します。$ curl -X GET -H "Authorization: Bearer <bearer_token>" "https://<quay-server.example.com>/api/v1/organization/<organization_name>/robots"
出力例
{"robots": []}
次のコマンドを入力し、
DELETE /api/v1/user/robots/{robot_shortname}
エンドポイントを使用して現在のユーザーのロボットアカウントを削除します。$ curl -X DELETE \ -H "Authorization: Bearer <bearer_token>" \ "<quay-server.example.com>/api/v1/user/robots/<robot_shortname>"
API を使用して現在のユーザーのロボットアカウントを削除する場合、CLI は情報を返しません。削除を確認するには、Red Hat Quay UI を確認するか、次の
GET /api/v1/user/robots/{robot_shortname}
コマンドを入力して、ロボットアカウントの詳細が返されるかどうかを確認します。$ curl -X GET \ -H "Authorization: Bearer <bearer_token>" \ "<quay-server.example.com>/api/v1/user/robots/<robot_shortname>"
出力例
{"message":"Could not find robot with specified username"}