6.12. 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.12.1. Red Hat Quay API を使用した名前空間の自動プルーニングポリシーの作成

Red Hat Quay API エンドポイントを使用して、名前空間の自動プルーニングポリシーを管理できます。

前提条件

  • config.yaml ファイルで BROWSER_API_CALLS_XHR_ONLY: false を設定している。
  • OAuth アクセストークンを作成している。
  • Red Hat Quay にログインしている。

手順

  1. 次の POST /api/v1/organization/{orgname}/autoprunepolicy/ コマンドを入力して、組織で許可されるタグの数を制限する新しいポリシーを作成します。

    $ curl -X POST -H "Authorization: Bearer <access_token>" -H "Content-Type: application/json" -d '{"method": "number_of_tags", "value": 10}' http://<quay-server.example.com>/api/v1/organization/<organization_name>/autoprunepolicy/

    または、タグの作成日から指定期間が経過すると期限切れになるようにタグを設定することもできます。

    $ curl -X POST -H "Authorization: Bearer <access_token>" -H "Content-Type: application/json" -d '{
    "method": "creation_date", "value": "7d"}' http://<quay-server.example.com>/api/v1/organization/<organization_name>/autoprunepolicy/

    出力例

    {"uuid": "73d64f05-d587-42d9-af6d-e726a4a80d6e"}

  2. オプション: 組織にポリシーを追加し、tagPattern フィールドと tagPatternMatches フィールドを渡して、指定された正規表現パターンに一致するタグのみをプルーニングできます。以下に例を示します。

    $ curl -X POST \
      -H "Authorization: Bearer <bearer_token>" \
      -H "Content-Type: application/json" \
      -d '{
        "method": "creation_date",
        "value": "7d",
        "tagPattern": "^v*",
        "tagPatternMatches": <true> 1
      }' \
      "https://<quay-server.example.com>/api/v1/organization/<organization_name>/autoprunepolicy/"
    1
    tagPatternMatchestrue に設定すると、指定された正規表現パターンに一致するタグがプルーニングされます。この例では、^v* に一致するタグがプルーニングされます。

    出力例

    {"uuid": "ebf7448b-93c3-4f14-bf2f-25aa6857c7b0"}

  3. PUT /api/v1/organization/{orgname}/autoprunepolicy/{policy_uuid} コマンドを使用して、組織の自動プルーニングポリシーを更新できます。以下に例を示します。

    $ curl -X PUT   -H "Authorization: Bearer <bearer_token>"   -H "Content-Type: application/json"   -d '{
        "method": "creation_date",
        "value": "4d",
        "tagPattern": "^v*",
        "tagPatternMatches": true
      }'   "<quay-server.example.com>/api/v1/organization/<organization_name>/autoprunepolicy/<uuid>"

    このコマンドは出力を返しません。次のステップに進みます。

  4. 次のコマンドを入力して、自動プルーニングポリシーを確認します。

    $ curl -X GET -H "Authorization: Bearer <access_token>" http://<quay-server.example.com>/api/v1/organization/<organization_name>/autoprunepolicy/

    出力例

    {"policies": [{"uuid": "ebf7448b-93c3-4f14-bf2f-25aa6857c7b0", "method": "creation_date", "value": "4d", "tagPattern": "^v*", "tagPatternMatches": true}, {"uuid": "da4d0ad7-3c2d-4be8-af63-9c51f9a501bc", "method": "number_of_tags", "value": 10, "tagPattern": null, "tagPatternMatches": true}, {"uuid": "17b9fd96-1537-4462-a830-7f53b43f94c2", "method": "creation_date", "value": "7d", "tagPattern": "^v*", "tagPatternMatches": true}]}

  5. 次のコマンドを入力すると、組織の自動プルーニングポリシーを削除できます。ポリシーを削除するには UUID が必要であることに注意してください。

    $ curl -X DELETE -H "Authorization: Bearer <access_token>" http://<quay-server.example.com>/api/v1/organization/<organization_name>/autoprunepolicy/73d64f05-d587-42d9-af6d-e726a4a80d6e

6.12.2. API を使用した現行ユーザーの名前空間の自動プルーニングポリシーの作成

Red Hat Quay API エンドポイントを使用して、自分のアカウントの自動プルーニングポリシーを管理できます。

注記

以下のコマンドで使用している /user/ は、現在 Red Hat Quay にログインしているユーザーを表しています。

前提条件

  • config.yaml ファイルで BROWSER_API_CALLS_XHR_ONLY: false を設定している。
  • OAuth アクセストークンを作成している。
  • Red Hat Quay にログインしている。

