6.13. Red Hat Quay API を使用してリポジトリーを作成および設定する
Red Hat Quay API を使用して、リポジトリーを作成、取得、変更、削除できます。
6.13.1. Red Hat Quay API を使用してリポジトリーを作成および設定する
Red Hat Quay API を使用して、リポジトリーを作成、取得、変更、削除できます。
手順
次のコマンドを入力し、
POST /api/v1/repository
エンドポイントを使用してリポジトリーを作成します。$ curl -X POST \ -H "Authorization: Bearer <bearer_token>" \ -H "Content-Type: application/json" \ -d '{ "repository": "<new_repository_name>", "visibility": "<private>", "description": "<This is a description of the new repository>." }' \ "https://quay-server.example.com/api/v1/repository"
出力例
{"namespace": "quayadmin", "name": "<new_repository_name>", "kind": "image"}
GET /api/v1/repository
エンドポイントを使用して、リポジトリーをリスト表示できます。以下に例を示します。$ curl -X GET \ -H "Authorization: Bearer <ACCESS_TOKEN>" \ "https://quay-server.example.com/api/v1/repository?public=true&starred=false&namespace=<NAMESPACE>"
出力例
{"repositories": [{"namespace": "quayadmin", "name": "busybox", "description": null, "is_public": false, "kind": "image", "state": "MIRROR", "is_starred": false, "quota_report": {"quota_bytes": 2280675, "configured_quota": 2199023255552}}]}
可視性は、
POST /api/v1/repository/{repository}/changevisibility
エンドポイントを使用してパブリックからプライベートに変更できます。$ curl -X POST \ -H "Authorization: Bearer <ACCESS_TOKEN>" \ -H "Content-Type: application/json" \ -d '{ "visibility": "private" }' \ "https://quay-server.example.com/api/v1/repository/<NAMESPACE>/<REPO_NAME>/changevisibility"
出力例
{"success": true}
Red Hat Quay UI を確認するか、次の
GET /api/v1/repository/{repository}
コマンドを入力してリポジトリーの詳細を返せます。$ curl -X GET -H "Authorization: Bearer <bearer_token>" "<quay-server.example.com>/api/v1/repository/<namespace>/<repository_name>"
出力例
{"detail": "Not Found", "error_message": "Not Found", "error_type": "not_found", "title": "not_found", "type": "http://quay-server.example.com/api/v1/error/not_found", "status": 404}
リポジトリーの説明は、
PUT /api/v1/repository/{repository}
エンドポイントを使用して更新できます。$ curl -X PUT \ -H "Authorization: Bearer <bearer_token>" \ -H "Content-Type: application/json" \ -d '{ "description": "This is an updated description for the repository." }' \ "https://quay-server.example.com/api/v1/repository/<NAMESPACE>/<REPOSITORY>"
出力例
{"success": true}
次のコマンドを入力し、
DELETE /api/v1/repository/{repository}
エンドポイントを使用してリポジトリーを削除します。$ curl -X DELETE -H "Authorization: Bearer <bearer_token>" "<quay-server.example.com>/api/v1/repository/<namespace>/<repository_name>"
このコマンドは CLI に出力を返しません。
6.13.2. API を使用した通知の作成
通知を追加するには、次の手順を実行します。
前提条件
- リポジトリーが作成済みである。
- リポジトリーの管理者権限がある。
- OAuth アクセストークンを作成 した。
-
config.yaml
ファイルでBROWSER_API_CALLS_XHR_ONLY: false
を設定している。
手順
次の
POST /api/v1/repository/{repository}/notification
コマンドを入力し、リポジトリーに関する通知を作成します。$ curl -X POST \ -H "Authorization: Bearer <bearer_token>" \ -H "Content-Type: application/json" \ --data '{ "event": "<event>", "method": "<method>", "config": { "<config_key>": "<config_value>" }, "eventConfig": { "<eventConfig_key>": "<eventConfig_value>" } }' \ https://<quay-server.example.com>/api/v1/repository/<namespace>/<repository_name>/notification/
このコマンドは CLI に出力を返しません。次の
GET /api/v1/repository/{repository}/notification/{uuid}
コマンドを入力すると、リポジトリー通知に関する情報を取得できます。{"uuid": "240662ea-597b-499d-98bb-2b57e73408d6", "title": null, "event": "repo_push", "method": "quay_notification", "config": {"target": {"name": "quayadmin", "kind": "user", "is_robot": false, "avatar": {"name": "quayadmin", "hash": "b28d563a6dc76b4431fc7b0524bbff6b810387dac86d9303874871839859c7cc", "color": "#17becf", "kind": "user"}}}, "event_config": {}, "number_of_failures": 0}
次の
POST /api/v1/repository/{repository}/notification/{uuid}/test
コマンドを入力すると、リポジトリー通知をテストできます。$ curl -X POST \ -H "Authorization: Bearer <bearer_token>" \ https://<quay-server.example.com>/api/v1/repository/<repository>/notification/<uuid>/test
出力例
{}
次の
POST /api/v1/repository/{repository}/notification/{uuid}
コマンドを入力すると、リポジトリー通知の失敗を 0 にリセットできます。$ curl -X POST \ -H "Authorization: Bearer <bearer_token>" \ https://<quay-server.example.com>/api/v1/repository/<repository>/notification/<uuid>
リポジトリー通知を削除するには、次の
DELETE /api/v1/repository/{repository}/notification/{uuid}
コマンドを入力します。$ curl -X DELETE \ -H "Authorization: Bearer <bearer_token>" \ https://<quay-server.example.com>/api/v1/repository/<namespace>/<repository_name>/notification/<uuid>
このコマンドは CLI に出力を返しません。次の
GET /api/v1/repository/{repository}/notification/
コマンドを入力すると、すべての通知のリストを取得できます。$ curl -X GET -H "Authorization: Bearer <bearer_token>" -H "Accept: application/json" https://<quay-server.example.com>/api/v1/repository/<namespace>/<repository_name>/notification
出力例
{"notifications": []}