6.13. Red Hat Quay API を使用してリポジトリーを作成および設定する


Red Hat Quay API を使用して、リポジトリーを作成、取得、変更、削除できます。

6.13.1. Red Hat Quay API を使用してリポジトリーを作成および設定する

Red Hat Quay API を使用して、リポジトリーを作成、取得、変更、削除できます。

手順

  1. 次のコマンドを入力し、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"}

  2. 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}}]}

  3. 可視性は、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}

  4. 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}
  5. リポジトリーの説明は、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}

  6. 次のコマンドを入力し、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 を設定している。

手順

  1. 次の 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}
  2. 次の 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

    出力例

    {}

  3. 次の 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>
  4. リポジトリー通知を削除するには、次の 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": []}

Red Hat logoGithubRedditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

Red Hat ドキュメントについて

Red Hat をお使いのお客様が、信頼できるコンテンツが含まれている製品やサービスを活用することで、イノベーションを行い、目標を達成できるようにします。

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

© 2024 Red Hat, Inc.