手順

  1. 次の POST コマンドを入力して、現在のユーザーのタグ数を制限する新しいポリシーを作成します。

    $ curl -X POST -H "Authorization: Bearer <access_token>" -H "Content-Type: application/json" -d '{"method": "number_of_tags", "value": 10}' http://<quay-server.example.com>/api/v1/user/autoprunepolicy/

    出力例

    {"uuid": "8c03f995-ca6f-4928-b98d-d75ed8c14859"}

  2. 次のコマンドを入力して、自動プルーニングポリシーを確認します。

    $ curl -X GET -H "Authorization: Bearer <access_token>" http://<quay-server.example.com>/api/v1/user/autoprunepolicy/

    または、UUID を含めることもできます。

    $ curl -X GET -H "Authorization: Bearer <access_token>" http://<quay-server.example.com>/api/v1/user/autoprunepolicy/8c03f995-ca6f-4928-b98d-d75ed8c14859

    出力例

    {"policies": [{"uuid": "8c03f995-ca6f-4928-b98d-d75ed8c14859", "method": "number_of_tags", "value": 10}]}

  3. 次のコマンドを入力すると、自動プルーニングポリシーを削除できます。ポリシーを削除するには UUID が必要であることに注意してください。

    $ curl -X DELETE -H "Authorization: Bearer <access_token>" http://<quay-server.example.com>/api/v1/user/autoprunepolicy/8c03f995-ca6f-4928-b98d-d75ed8c14859

    出力例

    {"uuid": "8c03f995-ca6f-4928-b98d-d75ed8c14859"}

6.12.3. Red Hat Quay API を使用したリポジトリーの自動プルーニングポリシーの作成

Red Hat Quay API エンドポイントを使用して、リポジトリーの自動プルーニングポリシーを管理できます。

前提条件

  • config.yaml ファイルで BROWSER_API_CALLS_XHR_ONLY: false を設定している。
  • OAuth アクセストークンを作成している。
  • Red Hat Quay にログインしている。

手順

  1. 次の POST /api/v1/repository/{repository}/autoprunepolicy/ コマンドを入力して、組織で許可されるタグの数を制限する新しいポリシーを作成します。

    $ curl -X POST -H "Authorization: Bearer <access_token>" -H "Content-Type: application/json" -d '{"method": "number_of_tags","value": 2}' http://<quay-server.example.com>/api/v1/repository/<organization_name>/<repository_name>/autoprunepolicy/

    または、タグの作成日から指定期間が経過すると期限切れになるようにタグを設定することもできます。

    $ curl -X POST -H "Authorization: Bearer <access_token>" -H "Content-Type: application/json" -d '{"method": "creation_date", "value": "7d"}' http://<quay-server.example.com>/api/v1/repository/<organization_name>/<repository_name>/autoprunepolicy/

    出力例

    {"uuid": "ce2bdcc0-ced2-4a1a-ac36-78a9c1bed8c7"}

  2. オプション: ポリシーを追加し、tagPattern フィールドと tagPatternMatches フィールドを渡して、指定された正規表現パターンに一致するタグのみをプルーニングできます。以下に例を示します。

    $ curl -X POST \
      -H "Authorization: Bearer <access_token>" \
      -H "Content-Type: application/json" \
      -d '{
        "method": "<creation_date>",
        "value": "<7d>",
        "tagPattern": "<^test.>*",
        "tagPatternMatches": <false> 1
      }' \
      "https://<quay-server.example.com>/api/v1/repository/<organization_name>/<repository_name>/autoprunepolicy/"
    1
    tagPatternMatchesfalse に設定すると、指定された正規表現パターンに 一致しない すべてのタグがプルーニングされます。この例では、^test. 以外 のすべてのタグがプルーニングされます。

    出力例

    {"uuid": "b53d8d3f-2e73-40e7-96ff-736d372cd5ef"}

  3. PUT /api/v1/repository/{repository}/autoprunepolicy/{policy_uuid} コマンドを使用して UUID を渡すことで、リポジトリーのポリシーを更新できます。以下に例を示します。

    $ curl -X PUT \
      -H "Authorization: Bearer <bearer_token>" \
      -H "Content-Type: application/json" \
      -d '{
        "method": "number_of_tags",
        "value": "5",
        "tagPattern": "^test.*",
        "tagPatternMatches": true
      }' \
      "https://quay-server.example.com/api/v1/repository/<namespace>/<repo_name>/autoprunepolicy/<uuid>"

    このコマンドは出力を返しません。次の手順に進み、自動プルーニングポリシーを確認します。

  4. 次のコマンドを入力して、自動プルーニングポリシーを確認します。

    $ curl -X GET -H "Authorization: Bearer <access_token>" http://<quay-server.example.com>/api/v1/repository/<organization_name>/<repository_name>/autoprunepolicy/

    または、UUID を含めることもできます。

    $ curl -X GET -H "Authorization: Bearer <access_token>" http://<quay-server.example.com>/api/v1/repository/<organization_name>/<repository_name>/autoprunepolicy/ce2bdcc0-ced2-4a1a-ac36-78a9c1bed8c7

    出力例

    {"policies": [{"uuid": "ce2bdcc0-ced2-4a1a-ac36-78a9c1bed8c7", "method": "number_of_tags", "value": 10}]}

  5. 次のコマンドを入力すると、自動プルーニングポリシーを削除できます。ポリシーを削除するには UUID が必要であることに注意してください。

    $ curl -X DELETE -H "Authorization: Bearer <access_token>" http://<quay-server.example.com>/api/v1/repository/<organization_name>/<repository_name>/autoprunepolicy/ce2bdcc0-ced2-4a1a-ac36-78a9c1bed8c7

    出力例

    {"uuid": "ce2bdcc0-ced2-4a1a-ac36-78a9c1bed8c7"}

6.12.4. API を使用するユーザーのリポジトリーでの自動プルーニングポリシーの作成

リポジトリーに対する admin 権限がある限り、Red Hat Quay API エンドポイントを使用して、自分以外のユーザーアカウントのリポジトリーに対する自動プルーニングポリシーを管理できます。

前提条件

  • config.yaml ファイルで BROWSER_API_CALLS_XHR_ONLY: false を設定している。
  • OAuth アクセストークンを作成している。
  • Red Hat Quay にログインしている。
  • ポリシーを作成するリポジトリーの admin 権限がある。

手順

  1. 次の POST /api/v1/repository/<user_account>/<user_repository>/autoprunepolicy/ コマンドを入力して、ユーザーのタグの数を制限する新しいポリシーを作成します。

    $ curl -X POST -H "Authorization: Bearer <access_token>" -H "Content-Type: application/json" -d '{"method": "number_of_tags","value": 2}' https://<quay-server.example.com>/api/v1/repository/<user_account>/<user_repository>/autoprunepolicy/

    出力例

    {"uuid": "7726f79c-cbc7-490e-98dd-becdc6fefce7"}

  2. オプション: 現在のユーザーに対してポリシーを追加し、tagPattern フィールドと tagPatternMatches フィールドを渡して、指定された正規表現パターンに一致するタグのみをプルーニングできます。以下に例を示します。

    $ curl -X POST \
      -H "Authorization: Bearer <bearer_token>" \
      -H "Content-Type: application/json" \
      -d '{
        "method": "creation_date",
        "value": "7d",
        "tagPattern": "^v*",
        "tagPatternMatches": true
      }' \
      "http://<quay-server.example.com>/api/v1/repository/<user_account>/<user_repository>/autoprunepolicy/"

    出力例

    {"uuid": "b3797bcd-de72-4b71-9b1e-726dabc971be"}

  3. PUT /api/v1/repository/<user_account>/<user_repository>/autoprunepolicy/<policy_uuid> コマンドを使用して、現在のユーザーのポリシーを更新できます。以下に例を示します。

    $ curl -X PUT   -H "Authorization: Bearer <bearer_token>"   -H "Content-Type: application/json"   -d '{
        "method": "creation_date",
        "value": "4d",
        "tagPattern": "^test.",
        "tagPatternMatches": true
      }'   "https://<quay-server.example.com>/api/v1/repository/<user_account>/<user_repository>/autoprunepolicy/<policy_uuid>"

    ポリシーを更新しても、CLI に出力は返されません。

  4. 次のコマンドを入力して、自動プルーニングポリシーを確認します。

    $ curl -X GET -H "Authorization: Bearer <access_token>" http://<quay-server.example.com>/api/v1/repository/<user_account>/<user_repository>/autoprunepolicy/

    または、UUID を含めることもできます。

    $ curl -X GET -H "Authorization: Bearer <access_token>" http://<quay-server.example.com>/api/v1/repository/<user_account>/<user_repository>/autoprunepolicy/7726f79c-cbc7-490e-98dd-becdc6fefce7

    出力例

    {"uuid": "81ee77ec-496a-4a0a-9241-eca49437d15b", "method": "creation_date", "value": "7d", "tagPattern": "^v*", "tagPatternMatches": true}

  5. 次のコマンドを入力すると、自動プルーニングポリシーを削除できます。ポリシーを削除するには UUID が必要であることに注意してください。

    $ curl -X DELETE -H "Authorization: Bearer <access_token>" http://<quay-server.example.com>/api/v1/repository/<user_account>/<user_repository>/autoprunepolicy/<policy_uuid>

    出力例

    {"uuid": "7726f79c-cbc7-490e-98dd-becdc6fefce7"}

Red Hat logoGithubRedditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

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

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

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

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

会社概要

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

© 2024 Red Hat, Inc.