Red Hat Quay API ガイド
はじめに
Red Hat Quay アプリケーションプログラミングインターフェイス (API) は、Red Hat Quay 内でタスクを管理および自動化するための包括的な RESTful インターフェイスを提供します。OAuth 2.0 プロトコル に基づいて設計されたこの API は、Red Hat Quay リソースへの安全できめ細かいアクセスを可能にし、管理者とユーザーがリポジトリーの作成、イメージの管理、権限の設定などのアクションを実行できるようにします。
Red Hat Quay はセマンティックバージョニング (SemVer) の原則に従っており、次のようなリリース間で予測可能な API の安定性を確保しています。
- メジャーリリース: 新しい機能を導入します。API 互換性に対する重大な変更が含まれる可能性があります。たとえば、Red Hat Quay 2.0 の API は Red Hat Quay 3.0 とは異なります。
- マイナーリリース: 下位互換性を保ちながら新しい機能を追加します。たとえば、3.y リリースではバージョン 3. リリースに機能が追加されます。
- パッチリリース: 3.y.z などのマイナーリリースとの下位互換性を維持しながら、バグ修正と改善を提供します。
次のガイドでは、Red Hat Quay API をさらに詳しく説明し、以下のトピックの詳細を示します。
- OAuth 2 アクセストークンと、従来の API トークンおよび Red Hat Quay のロボットトークンとの比較
- OAuth 2 アクセストークンの生成
- トークン管理のベストプラクティス
- OAuth 2 アクセストークンの機能
- Red Hat Quay API の使用
- Red Hat Quay API 設定例
このガイドには、2 番目のガイドである Red Hat Quay API リファレンス が付属しており、すべての api/v1
エンドポイントに関する情報と、サンプルコマンドを使用してそれらのエンドポイントにアクセスする方法が提供されています。
第1章 Red Hat Quay OAuth 2.0 トークンの概要
Red Hat Quay OAuth 2 トークンシステムは、Red Hat Quay の API やその他の関連リソースにアクセスするための安全で標準ベースの方法を提供します。OAuth 2 トークンベースのアプローチは、複雑な環境での認証と認可を処理するための安全な方法として使用できます。従来の API トークンと比較して、Red Hat Quay の OAuth 2 トークンシステムでは、次のように機能が拡張されています。
- OAuth 2.0 プロトコル に準拠した標準ベースのセキュリティー。
- OAuth 2 トークンが存在するアプリケーションを削除し、アクセスを取り消すことができます。
- アクセス制御の設定を詳細に指定できるため、Red Hat Quay 管理者はトークンに特定の権限を割り当てることができます。
- 委譲アクセス。これにより、サードパーティーのアプリケーションやサービスがユーザーに代わって動作できるようになります。
- 将来を見据えた設計により、Red Hat Quay が他のサービス、プラットフォーム、統合との互換性を維持できるようになります。
Red Hat Quay は、主に OAuth 2 アクセストークンとロボットアカウントトークンという 2 種類のトークンをサポートします。3 番目のトークンタイプである OCI リファラーアクセストークン (リポジトリーの下にあるマニフェストの OCI リファラーの表示に必要) も、必要に応じて使用できます。
次の章では、各トークンタイプの詳細と生成方法を説明します。
第2章 OAuth 2 アクセストークン
OAuth 2 アクセストークン (Red Hat Quay では "API トークン" と見なされます) を使用すると、ユーザーアイデンティティー検証を必要とするアプリケーションに適した、Red Hat Quay API へのユーザー認証アクセスが可能になります。これらのトークンは、OAuth 2 認可プロセスを通じて取得されます。このプロセスでは、Red Hat Quay 管理者が自分自身または別のユーザーに代わってトークンを生成し、Red Hat Quay API エンドポイントにアクセスします。OAuth 2 トークンは、トークンに定義されたスコープに基づいて、API エンドポイントでのアクションを承認します。
OAuth 2 トークンはトークンに定義されたスコープに基づいて API エンドポイントでのアクションを承認しますが、リソース自体へのアクセスは Red Hat Quay のロールベースアクセス制御 (RBAC) メカニズムによって管理されます。対象の名前空間に対して適切なロール (Admin または Creator) がある場合は、リポジトリーなどのリソースに対してアクションを作成できます。これは、API トークンに repo:admin
スコープが付与されている場合でも当てはまります。
OAuth 2 アクセストークンは、Red Hat Quay UI を使用してのみ作成できます。CLI を使用して OAuth 2 アクセストークンを作成する方法はありません。OAuth 2 トークンを作成するときに、トークン所有者に対して次のオプションを選択できます。
- Administer Organization。選択すると、ユーザーはロボットの作成、チームの作成、チームメンバーシップの調整、課金設定の変更など、組織を管理できるようになります。
- Administer Repositories。選択すると、権限を付与したユーザーがアクセスできるすべてのリポジトリーへのユーザー管理者アクセスが提供されます。
- Create Repositories。選択すると、権限を付与したユーザーがリポジトリーの作成を許可されている任意の名前空間にリポジトリーを作成できるようになります。
- View all visible repositories。選択すると、権限を付与したユーザーに表示されるすべてのリポジトリーを表示しする権限およびプルする権限がユーザーに付与されます。
- Read/Write to any accessible repositories。選択すると、権限を付与したユーザーが書き込みアクセス権を持つすべてのリポジトリーを表示、プッシュ、プルする機能がユーザーに割り当てられます。
- Super User Access。選択すると、ユーザーの管理、組織の管理、スーパーユーザーパネルにあるその他の機能など、インストールを管理する権限がユーザーに付与されます。
- Administer User。選択すると、ロボットの作成やリポジトリーへの権限の付与など、アカウントを管理する権限がユーザーに付与されます。
- Read User Information。選択すると、ユーザー名やメールアドレスなどのユーザー情報を読み取る機能がユーザーに付与されます。
トークンディストリビューターは、ユーザーに代わってトークンを生成するときに付与する権限に注意する必要があります。ユーザーを完全に信頼できることを確認してから、Administer organization、Super User Access、および Administer User などの権限を付与する必要があります。また、アクセストークンは作成時にのみ公開され、CLI から一覧表示できず、Red Hat Quay UI で表示することもできません。アクセストークンを紛失したり忘れたりした場合は、新しいトークンを作成する必要があります。トークンを復元することはできません。
OAuth 2 アクセストークンは、API 呼び出しの Authorization
ヘッダーで Bearer
トークンとして渡され、イメージタグ、リポジトリー、組織などの定義された API エンドポイントに認証と認可を提供するために使用されます。
API は、Red Hat Quay ホストの /api/v1
エンドポイントから使用できます。たとえば、https://<quay-server.example.com>/api/v1
です。Swagger UI を有効にすると、ユーザーがブラウザー経由でエンドポイントに接続し、Red Hat Quay の設定を GET
、POST
、DELETE
、PUT
できるようになります。API は、API 呼び出しを実行して OAuth トークンを使用するアプリケーションからアクセスでき、JSON としてデータを送受信します。
Red Hat Quay では現在、OAuth 2 アクセストークンに有効期限をローテーションまたは設定する方法はなく、トークンの有効期間は 10 年です。トークンが不正使用された場合、トークンが作成されたアプリケーションを削除して、トークンを削除できますが、この操作により、その特定のアプリケーション内で作成されたすべてのトークンが削除されます。
実際には、Red Hat Quay 管理者は、ユーザー用に新しい OAuth トークンを作成するたびに、組織の Applications ページで新しい OAuth アプリケーションを作成 できます。これにより、単一のアプリケーションがすべての OAuth トークンを管理する必要がなくなります。その結果、ユーザーのトークンが不正使用された場合、管理者は不正使用されたトークンのアプリケーションを削除します。これにより、同じアプリケーションの中に含まれる可能性のあるトークンを使用する他のユーザーの混乱を回避するのに役立ちます。
次のセクションでは、OAuth 2 アクセストークンを生成して再割り当てする方法を説明します。
2.1. OAuth 2 アクセストークンの作成
Red Hat Quay では、組織の API エンドポイントにアクセスする前に、OAuth 2 アクセストークンを作成する必要があります。OAuth 2 アクセストークンは、Red Hat Quay UI を使用してのみ生成できます。CLI を使用して OAuth 2 アクセストークンを生成することはできません。
OAuth2 アクセストークンを作成するには、次の手順を実行します。
前提条件
- Red Hat Quay に管理者としてログインしている。
- OAuth 2 アプリケーションを作成した。
手順
- メインページで、Organization を選択します。
- ナビゲーションペインで、Applications を選択します。
- アプリケーションの名前 (例: Test application) をクリックします。
- ナビゲーションペインで、Generate Token を選択します。
次のオプションのチェックボックスをオンにします。
- Administer Organization。選択すると、ユーザーはロボットの作成、チームの作成、チームメンバーシップの調整、課金設定の変更など、組織を管理できるようになります。
- Administer Repositories。選択すると、権限を付与したユーザーがアクセスできるすべてのリポジトリーへのユーザー管理者アクセスが提供されます。
- Create Repositories。選択すると、権限を付与したユーザーがリポジトリーの作成を許可されている任意の名前空間にリポジトリーを作成できるようになります。
- View all visible repositories。選択すると、権限を付与したユーザーに表示されるすべてのリポジトリーを表示しする権限およびプルする権限がユーザーに付与されます。
- Read/Write to any accessible repositories。選択すると、権限を付与したユーザーが書き込みアクセス権を持つすべてのリポジトリーを表示、プッシュ、プルする機能がユーザーに割り当てられます。
- Super User Access。選択すると、ユーザーの管理、組織の管理、スーパーユーザーパネルにあるその他の機能など、インストールを管理する権限がユーザーに付与されます。
- Administer User。選択すると、ロボットの作成やリポジトリーへの権限の付与など、アカウントを管理する権限がユーザーに付与されます。
- Read User Information。選択すると、ユーザー名やメールアドレスなどのユーザー情報を読み取る機能がユーザーに付与されます。
- Generate Access Token をクリックします。新しいページにリダイレクトされます。
- 許可する権限を確認し、Authorize Application をクリックします。Authorize Application をクリックして決定した内容を確定します。
Access Token ページにリダイレクトされます。アクセストークンをコピーして保存します。
重要これは、アクセストークンをコピーして保存する唯一の機会です。このページを離れると再取得できません。
2.2. OAuth アクセストークンの再割り当て
組織管理者は、特定の権限を持つ他のユーザーによって作成されるように OAuth API トークンを割り当てることができます。これにより、OAuth API トークンを作成する組織管理者権限を持たないユーザーがトークンを使用した場合でも、監査ログが正確に反映されるようになります。
次の手順は、現在の Red Hat Quay UI でのみ機能します。現在、Red Hat Quay v2 UI には実装されていません。
前提条件
組織管理者権限を持つユーザーとしてログインしており、OAuth API トークンを割り当てることができる。
注記OAuth API トークンは、認可ではなく認証に使用されます。たとえば、OAuth トークンを割り当てるユーザーは、管理 API エンドポイントを使用するために
Admin
チームロールを持っている必要があります。詳細は、リポジトリーへのアクセスの管理 を参照してください。
手順
オプション: まだ更新していない場合は、Red Hat Quay
config.yaml
ファイルを更新して、FEATURE_ASSIGN_OAUTH_TOKEN: true
フィールドを含めます。# ... FEATURE_ASSIGN_OAUTH_TOKEN: true # ...
- オプション: Red Hat Quay レジストリーを再起動します。
- 組織管理者として Red Hat Quay レジストリーにログインします。
- OAuth トークンを作成した組織の名前をクリックします。
- ナビゲーションペインで、Applications をクリックします。
- 適切なアプリケーション名をクリックします。
- ナビゲーションペインで、Generate Token をクリックします。
- Assign another user をクリックし、OAuth トークンを引き継ぐユーザーの名前を入力します。
新しいユーザーに付与する必要な権限のボックスをオンにします。たとえば、新しいユーザーにリポジトリーの作成のみを許可する場合は、Create Repositories クリックします。
重要権限の制御は、組織内のチームロールによって定義され、ここで選択したオプションに関係なく設定する必要があります。たとえば、OAuth トークンを割り当てるユーザーは、管理 API エンドポイントを使用するために
Admin
チームロールを持っている必要があります。Super User Access ボックスをオンにしただけでは、この権限がユーザーに実際に付与されるわけではありません。
config.yaml
ファイルでスーパーユーザーを設定する必要があり、かつ ここでボックスをオンにする必要があります。Assign token をクリックします。ポップアップボックスに、認可を確認する次のメッセージと、承認される権限が表示されます。
This will prompt user <username> to generate a token with the following permissions: repo:create
ポップアップボックスで Assign token をクリックします。新しいページにリダイレクトされ、次のメッセージが表示されます。
Token assigned successfully
検証
- OAuth トークンを再割り当てした後、割り当てられたユーザーがトークンを受け入れて、API エンドポイントの使用に必要なベアラートークンを受け取る必要があります。割り当てられたユーザーに、Red Hat Quay レジストリーにログインするよう依頼します。
- ユーザーは、ログインしたら、Users and Organizations の下にある自分のユーザー名をクリックする必要があります。
- ナビゲーションペインで、External Logins And Applications をクリックする必要があります。
- Authorized Applications の下で、Authorize Application をクリックしてアプリケーションを確認する必要があります。新しいページに移動し、Authorize Application をクリックして再確認する必要があります。
- ユーザーは、ベアラートークンが表示される新しいページにリダイレクトされます。このベアラートークンは再度表示することはできないため、保存する必要があります。
2.3. OAuth 2 アクセストークンの削除
OAuth 2 アクセストークンは OAuth アプリケーションを通じて作成されるため、ローテーションまたは更新することはできません。トークンが侵害された場合、またはトークンを削除する必要がある場合は、Red Hat Quay UI を通じて関連付けられているアプリケーションを削除する必要があります。
アプリケーションを削除すると、そのアプリケーション内で作成されたすべてのトークンが削除されます。注意して使用してください。
前提条件
- OAuth 2 アクセストークンを作成した。
手順
- Red Hat Quay UI で、アプリケーションをホストしている組織の名前をクリックします。次に、ナビゲーションペインで Applications をクリックします。
- アプリケーション名 (例: Test application) をクリックします。
- ナビゲーションペインで、Delete Application をクリックします。新しいページにリダイレクトされます。Delete application をクリックして確認します。
第3章 ロボットアカウントトークン
ロボットアカウント トークン は、通常の Docker v2 エンドポイント経由で Red Hat Quay レジストリーにアクセスするために使用される パスワードタイプ の認証情報です。パスワード自体は暗号化されているため、UI 上で トークン として定義されます。
ロボットアカウントトークンは、自動化および継続的インテグレーションワークフロー向けに設計された永続的なトークンです。デフォルトでは、Red Hat Quay のロボットアカウントトークンは期限切れにならず、ユーザーの操作も必要ありません。そのため、ロボットアカウントは非対話型のユースケースに最適です。
ロボットアカウントトークンは、ロボットの作成時に自動的に生成され、ユーザー固有ではありません。つまり、作成されたユーザーと組織の名前空間に接続されます。たとえば、project_tools+<robot_name>
という名前のロボットは project_tools
名前空間に関連付けられます。
ロボットアカウントトークンを使用すると、ユーザーの個人認証情報を必要とせずにアクセスが可能になります。ロボットアカウントがどのように設定されているか (例: READ
、WRITE
、または ADMIN
権限のいずれか) によって、最終的にロボットアカウントが実行できるアクションが決まります。
ロボットアカウントトークンは永続的であり、デフォルトでは期限切れにならないため、手動で更新せずに Red Hat Quay に常にアクセスする必要がある自動ワークフローに最適です。ただし、ロボットアカウントトークンは UI を使用して簡単に再生成できます。CLI 経由で適切な API エンドポイントを使用して再生成することもできます。Red Hat Quay デプロイメントのセキュリティーを強化するために、管理者はロボットアカウントトークンを定期的に更新する必要があります。さらに、ロボットアカウントを使用したキーレス認証 機能により、ロボットアカウントトークンを外部 OIDC トークンと交換して 1 時間のみ有効化できるため、レジストリーのセキュリティーが強化されます。
名前空間が削除されたり、ロボットアカウント自体が削除されたりすると、コレクターの実行がスケジュールされているときにガベージコレクションが行われます。
次のセクションでは、API を使用して組織ロボットとユーザーロボットのロボットアカウントトークンを再生成する方法を説明します。
3.1. Red Hat Quay UI を使用したロボットアカウントトークンの再生成
Red Hat Quay UI を使用してロボットアカウントトークンを再生成するには、次の手順に従います。
前提条件
- Red Hat Quay にログインしている。
手順
- 組織名をクリックします。
- ナビゲーションウィンドウで、Robot accounts をクリックします。
- ロボットアカウントの名前 (例: testorg3+test) をクリックします。
- ポップアップボックスで Regenerate token をクリックします。
3.2. Red Hat Quay API を使用したロボットアカウントトークンの再生成
Red Hat Quay API を使用してロボットアカウントトークンを再生成するには、次の手順に従います。
前提条件
- OAuth アクセストークンを作成 した。
-
config.yaml
ファイルでBROWSER_API_CALLS_XHR_ONLY: false
を設定している。
手順
次のコマンドを入力し、
POST /api/v1/organization/{orgname}/robots/{robot_shortname}/regenerate
エンドポイントを使用して組織のロボットアカウントトークンを再生成します。$ curl -X POST \ -H "Authorization: Bearer <bearer_token>" \ "<quay-server.example.com>/api/v1/organization/<orgname>/robots/<robot_shortname>/regenerate"
出力例
{"name": "test-org+test", "created": "Fri, 10 May 2024 17:46:02 -0000", "last_accessed": null, "description": "", "token": "<example_secret>"}
次のコマンドを入力し、
POST /api/v1/user/robots/{robot_shortname}/regenerate
エンドポイントを使用して現在のユーザーのロボットアカウントトークンを再生成します。$ curl -X POST \ -H "Authorization: Bearer <bearer_token>" \ "<quay-server.example.com>/api/v1/user/robots/<robot_shortname>/regenerate"
出力例
{"name": "quayadmin+test", "created": "Fri, 10 May 2024 14:12:11 -0000", "last_accessed": null, "description": "", "token": "<example_secret>"}
第4章 OCI リファラー OAuth アクセストークン
場合によっては、Red Hat Quay デプロイメントで使用するように設定されている機能に応じて、OCI リファラー OAuth アクセストークン を活用する必要があります。OCI リファラー OAuth アクセストークンは、リポジトリー下のマニフェストの OCI リファラーをリスト表示するために使用され、curl
コマンドを使用して Red Hat Quay v2/auth
エンドポイントに GET
リクエストを送信します。
これらのトークンは Basic HTTP 認証によって取得されます。ユーザーは Base64 でエンコードされたユーザー名とパスワードを使用し、v2/auth
API エンドポイントで直接認証します。そのため、このトークンはユーザーの認証情報に直接基づいており、OAuth 2 と同じ詳細な認可フローには従いませんが、ユーザーは API リクエストを承認できます。
OCI リファラー OAuth アクセストークン は、スコープベースの権限を提供せず、有効期限もありません。これらは、リポジトリーの下にあるマニフェストの OCI リファラーをリストするためにのみ使用されます。
関連情報
4.1. OCI リファラー OAuth アクセストークンの作成
この OCI リファラー OAuth アクセストークンは、リポジトリーの下にあるマニフェストの OCI リファラーをリスト表示するために使用されます。
手順
config.yaml
ファイルを更新して、FEATURE_REFERRERS_API: true
フィールドを含めます。以下に例を示します。# ... FEATURE_REFERRERS_API: true # ...
次のコマンドを入力し、認証情報を Base64 でエンコードします。
$ echo -n '<username>:<password>' | base64
出力例
abcdeWFkbWluOjE5ODlraWROZXQxIQ==
次のコマンドを入力して、base64 でエンコードされた文字列を使用し、URL エンドポイントを Red Hat Quay サーバーに変更します。
$ curl --location '<quay-server.example.com>/v2/auth?service=<quay-server.example.com>&scope=repository:quay/listocireferrs:pull,push' --header 'Authorization: Basic <base64_username:password_encode_token>' -k | jq
出力例
{ "token": "<example_secret> }
第5章 Red Hat Quay API の有効化と使用
Red Hat Quay API を活用することで、コンテナーレジストリー管理を合理化し、タスクを自動化し、Red Hat Quay の機能を既存のワークフローに統合できます。これにより、効率と柔軟性 (リポジトリー管理、ユーザー管理、ユーザー権限、イメージ管理など) が向上し、組織やリポジトリー、あるいは全体的なデプロイメントの安定性などが向上します。
次のセクションでは、Red Hat Quay API を有効にして使用する方法を説明します。
5.1. API 呼び出しを受け付けるように Red Hat Quay を設定する
Red Hat Quay API を使用する前に、config.yaml
ファイルで BROWSER_API_CALLS_XHR_ONLY
を無効にする必要があります。これにより API calls must be invoked with an X-Requested-With header if called from a browser
などのエラーを回避できます。
手順
Red Hat Quay
config.yaml
ファイルで、BROWSER_API_CALLS_XHR_ONLY
をfalse
に設定します。以下に例を示します。# ... BROWSER_API_CALLS_XHR_ONLY: false # ...
- Red Hat Quay デプロイメントを再起動します。
5.2. Red Hat Quay API の使用
アプリケーションを作成し、必要な設定で OAuth 2 アクセストークンを生成したら、CLI から API を使用して、アクセストークンを GET
、PUT
、POST
、または DELETE
設定に渡すことができます。通常、Red Hat Quay API コマンドは次の例のようになります。
$ curl -X GET -H "Authorization: Bearer <your_access_token>" \ 1 https://<quay-server.example.com>/api/v1/<example>/<endpoint>/ 2
すべての Red Hat Quay API は、アプリケーションプログラミングインターフェイス (API) の章を参照してください。記載内容を理解することは、呼び出しを成功させるために非常に重要です。たとえば、createAppToken
API エンドポイントの次のエントリーがあります。
*createAppToken* 1 Create a new app specific token for user. 2 *POST /api/v1/user/apptoken* 3 **Authorizations: **oauth2_implicit (**user:admin**) 4 Request body schema (application/json) *Path parameters* 5 Name: **title** Description: Friendly name to help identify the token. Schema: string *Responses* 6 |HTTP Code|Description |Schema |201 |Successful creation | |400 |Bad Request |<<_apierror,ApiError>> |401 |Session required |<<_apierror,ApiError>> |403 |Unauthorized access |<<_apierror,ApiError>> |404 |Not found |<<_apierror,ApiError>> |===
API エンドポイントを使用するには、アクセストークンを渡し、必要に応じて適切なフィールドを含めます。次の手順は、POST/api/v1/user/apptoken
エンドポイントの使用方法を示しています。
前提条件
- Red Hat Quay API にアクセスできる。そのためには、OAuth 2 アクセストークンが作成済みでなければなりません。
-
config.yaml
ファイルでBROWSER_API_CALLS_XHR_ONLY: false
を設定している。
手順
POST /api/v1/user/apptoken
API 呼び出しを入力して、ユーザーアプリケーションを作成します。$ curl -X POST \ -H "Authorization: Bearer <access_token>" 1 -H "Content-Type: application/json" \ -d '{ "title": "MyAppToken" 2 }' \ "http://quay-server.example.com/api/v1/user/apptoken" 3
出力例
{"token": {"uuid": "6b5aa827-cee5-4fbe-a434-4b7b8a245ca7", "title": "MyAppToken", "last_accessed": null, "created": "Wed, 08 Jan 2025 19:32:48 -0000", "expiration": null, "token_code": "K2YQB1YO0ABYV5OBUYOMF9MCUABN12Y608Q9RHFXBI8K7IE8TYCI4WEEXSVH1AXWKZCKGUVA57PSA8N48PWED9F27PXATFUVUD9QDNCE9GOT9Q8ACYPIN0HL"}}
検証
Red Hat Quay UI のナビゲーションペインでユーザー名をクリックし、Account Settings をクリックします。アプリケーションの名前は、Docker CLI and other Application Tokens の見出しの下に表示されます。以下に例を示します。
5.3. Red Hat Quay Swagger UI へのアクセス
Red Hat Quay の管理者とユーザーは、実行可能コマンドをコンパイルする対話型 Web インターフェイスである Swagger UI を使用して API と対話できます。Swagger UI は、Red Hat Quay インスタンスの API 検出エンドポイント (/api/v1/discovery
) を指すコンテナーとして起動できます。コンテナーをデプロイすると、指定された URL から Red Hat Quay の OpenAPI 仕様を読み込む Swagger UI にアクセスできます。Red Hat Quay の管理者とユーザーは、利用可能なエンドポイントとその構成を調べることができます。
Red Hat Quay Swagger UI にアクセスするには、次の手順に従います。
手順
次のコマンドを入力して Swagger UI コンテナーをデプロイし、URL を Red Hat Quay の API 検出エンドポイントに指定します。以下に例を示します。
$ podman run -p 8080:8080 -e SWAGGER_JSON_URL=<quay-server.example.com> docker.swagger.io/swaggerapi/swagger-ui
出力例
--- /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh 20-envsubst-on-templates.sh: Running envsubst on /etc/nginx/templates/default.conf.template to /etc/nginx/conf.d/default.conf /docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh /docker-entrypoint.sh: Launching /docker-entrypoint.d/40-swagger-ui.sh /docker-entrypoint.sh: Configuration complete; ready for start up ---
-
localhost
URL に移動します。この例では、http://localhost:8080/ です。 Swagger UI を使用して、さまざまな API エンドポイントをテストします。たとえば、ユーザーの新しいトークンを作成するには、POST /api/v1/user/apptoken endpoint → Try it out → Execute をクリックして、
curl
コマンド例を生成します。注記現在、サーバー応答を生成できません。これは、Swagger UI がベアラートークンを受け入れるように設定されていないためです。その結果、各コマンドに対して、
{"error": "CSRF token was invalid or missing."}
のエラーが返されます。回避策として、このコマンドをターミナルにコピーし、ベアラートークンを手動で追加できます (例:-H 'Authorization: Bearer <bearer_token>'
)。
5.4. API を使用した Red Hat Quay プロセスの自動化
API を使用すると、Red Hat Quay 管理者と API にアクセスできるユーザーは、リポジトリー管理やイメージのプルーニングなどの反復タスクを自動化できます。
次の例は、Python スクリプトと cron ジョブを使用して、管理者のトークン 以外 の OAuth 2 アプリケーションの削除を自動化する方法を示しています。これは、OAuth 2 アクセストークンに関連付けられたアプリケーションが一定期間後に確実に循環されるようにする場合に役立ちます。
前提条件
- Red Hat Quay API にアクセスできる。そのためには、OAuth 2 アクセストークンが作成済みでなければなりません。
-
config.yaml
ファイルでBROWSER_API_CALLS_XHR_ONLY: false
を設定している。 -
Python
requests
ライブラリーをインストールした。 - マシン上で cron ジョブを有効化した。
- 削除されないものも含め、複数の組織アプリケーションを作成した。
手順
API コマンドを実行する Python スクリプトを作成します。次の例は、
DELETE /api/v1/organization/{orgname}/applications/{client_id}
API エンドポイントを使用して組織アプリケーションを削除するために使用します。example.py ファイル
import requests 1 # Hard-coded values API_BASE_URL = "http://<quay-server.example.com>/api/v1" 2 ACCESS_TOKEN = "<access_token>" 3 ORG_NAME = "<organization_name>" 4 def get_all_organization_applications(): url = f"{API_BASE_URL}/organization/{ORG_NAME}/applications" headers = { "Authorization": f"Bearer {ACCESS_TOKEN}" } response = requests.get(url, headers=headers) if response.status_code == 200: try: applications = response.json() # Print the raw response for debugging print("Raw response:", applications) # Adjust parsing logic based on the response structure if isinstance(applications, dict) and 'applications' in applications: applications = applications['applications'] if isinstance(applications, list): print("Organization applications retrieved successfully:") for app in applications: # Updated key from 'title' to 'name' print(f"Name: {app['name']}, Client ID: {app['client_id']}") return applications else: print("Unexpected response format.") return [] except requests.exceptions.JSONDecodeError: print("Error decoding JSON response:", response.text) return [] else: print(f"Failed to retrieve applications. Status code: {response.status_code}, Response: {response.text}") return [] def delete_organization_application(client_id): url = f"{API_BASE_URL}/organization/{ORG_NAME}/applications/{client_id}" headers = { "Authorization": f"Bearer {ACCESS_TOKEN}" } response = requests.delete(url, headers=headers) if response.status_code == 204: print(f"Application {client_id} deleted successfully.") else: print(f"Failed to delete application {client_id}. Status code: {response.status_code}, Response: {response.text}") def main(): applications = get_all_organization_applications() for app in applications: if app['name'] != "<admin_token_app>": <5> # Skip the "admin-token-app" delete_organization_application(app['client_id']) else: print(f"Skipping deletion of application: {app['name']}") # Execute the main function main()
-
スクリプトを
prune_applications.py
として保存します。 スクリプトを自動的に実行する cron ジョブを作成します。
次のコマンドを実行して、crontab エディターを開きます。
$ crontab -e
エディターで、スクリプトを実行するための cron ジョブを追加します。次の例では、スクリプトを月に 1 回実行します。
0 0 1 * * sudo python /path/to/prune_images.py >> /var/log/prune_images.log 2>&1
第6章 Red Hat Quay API の例
この章の残りの部分では、API が使用可能な機能における Red Hat Quay API の例を示します。
6.1. API を使用してユーザーアプリケーションを管理する
Red Hat Quay ユーザーは、Docker、Podman、またはその他のサービスプロバイダーのパスワードの代わりに使用できる ユーザーアプリケーション の作成、情報のリスト表示、削除を実行できます。ユーザーアプリケーショントークンはユーザー名とパスワードと同じように機能しますが、暗号化されており、Red Hat Quay に誰がアクセスしているかに関する情報を第三者に提供しません。
CLI 経由で作成したユーザーアプリケーショントークンは、Red Hat Quay UI の User Settings の下に表示されます。これは、ユーザー設定で作成されるアプリケーショントークンとは異なり、まったく別のアプリケーションとして扱う必要があることに注意してください。
ユーザーアプリケーショントークンを作成するには、次の手順に従います。
前提条件
- OAuth 2 アクセストークンを作成した。
手順
POST /api/v1/user/apptoken
API 呼び出しを入力して、ユーザーアプリケーションを作成します。$ curl -X POST \ -H "Authorization: Bearer <access_token>" \ -H "Content-Type: application/json" \ -d '{ "title": "MyAppToken" }' \ "http://quay-server.example.com/api/v1/user/apptoken"
出力例
{"token": {"uuid": "6b5aa827-cee5-4fbe-a434-4b7b8a245ca7", "title": "MyAppToken", "last_accessed": null, "created": "Wed, 08 Jan 2025 19:32:48 -0000", "expiration": null, "token_code": "K2YQB1YO0ABYV5OBUYOMF9MCUABN12Y608Q9RHFXBI8K7IE8TYCI4WEEXSVH1AXWKZCKGUVA57PSA8N48PWED9F27PXATFUVUD9QDNCE9GOT9Q8ACYPIN0HL"}}
GET /api/v1/user/apptoken
コマンドを使用すると、アプリケーションの有効期限など、アプリケーションに関する情報を取得できます。以下に例を示します。$ curl -X GET \ -H "Authorization: Bearer <access_token>" \ "http://quay-server.example.com/api/v1/user/apptoken"
{"tokens": [{"uuid": "6b5aa827-cee5-4fbe-a434-4b7b8a245ca7", "title": "MyAppToken", "last_accessed": null, "created": "Wed, 08 Jan 2025 19:32:48 -0000", "expiration": null}], "only_expiring": null}
GET /api/v1/user/apptoken/{token_uuid}
コマンドを入力すると、特定のユーザーアプリケーションに関する情報を取得できます。$ curl -X GET \ -H "Authorization: Bearer <access_token>" \ "http://quay-server.example.com/api/v1/user/apptoken/<token_uuid>"
出力例
{"token": {"uuid": "6b5aa827-cee5-4fbe-a434-4b7b8a245ca7", "title": "MyAppToken", "last_accessed": null, "created": "Wed, 08 Jan 2025 19:32:48 -0000", "expiration": null, "token_code": "K2YQB1YO0ABYV5OBUYOMF9MCUABN12Y608Q9RHFXBI8K7IE8TYCI4WEEXSVH1AXWKZCKGUVA57PSA8N48PWED9F27PXATFUVUD9QDNCE9GOT9Q8ACYPIN0HL"}}
DELETE /api/v1/user/apptoken/{token_uuid}
エンドポイントを使用すると、ユーザーアプリケーショントークンを削除または取り消すことができます。$ curl -X DELETE \ -H "Authorization: Bearer <access_token>" \ "http://quay-server.example.com/api/v1/user/apptoken/<token_uuid>"
このコマンドは CLI に出力を返しません。前述のコマンドのいずれかを入力すると、トークンのリストを返すことができます。
6.2. Red Hat Quay API エンドポイントの検出
Red Hat Quay API エンドポイントは、API を使用して検出できます。
利用可能な API エンドポイントを検出するには、次の手順に従います。
前提条件
- OAuth 2 アクセストークンを作成した。
手順
Swagger API 形式で使用可能なすべての API エンドポイントをリストするには、次の
GET /api/v1/discovery
コマンドを実行します。$ curl -X GET "https://<quay-server.example.com>/api/v1/discovery?query=true" \ -H "Authorization: Bearer <access_token>"
出力例
--- : "Manage the tags of a repository."}, {"name": "team", "description": "Create, list and manage an organization's teams."}, {"name": "trigger", "description": "Create, list and manage build triggers."}, {"name": "user", "description": "Manage the current user."}, {"name": "userfiles", "description": ""}]} ---
6.3. Red Hat Quay API エラーの詳細を取得する
Red Hat Quay API エラーの詳細は、API を使用して検出できます。
エラーの詳細を確認するには、次の手順に従います。
前提条件
- OAuth 2 アクセストークンを作成した。
手順
GET /api/v1/error/{error_type}
エンドポイントを入力すると、API のエラーの詳細を取得できます。次のいずれかのエラーコードを含める必要があることに注意してください。HTTP コード 説明 200 正常な呼び出し
400
Bad Request (不適切な要求)
401
セッションが必要
403
不正アクセス
404
見つからない
$ curl -X GET "https://<quay-server.example.com>/api/v1/error/<error_type>" \ -H "Authorization: Bearer <access_token>"
出力例
curl: (7) Failed to connect to quay-server.example.com port 443 after 0 ms: Couldn't connect to server
6.4. グローバルメッセージ
グローバルメッセージは、Red Hat Quay API を使用して作成、取得、または削除できます。グローバルメッセージを作成、取得、または削除するには、次の手順に従います。
前提条件
- OAuth 2 アクセストークンを作成した。
手順
POST /api/v1/message
エンドポイントを使用してメッセージを作成します。$ curl -X POST "https://<quay-server.example.com>/api/v1/messages" \ -H "Authorization: Bearer <access_token>" \ -H "Content-Type: application/json" \ -d '{ "message": { "content": "Hi", "media_type": "text/plain", "severity": "info" } }'
このコマンドは出力を返しません。
GET /api/v1/messages
コマンドを使用して、グローバルメッセージのリストを返します。$ curl -X GET "https://<quay-server.example.com>/api/v1/messages" \ -H "Authorization: Bearer <access_token>"
出力例
{"messages": [{"uuid": "ecababd4-3451-4458-b5db-801684137444", "content": "Hi", "severity": "info", "media_type": "text/plain"}]}
DELETE /api/v1/message/{uuid}
エンドポイントを使用して、グローバルメッセージを削除します。$ curl -X DELETE "https://<quay-server.example.com>/api/v1/message/<uuid>" \ -H "Authorization: Bearer <access_token>"
このコマンドは出力を返しません。
6.5. API を使用した使用状況ログの表示す
API を使用して、組織またはリポジトリー別にログを表示できます。ログは、集約 (グループ化) したり、より詳細にリスト表示したりすることもできます。ユーザー別、特定の日付範囲別、またはページ別に表示することもできます。
6.5.1. 集約されたログの表示
集約されたログは、組織、リポジトリー、特定のユーザー、または現在のユーザー別に表示できます。結果をフィルタリングするために、performer
、starttime/endtime
、next_page
などのオプションのコマンドを渡すこともできます。
前提条件
- OAuth アクセストークンを作成 した。
-
config.yaml
ファイルでBROWSER_API_CALLS_XHR_ONLY: false
を設定している。
手順
現在のユーザーの集約された (またはグループ化された) ログを返すには、
GET /api/v1/user/aggregatelogs
API エンドポイントを使用します。$ curl -X GET \ -H "Authorization: Bearer <bearer_token>" \ -H "Accept: application/json" \ "https://<quay-server.example.com>/api/v1/user/aggregatelogs"
出力例
{"aggregated": [{"kind": "create_tag", "count": 1, "datetime": "Tue, 18 Jun 2024 00:00:00 -0000"}, {"kind": "manifest_label_add", "count": 1, "datetime": "Tue, 18 Jun 2024 00:00:00 -0000"}, {"kind": "push_repo", "count": 2, "datetime": "Tue, 18 Jun 2024 00:00:00 -0000"}, {"kind": "revert_tag", "count": 1, "datetime": "Tue, 18 Jun 2024 00:00:00 -0000"}]}
また、
performer
とstarttime/endtime
クエリーを渡して、特定期間における特定のユーザーの集約されたログを取得することもできます。以下に例を示します。$ curl -X GET \ -H "Authorization: Bearer <bearer_token>" \ -H "Accept: application/json" \ "<quay-server.example.com>/api/v1/user/aggregatelogs?performer=<username>&starttime=<MM/DD/YYYY>&endtime=<MM/DD/YYYY>"
集約されたログは、
GET /api/v1/organization/{orgname}/aggregatelogs
を使用して組織別に表示することもできます。以下に例を示します。$ curl -X GET \ -H "Authorization: Bearer <bearer_token>" \ -H "Accept: application/json" \ "<quay-server.example.com>/api/v1/organization/{orgname}/aggregatelogs"
集約されたログは、
GET /api/v1/repository/{repository}/aggregatelogs
コマンドを使用してリポジトリー別に表示することもできます。次の例には、starttime/endtime
フィールドが含まれています。$ curl -X GET \ -H "Authorization: Bearer <bearer_token>" \ -H "Accept: application/json" \ "<quay-server.example.com>/api/v1/repository/<repository_name>/<namespace>/aggregatelogs?starttime=2024-01-01&endtime=2024-06-18""
6.5.2. 詳細なログの表示
詳細なログは、組織、リポジトリー、特定のユーザー、または現在のユーザー別に表示できます。結果をフィルタリングするために、performer
、starttime/endtime
、next_page
などのオプションのフィールドを渡すこともできます。
手順
ユーザーのログエントリーのリストを返すには、
GET /api/v1/user/logs
API エンドポイントを使用します。以下に例を示します。$ curl -X GET -H "Authorization: Bearer <bearer_token>" -H "Accept: application/json" "<quay-server.example.com>/api/v1/user/logs"
また、
performer
とstartime/endtime
クエリーを渡して、特定期間における特定のユーザーのログを取得することもできます。以下に例を示します。$ curl -X GET -H "Authorization: Bearer <bearer_token>" -H "Accept: application/json" "http://quay-server.example.com/api/v1/user/logs?performer=quayuser&starttime=01/01/2024&endtime=06/18/2024"
出力例
--- {"start_time": "Mon, 01 Jan 2024 00:00:00 -0000", "end_time": "Wed, 19 Jun 2024 00:00:00 -0000", "logs": [{"kind": "revert_tag", "metadata": {"username": "quayuser", "repo": "busybox", "tag": "test-two", "manifest_digest": "sha256:57583a1b9c0a7509d3417387b4f43acf80d08cdcf5266ac87987be3f8f919d5d"}, "ip": "192.168.1.131", "datetime": "Tue, 18 Jun 2024 18:59:13 -0000", "performer": {"kind": "user", "name": "quayuser", "is_robot": false, "avatar": {"name": "quayuser", "hash": "b28d563a6dc76b4431fc7b0524bbff6b810387dac86d9303874871839859c7cc", "color": "#17becf", "kind": "user"}}}, {"kind": "push_repo", "metadata": {"repo": "busybox", "namespace": "quayuser", "user-agent": "containers/5.30.1 (github.com/containers/image)", "tag": "test-two", "username": "quayuser", } ---
指定した組織のログを返すには、
GET /api/v1/organization/{orgname}/logs
エンドポイントを使用します。$ curl -X GET \ -H "Authorization: Bearer <bearer_token>" \ -H "Accept: application/json" \ "http://<quay-server.example.com>/api/v1/organization/{orgname}/logs"
指定したリポジトリーのログを返すには、
GET /api/v1/repository/{repository}/logs
エンドポイントを使用します。$ curl -X GET \ -H "Authorization: Bearer <bearer_token>" \ -H "Accept: application/json" \ "http://<quay-server.example.com>/api/v1/repository/{repository}/logs"
6.6. API を使用したログのエクスポート
詳細なログは、コールバック URL またはメールアドレスにエクスポートできます。
前提条件
- OAuth アクセストークンを作成 した。
-
config.yaml
ファイルでBROWSER_API_CALLS_XHR_ONLY: false
を設定している。
手順
現在のユーザーのログをエクスポートするには、
POST /api/v1/user/exportlogs
エンドポイントを使用します。$ curl -X POST \ -H "Authorization: Bearer <bearer_token>" \ -H "Content-Type: application/json" \ -H "Accept: application/json" \ -d '{ "starttime": "<MM/DD/YYYY>", "endtime": "<MM/DD/YYYY>", "callback_email": "your.email@example.com" }' \ "http://<quay-server.example.com>/api/v1/user/exportlogs"
出力例
{"export_id": "6a0b9ea9-444c-4a19-9db8-113201c38cd4"}
組織のログをエクスポートするには、
POST /api/v1/organization/{orgname}/exportlogs
エンドポイントを使用します。$ curl -X POST \ -H "Authorization: Bearer <bearer_token>" \ -H "Content-Type: application/json" \ -H "Accept: application/json" \ -d '{ "starttime": "<MM/DD/YYYY>", "endtime": "<MM/DD/YYYY>", "callback_email": "org.logs@example.com" }' \ "http://<quay-server.example.com>/api/v1/organization/{orgname}/exportlogs"
リポジトリーのログをエクスポートするには、
POST /api/v1/repository/{repository}/exportlogs
エンドポイントを使用します。$ curl -X POST \ -H "Authorization: Bearer <bearer_token>" \ -H "Content-Type: application/json" \ -H "Accept: application/json" \ -d '{ "starttime": "2024-01-01", "endtime": "2024-06-18", "callback_url": "http://your-callback-url.example.com" }' \ "http://<quay-server.example.com>/api/v1/repository/{repository}/exportlogs"
6.7. API を使用してラベルを追加および管理する
Red Hat Quay 管理者は、以下の手順を使用して、API を使用してタグのラベルを追加および管理できます。
前提条件
- OAuth アクセストークンを作成 した。
-
config.yaml
ファイルでBROWSER_API_CALLS_XHR_ONLY: false
を設定している。
手順
リポジトリー内にある特定のマニフェストの詳細を取得するには、
GET /api/v1/repository/{repository}/manifest/{manifestref}
コマンドを使用します。$ curl -X GET \ -H "Authorization: Bearer <bearer_token>" \ -H "Accept: application/json" \ https://<quay-server.example.com>/api/v1/repository/<repository>/manifest/<manifestref>
特定のマニフェストのラベルのリストを取得するには、
GET /api/v1/repository/{repository}/manifest/{manifestref}/labels
コマンドを使用します。$ curl -X GET \ -H "Authorization: Bearer <bearer_token>" \ -H "Accept: application/json" \ https://<quay-server.example.com>/api/v1/repository/<repository>/manifest/<manifestref>/labels
出力例
{"labels": [{"id": "e9f717d2-c1dd-4626-802d-733a029d17ad", "key": "org.opencontainers.image.url", "value": "https://github.com/docker-library/busybox", "source_type": "manifest", "media_type": "text/plain"}, {"id": "2d34ec64-4051-43ad-ae06-d5f81003576a", "key": "org.opencontainers.image.version", "value": "1.36.1-glibc", "source_type": "manifest", "media_type": "text/plain"}]}
特定のマニフェストに関する情報を取得するには、
GET /api/v1/repository/{repository}/manifest/{manifestref}/labels/{labelid}
コマンドを使用します。$ curl -X GET \ -H "Authorization: Bearer <bearer_token>" \ -H "Accept: application/json" \ https://<quay-server.example.com>/api/v1/repository/<repository>/manifest/<manifestref>/labels/<label_id>
出力例
{"id": "e9f717d2-c1dd-4626-802d-733a029d17ad", "key": "org.opencontainers.image.url", "value": "https://github.com/docker-library/busybox", "source_type": "manifest", "media_type": "text/plain"}
特定のリポジトリー内のマニフェストに追加のラベルを追加するには、
POST /api/v1/repository/{repository}/manifest/{manifestref}/labels
コマンドを使用します。以下に例を示します。$ curl -X POST \ -H "Authorization: Bearer <bearer_token>" \ -H "Content-Type: application/json" \ --data '{ "key": "<key>", "value": "<value>", "media_type": "<media_type>" }' \ https://<quay-server.example.com>/api/v1/repository/<repository>/manifest/<manifestref>/labels
出力例
{"label": {"id": "346593fd-18c8-49db-854f-4cb1fb76ff9c", "key": "example-key", "value": "example-value", "source_type": "api", "media_type": "text/plain"}}
DELETE/api/v1/repository/{repository}/manifest/{manifestref}/labels/{labelid}
コマンドを使用してラベルを削除できます。$ curl -X DELETE \ -H "Authorization: Bearer <bearer_token>" \ https://<quay-server.example.com>/api/v1/repository/<repository>/manifest/<manifestref>/labels/<labelid>
このコマンドは CLI に出力を返しません。上記のコマンドのいずれかを使用して、正常に削除されたことを確認できます。
6.8. API を使用してリポジトリーをミラーリングする
Red Hat Quay 管理者は、API を使用して外部リポジトリーをミラーリングできます。
前提条件
-
config.yaml
ファイルでFEATURE_REPO_MIRROR: true
を設定した。
手順
POST /api/v1/repository/{repository}/mirror
エンドポイントを使用して、新しいリポジトリーミラー設定を作成します。$ curl -X POST "https://<quay-server.example.com>/api/v1/repository/<namespace>/<repo>/mirror" \ -H "Authorization: Bearer <access_token>" \ -H "Content-Type: application/json" \ -d '{ "is_enabled": <is_enabled>, "external_reference": "<external_reference>", "external_registry_username": "<external_registry_username>", "external_registry_password": "<external_registry_password>", "sync_start_date": "<sync_start_date>", "sync_interval": <sync_interval>, "robot_username": "<robot_username>", "root_rule": { "rule": "<rule>", "rule_type": "<rule_type>" } }'
GET /api/v1/repository/{repository}/mirror
エンドポイントを使用して、ミラー設定に関する情報を返すことができます。$ curl -X GET "https://<quay-server.example.com>/api/v1/repository/<namespace>/<repo>/mirror" \ -H "Authorization: Bearer <access_token>"
出力例
{"is_enabled": true, "mirror_type": "PULL", "external_reference": "https://quay.io/repository/argoproj/argocd", "external_registry_username": null, "external_registry_config": {}, "sync_interval": 86400, "sync_start_date": "2025-01-15T12:00:00Z", "sync_expiration_date": null, "sync_retries_remaining": 3, "sync_status": "NEVER_RUN", "root_rule": {"rule_kind": "tag_glob_csv", "rule_value": ["*.latest*"]}, "robot_username": "quayadmin+mirror_robot"}
リポジトリーを同期するには、
POST /api/v1/repository/{repository}/mirror/sync-now
エンドポイントを使用します。以下に例を示します。$ curl -X POST "https://<quay-server.example.com>/api/v1/repository/<namespace>/<repo>/mirror/sync-now" \ -H "Authorization: Bearer <access_token>"
このコマンドは CLI に出力を返しません。
POST /api/v1/repository/{repository}/mirror/sync-cancel
エンドポイントを使用して、同期をキャンセルすることもできます。以下はその例です。$ curl -X POST "https://<quay-server.example.com>/api/v1/repository/<namespace>/<repo>/mirror/sync-cancel" \
このコマンドは CLI に出力を返しません。
ミラー設定を作成した後、
PUT /api/v1/repository/{repository}/mirror
コマンドを使用して変更を加えることができます。たとえば、自動同期を無効にする場合は次のようになります。$ curl -X PUT "https://<quay-server.example.com>/api/v1/repository/<namespace>/<repo>/mirror" \ -H "Authorization: Bearer <access_token>" \ -H "Content-Type: application/json" \ -d '{ "is_enabled": <false>, 1 "external_reference": "<external_reference>", "external_registry_username": "<external_registry_username>", "external_registry_password": "<external_registry_password>", "sync_start_date": "<sync_start_date>", "sync_interval": <sync_interval>, "robot_username": "<robot_username>", "root_rule": { "rule": "<rule>", "rule_type": "<rule_type>" } }'
- 1
- 自動同期を無効にします。
6.9. Red Hat Quay API を使用したクォータの確立
組織またはユーザーのクォータを設定し、レジストリーのニーズに合わせてクォータポリシーをカスタマイズできます。
次のセクションでは、組織とユーザーのクォータを設定する方法と、それらの設定を変更する方法を説明します。
6.9.1. Red Hat Quay API を使用した組織のクォータの管理
組織を初めて作成した時点では、クォータは設定されていません。API を使用して、組織のクォータ制限を確認、作成、変更、または削除できます。
前提条件
- OAuth アクセストークンを生成した。
手順
組織のクォータを設定するには、
POST /api/v1/organization/{orgname}/quota
エンドポイントを使用します。$ curl -X POST "https://<quay-server.example.com>/api/v1/organization/<orgname>/quota" \ -H "Authorization: Bearer <access_token>" \ -H "Content-Type: application/json" \ -d '{ "limit_bytes": 10737418240, "limits": "10 Gi" }'
出力例
"Created"
GET /api/v1/organization/{orgname}/quota
コマンドを使用して、他の組織のクォータエンドポイントに必要なポリシーに関する情報 (ID 番号など) を返します。以下に例を示します。$ curl -k -X GET -H "Authorization: Bearer <token>" -H 'Content-Type: application/json' https://example-registry-quay-quay-enterprise.apps.docs.gcp.quaydev.org/api/v1/organization/testorg/quota | jq
出力例
[{"id": 1, "limit_bytes": 10737418240, "limit": "10.0 GiB", "default_config": false, "limits": [], "default_config_exists": false}]
ID 番号を取得したら、
GET /api/v1/organization/{orgname}/quota/{quota_id}
コマンドを使用してクォータポリシーをリスト表示できます。以下に例を示します。$ curl -X GET "https://<quay-server.example.com>/api/v1/organization/<orgname>/quota/<quota_id>" \ -H "Authorization: Bearer <access_token>"
出力例
{"id": 1, "limit_bytes": 10737418240, "limit": "10.0 GiB", "default_config": false, "limits": [], "default_config_exists": false}
既存のクォータ制限を変更するには、
PUT /api/v1/organization/{orgname}/quota/{quota_id}
コマンドを使用します。その場合はポリシー ID が必要であることに注意してください。以下に例を示します。$ curl -X PUT "https://<quay-server.example.com>/api/v1/organization/<orgname>/quota/<quota_id>" \ -H "Authorization: Bearer <access_token>" \ -H "Content-Type: application/json" \ -d '{ "limit_bytes": <limit_in_bytes> }'
出力例
{"id": 1, "limit_bytes": 21474836480, "limit": "20.0 GiB", "default_config": false, "limits": [], "default_config_exists": false}
組織のクォータを削除するには、
DELETE /api/v1/organization/{orgname}/quota/{quota_id}
コマンドを使用します。以下に例を示します。$ curl -X DELETE "https://<quay-server.example.com>/api/v1/organization/<orgname>/quota/<quota_id>" \ -H "Authorization: Bearer <access_token>"
このコマンドは出力を返しません。
6.9.2. Red Hat Quay API を使用して組織のクォータ制限を設定する
組織に対して特定のクォータ制限を設定すると、それを超過した場合に警告が返されるか、プッシュされたイメージが完全に拒否されるようになります。
手順
POST /api/v1/organization/{orgname}/quota/{quota_id}/limit
コマンドを使用して、割り当てられたクォータを超えた場合にイメージを拒否するクォータポリシーを作成します。以下に例を示します。$ curl -X POST "https://<quay-server.example.com>/api/v1/organization/<orgname>/quota/<quota_id>/limit" \ -H "Authorization: Bearer <access_token>" \ -H "Content-Type: application/json" \ -d '{ "limit_bytes": 21474836480, "type": "Reject", 1 "threshold_percent": 90 2 }'
出力例
"Created"
GET /api/v1/organization/{orgname}/quota/{quota_id}/limit
を使用して、クォータ制限の ID を取得します。以下に例を示します。$ curl -X GET "https://<quay-server.example.com>/api/v1/organization/<orgname>/quota/<quota_id>/limit" \ -H "Authorization: Bearer <access_token>"
出力例
[{"id": 2, "type": "Reject", "limit_percent": 90}]
PUT/api/v1/organization/{orgname}/quota/{quota_id}/limit/{limit_id}
エンドポイントを使用して、ポリシーを更新します。以下に例を示します。$ curl -X PUT "https://<quay-server.example.com>/api/v1/organization/<orgname>/quota/<quota_id>/limit/<limit_id>" \ -H "Authorization: Bearer <access_token>" \ -H "Content-Type: application/json" \ -d '{ "type": "<type>", "threshold_percent": <threshold_percent> }'
出力例
{"id": 3, "limit_bytes": 10737418240, "limit": "10.0 GiB", "default_config": false, "limits": [{"id": 2, "type": "Warning", "limit_percent": 80}], "default_config_exists": false}
DELETE/api/v1/organization/{orgname}/quota/{quota_id}/limit/{limit_id}
エンドポイントを使用して、クォータ制限を削除できます。$ curl -X DELETE "https://<quay-server.example.com>/api/v1/organization/<orgname>/quota/<quota_id>/limit/<limit_id>" \ -H "Authorization: Bearer <access_token>"
このコマンドは出力を返しません。
6.9.3. Red Hat Quay API を使用してユーザーのクォータ制限を取得する
ユーザーに対してクォータと制限を指定して、それを超過した場合に警告が返されるか、プッシュされたイメージが完全に拒否されるようにできます。ユーザーのクォータ制限は、Red Hat Quay UI で設定する必要があります。次の API を使用して、ログインしているユーザーのクォータ制限を表示できます。
手順
GET /api/v1/user/quota
コマンドを使用して、クォータ制限に関する情報を返します。$ curl -X GET "https://<quay-server.example.com>/api/v1/user/quota" \ -H "Authorization: Bearer <access_token>"
出力例
[{"id": 4, "limit_bytes": 2199023255552, "limit": "2.0 TiB", "default_config": false, "limits": [], "default_config_exists": false}]
クォータ ID を受け取ったら、
GET /api/v1/user/quota/{quota_id}
エンドポイントでそれを渡し、制限に関する情報を返すことができます。$ curl -X GET "https://<quay-server.example.com>/api/v1/user/quota/{quota_id}" \ -H "Authorization: Bearer <access_token>"
出力例
{"id": 4, "limit_bytes": 2199023255552, "limit": "2.0 TiB", "default_config": false, "limits": [], "default_config_exists": false}
制限は、
GET /api/v1/user/quota/{quota_id}/limit
エンドポイントを使用して確認できます。以下に例を示します。$ curl -X GET "https://<quay-server.example.com>/api/v1/user/quota/{quota_id}/limit" \ -H "Authorization: Bearer <access_token>"
出力例
[{"id": 3, "type": "Reject", "limit_percent": 100}]
GET /api/v1/user/quota/{quota_id}/limit/{limit_id}
エンドポイントを使用して、ポリシー全体に関する追加情報を返すことができます。$ curl -X GET "https://<quay-server.example.com>/api/v1/user/quota/{quota_id}/limit/{limit_id}" \ -H "Authorization: Bearer <access_token>"
出力例
{"id": 4, "limit_bytes": 2199023255552, "limit": "2.0 TiB", "default_config": false, "limits": [{"id": 3, "type": "Reject", "limit_percent": 100}], "default_config_exists": false}
6.10. Red Hat Quay API を使用したクォータの確立
組織は API エンドポイントを通じて作成および管理できます。Red Hat Quay API を使用すると、組織の作成、組織情報の表示、組織のプロキシーキャッシュの作成、組織へのアクセス権を持つユーザーの編集、組織の詳細の変更、組織の削除などを実行できます。
6.10.1. Red Hat Quay API を使用した組織の作成
Red Hat Quay API を使用して新しい組織を作成するには、次の手順に従います。
前提条件
- OAuth アクセストークンを作成 した。
-
config.yaml
ファイルでBROWSER_API_CALLS_XHR_ONLY: false
を設定している。
手順
次のコマンドを入力し、
POST /api/v1/organization/
エンドポイントを使用して新しい組織を作成します。$ curl -X POST -H "Authorization: Bearer <bearer_token>" -H "Content-Type: application/json" -d '{ "name": "<new_organization_name>" }' "https://<quay-server.example.com>/api/v1/organization/"
出力例
"Created"
作成後、
PUT /api/v1/organization/{orgname}
コマンドを使用して、メールアドレスの追加など、組織の詳細を変更できます。以下に例を示します。$ curl -X PUT "https://<quay-server.example.com>/api/v1/organization/<orgname>" \ -H "Authorization: Bearer <access_token>" \ -H "Content-Type: application/json" \ -d '{ "email": "<org_email>", "invoice_email": <true/false>, "invoice_email_address": "<billing_email>" }'
出力例
{"name": "test", "email": "new-contact@test-org.com", "avatar": {"name": "test", "hash": "a15d479002b20f211568fd4419e76686d2b88a4980a5b4c4bc10420776c5f6fe", "color": "#aec7e8", "kind": "user"}, "is_admin": true, "is_member": true, "teams": {"owners": {"name": "owners", "description": "", "role": "admin", "avatar": {"name": "owners", "hash": "6f0e3a8c0eb46e8834b43b03374ece43a030621d92a7437beb48f871e90f8d90", "color": "#c7c7c7", "kind": "team"}, "can_view": true, "repo_count": 0, "member_count": 1, "is_synced": false}}, "ordered_teams": ["owners"], "invoice_email": true, "invoice_email_address": "billing@test-org.com", "tag_expiration_s": 1209600, "is_free_account": true, "quotas": [{"id": 2, "limit_bytes": 10737418240, "limits": [{"id": 1, "type": "Reject", "limit_percent": 90}]}], "quota_report": {"quota_bytes": 0, "configured_quota": 10737418240, "running_backfill": "complete", "backfill_status": "complete"}}
6.10.2. Red Hat Quay API を使用した組織の削除
Red Hat Quay API を使用して組織を削除するには、次の手順に従います。
前提条件
- OAuth アクセストークンを作成 した。
-
config.yaml
ファイルでBROWSER_API_CALLS_XHR_ONLY: false
を設定している。
手順
次のコマンドを入力し、
DELETE /api/v1/organization/{orgname}
エンドポイントを使用して組織を削除します。$ curl -X DELETE \ -H "Authorization: Bearer <bearer_token>" \ "https://<quay-server.example.com>/api/v1/organization/<organization_name>"
CLI から組織を削除する場合、CLI は情報を返しません。削除を確認するには、Red Hat Quay UI を確認するか、
GET /api/v1/organization/{orgname}
コマンドを入力して、削除した組織の詳細が返されるかどうかを確認します。$ curl -X GET \ -H "Authorization: Bearer <bearer_token>" \ "<quay-server.example.com>/api/v1/organization/<organization_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}
6.10.3. API を使用して組織メンバーの情報を取得する
組織メンバーに関する情報は、Red Hat Quay API を使用して取得できます。
手順
GET /api/v1/organization/{orgname}/members
使用して、組織メンバーのリストを返します。$ curl -X GET "https://<quay-server.example.com>/api/v1/organization/<orgname>/members" \ -H "Authorization: Bearer <access_token>"
出力例
{"members": [{"name": "quayadmin", "kind": "user", "avatar": {"name": "quayadmin", "hash": "6d640d802fe23b93779b987c187a4b7a4d8fbcbd4febe7009bdff58d84498fba", "color": "#f7b6d2", "kind": "user"}, "teams": [{"name": "owners", "avatar": {"name": "owners", "hash": "6f0e3a8c0eb46e8834b43b03374ece43a030621d92a7437beb48f871e90f8d90", "color": "#c7c7c7", "kind": "team"}}], "repositories": ["testrepo"]}, {"name": "testuser", "kind": "user", "avatar": {"name": "testuser", "hash": "f660ab912ec121d1b1e928a0bb4bc61b15f5ad44d5efdc4e1c92a25e99b8e44a", "color": "#6b6ecf", "kind": "user"}, "teams": [{"name": "owners", "avatar": {"name": "owners", "hash": "6f0e3a8c0eb46e8834b43b03374ece43a030621d92a7437beb48f871e90f8d90", "color": "#c7c7c7", "kind": "team"}}], "repositories": []}]}
GET /api/v1/organization/{orgname}/collaborators
使用して、組織の共同作業者のリストを返すことができます。$ curl -X GET "https://<quay-server.example.com>/api/v1/organization/{orgname}/collaborators" \ -H "Authorization: Bearer <access_token>"
出力例
{"collaborators": [user-test]}
ユーザーに関するより具体的な情報を取得するには、
GET /api/v1/organization/{orgname}/members/{membername}
エンドポイントを使用します。$ curl -X GET "https://<quay-server.example.com>/api/v1/organization/<orgname>/members/<membername>" \ -H "Authorization: Bearer <access_token>"
出力例
{"name": "quayadmin", "kind": "user", "avatar": {"name": "quayadmin", "hash": "6d640d802fe23b93779b987c187a4b7a4d8fbcbd4febe7009bdff58d84498fba", "color": "#f7b6d2", "kind": "user"}, "teams": [{"name": "owners", "avatar": {"name": "owners", "hash": "6f0e3a8c0eb46e8834b43b03374ece43a030621d92a7437beb48f871e90f8d90", "color": "#c7c7c7", "kind": "team"}}], "repositories": ["testrepo"]}
チームメンバーを削除するには、
DELETE /api/v1/organization/{orgname}/members/{membername}
エンドポイントを使用します。$ curl -X DELETE "https://<quay-server.example.com>/api/v1/organization/<orgname>/members/<membername>" \ -H "Authorization: Bearer <access_token>"
このコマンドは出力を返しません。
6.10.4. Red Hat Quay API を使用して組織アプリケーションを作成する
組織アプリケーションは、Red Hat Quay UI を使用して作成できます。
組織アプリケーションは UI を使用して作成できますが、OAuth 2 アクセストークンは UI で作成する必要があります。
手順
組織用の新しいアプリケーションを作成するには、
POST /api/v1/organization/{orgname}/applications
エンドポイントを使用します。以下に例を示します。$ curl -X POST "https://<quay-server.example.com>/api/v1/organization/<orgname>/applications" \ -H "Authorization: Bearer <access_token>" \ -H "Content-Type: application/json" \ -d '{ "name": "<app_name>", "redirect_uri": "<redirect_uri>", "application_uri": "<application_uri>", "description": "<app_description>", "avatar_email": "<avatar_email>" }'
出力例
{"name": "new-application", "description": "", "application_uri": "", "client_id": "E6GJSHOZMFBVNHTHNB53", "client_secret": "SANSWCWSGLVAUQ60L4Q4CEO3C1QAYGEXZK2VKJNI", "redirect_uri": "", "avatar_email": null}
GET /api/v1/organization/{orgname}/applications
エンドポイントを使用して、すべての組織アプリケーションのリストを返します。以下に例を示します。$ curl -X GET "https://<quay-server.example.com>/api/v1/organization/<orgname>/applications" \ -H "Authorization: Bearer <access_token>"
出力例
{"applications": [{"name": "test", "description": "", "application_uri": "", "client_id": "MCJ61D8KQBFS2DXM56S2", "client_secret": "J5G7CCX5QCA8Q5XZLWGI7USJPSM4M5MQHJED46CF", "redirect_uri": "", "avatar_email": null}, {"name": "new-token", "description": "", "application_uri": "", "client_id": "IG58PX2REEY9O08IZFZE", "client_secret": "2LWTWO89KH26P2CO4TWFM7PGCX4V4SUZES2CIZMR", "redirect_uri": "", "avatar_email": null}, {"name": "second-token", "description": "", "application_uri": "", "client_id": "6XBK7QY7ACSCN5XBM3GS", "client_secret": "AVKBOUXTFO3MXBBK5UJD5QCQRN2FWL3O0XPZZT78", "redirect_uri": "", "avatar_email": null}, {"name": "new-application", "description": "", "application_uri": "", "client_id": "E6GJSHOZMFBVNHTHNB53", "client_secret": "SANSWCWSGLVAUQ60L4Q4CEO3C1QAYGEXZK2VKJNI", "redirect_uri": "", "avatar_email": null}]}
GET/api/v1/organization/{orgname}/applications/{client_id}
エンドポイントを使用して、特定のクライアントのアプリケーションを返すこともできます。以下に例を示します。$ curl -X GET "https://<quay-server.example.com>/api/v1/organization/<orgname>/applications/<client_id>" \ -H "Authorization: Bearer <access_token>"
出力例
{"name": "test", "description": "", "application_uri": "", "client_id": "MCJ61D8KQBFS2DXM56S2", "client_secret": "J5G7CCX5QCA8Q5XZLWGI7USJPSM4M5MQHJED46CF", "redirect_uri": "", "avatar_email": null}
作成後に、組織アプリケーションを更新できます。たとえば、リダイレクト URI や新しい説明を追加する場合は、
PUT /api/v1/organization/{orgname}/applications/{client_id}
エンドポイントを使用します。$ curl -X PUT "https://quay-server.example.com/api/v1/organization/test/applications/12345" \ -H "Authorization: Bearer <access_token>" \ -H "Content-Type: application/json" \ -d '{ "name": "Updated Application Name", "redirect_uri": "https://example.com/oauth/callback", "application_uri": "https://example.com", "description": "Updated description for the application", "avatar_email": "avatar@example.com" }'
作成後、
GET /api/v1/app/{client_id}
エンドポイントを使用してアプリケーション情報を返すことができます。$ curl -X GET "https://<quay-server.example.com>/api/v1/app/<client_id>" \ -H "Authorization: Bearer <access_token>"
出力例
{"name": "new-application3", "description": "", "uri": "", "avatar": {"name": "new-application3", "hash": "a15d479002b20f211568fd4419e76686d2b88a4980a5b4c4bc10420776c5f6fe", "color": "#aec7e8", "kind": "app"}, "organization": {"name": "test", "email": "new-contact@test-org.com", "avatar": {"name": "test", "hash": "a15d479002b20f211568fd4419e76686d2b88a4980a5b4c4bc10420776c5f6fe", "color": "#aec7e8", "kind": "user"}, "is_admin": true, "is_member": true, "teams": {}, "ordered_teams": [], "invoice_email": true, "invoice_email_address": "billing@test-org.com", "tag_expiration_s": 1209600, "is_free_account": true, "quotas": [{"id": 2, "limit_bytes": 10737418240, "limits": [{"id": 1, "type": "Reject", "limit_percent": 90}]}], "quota_report": {"quota_bytes": 0, "configured_quota": 10737418240, "running_backfill": "complete", "backfill_status": "complete"}}}
組織アプリケーション、
DELETE /api/v1/organization/{orgname}/applications/{client_id}
エンドポイントを使用して削除できます。以下に例を示します。$ curl -X DELETE "https://<quay-server.example.com>/api/v1/organization/{orgname}/applications/{client_id}" \ -H "Authorization: Bearer <access_token>"
このコマンドは出力を返しません。
6.10.5. Red Hat Quay API を使用して組織のプロキシーキャッシュを設定する
組織のプロキシーキャッシュは、Red Hat Quay API を使用して設定できます。
手順
組織のプロキシーキャッシュ設定を作成するには、
POST /api/v1/organization/{orgname}/proxycache
エンドポイントを使用します。$ curl -X POST "https://<quay-server.example.com>/api/v1/organization/<orgname>/proxycache" \ -H "Authorization: Bearer <access_token>" \ -H "Content-Type: application/json" \ -d '{ "upstream_registry": "<upstream_registry>" }'
プロキシー設定を検証するには、
POST /api/v1/organization/{orgname}/validateproxycache
エンドポイントを使用します。$ curl -X POST "https://<quay-server.example.com>/api/v1/organization/{orgname}/validateproxycache" \ -H "Authorization: Bearer <access_token>" \ -H "Content-Type: application/json" \ -d '{ "upstream_registry": "<upstream_registry>" }'
プロキシーキャッシュに関する情報を取得するには、
GET /api/v1/organization/{orgname}/proxycache
エンドポイントを使用します。以下に例を示します。$ curl -X GET "https://<quay-server.example.com>/api/v1/organization/{orgname}/proxycache" \ -H "Authorization: Bearer <access_token>"
出力例
{"upstream_registry": "quay.io", "expiration_s": 86400, "insecure": false}
DELETE /api/v1/organization/{orgname}/proxycache
エンドポイントを使用します。$ curl -X DELETE "https://<quay-server.example.com>/api/v1/organization/{orgname}/proxycache" \ -H "Authorization: Bearer <access_token>"
出力例
"Deleted"
6.11. Red Hat Quay API を使用してリポジトリー権限を管理する
リポジトリー権限は、Red Hat Quay API を使用して管理できます。たとえば、ユーザーおよびチームの権限を作成、表示、削除できます。
次の手順は、Red Hat Quay API を使用してリポジトリー権限を管理する方法を示しています。
6.11.1. Red Hat Quay API を使用してユーザー権限を管理する
Red Hat Quay API を使用してユーザー権限を管理するには、次の手順に従います。
手順
ユーザーのリポジトリー権限を取得するには、
GET /api/v1/repository/{repository}/permissions/user/{username}
エンドポイントを使用します。以下に例を示します。$ curl -X GET \ -H "Authorization: Bearer <access_token>" \ "https://quay-server.example.com/api/v1/repository/<repository_path>/permissions/user/<username>"
出力例
$ {"role": "read", "name": "testuser", "is_robot": false, "avatar": {"name": "testuser", "hash": "f660ab912ec121d1b1e928a0bb4bc61b15f5ad44d5efdc4e1c92a25e99b8e44a", "color": "#6b6ecf", "kind": "user"}, "is_org_member": false}
すべてのユーザー権限は
GET /api/v1/repository/{repository}/permissions/user/
エンドポイントを使用して返せます。$ curl -X GET \ -H "Authorization: Bearer <access_token>" \ "https://quay-server.example.com/api/v1/repository/<namespace>/<repository>/permissions/user/"
出力例
{"permissions": {"quayadmin": {"role": "admin", "name": "quayadmin", "is_robot": false, "avatar": {"name": "quayadmin", "hash": "6d640d802fe23b93779b987c187a4b7a4d8fbcbd4febe7009bdff58d84498fba", "color": "#f7b6d2", "kind": "user"}, "is_org_member": true}, "test+example": {"role": "admin", "name": "test+example", "is_robot": true, "avatar": {"name": "test+example", "hash": "3b03050c26e900500437beee4f7f2a5855ca7e7c5eab4623a023ee613565a60e", "color": "#a1d99b", "kind": "robot"}, "is_org_member": true}}}
または、
GET /api/v1/repository/{repository}/permissions/user/{username}/transitive
エンドポイントを使用して、ユーザーのリポジトリー権限のみを返すこともできます。$ curl -X GET \ -H "Authorization: Bearer <access_token>" \ "https://quay-server.example.com/api/v1/repository/<repository_path>/permissions/user/<username>/transitive"
出力例
{"permissions": [{"role": "admin"}]}
PUT /api/v1/repository/{repository}/permissions/user/{username}
エンドポイントを使用して、ユーザーをadmin
にするなど、ユーザーの権限を変更できます。以下に例を示します。$ curl -X PUT \ -H "Authorization: Bearer <access_token>" \ -H "Content-Type: application/json" \ -d '{"role": "<role>"}' \ "https://quay-server.example.com/api/v1/repository/<repository_path>/permissions/user/<username>"
出力例
{"role": "admin", "name": "testuser", "is_robot": false, "avatar": {"name": "testuser", "hash": "f660ab912ec121d1b1e928a0bb4bc61b15f5ad44d5efdc4e1c92a25e99b8e44a", "color": "#6b6ecf", "kind": "user"}, "is_org_member": false}
ユーザー権限は、
DELETE /api/v1/repository/{repository}/permissions/user/{username}
エンドポイントを使用して削除できます。以下に例を示します。$ curl -X DELETE \ -H "Authorization: Bearer <access_token>" \ "https://quay-server.example.com/api/v1/repository/<namespace>/<repository>/permissions/user/<username>"
このコマンドは出力を返しません。
6.11.2. Red Hat Quay API を使用してチーム権限を管理する
Red Hat Quay API を使用してチーム権限を管理するには、次の手順に従います。
指定されたチームの権限は、
GET /api/v1/repository/{repository}/permissions/team/{teamname}
エンドポイントを使用して返せます。$ curl -X GET \ -H "Authorization: Bearer <access_token>" \ "https://quay-server.example.com/api/v1/repository/<namespace>/<repository>/permissions/team/<teamname>"
出力例
{"role": "write"}
すべてのチームの権限は、
GET /api/v1/repository/{repository}/permissions/team/
エンドポイントを使用して返せます。以下に例を示します。$ curl -X GET \ -H "Authorization: Bearer <access_token>" \ "https://quay-server.example.com/api/v1/repository/<namespace>/<repository>/permissions/team/"
出力例
{"permissions": {"ironmanteam": {"role": "read", "name": "ironmanteam", "avatar": {"name": "ironmanteam", "hash": "8045b2361613622183e87f33a7bfc54e100a41bca41094abb64320df29ef458d", "color": "#969696", "kind": "team"}}, "sillyteam": {"role": "read", "name": "sillyteam", "avatar": {"name": "sillyteam", "hash": "f275d39bdee2766d2404e2c6dbff28fe290969242e9fcf1ffb2cde36b83448ff", "color": "#17becf", "kind": "team"}}}}
指定されたチームの権限は、
PUT /api/v1/repository/{repository}/permissions/team/{teamname}
コマンドを使用して変更できます。以下に例を示します。$ curl -X PUT \ -H "Authorization: Bearer <access_token>" \ -H "Content-Type: application/json" \ -d '{"role": "<role>"}' \ "https://quay-server.example.com/api/v1/repository/<namespace>/<repository>/permissions/team/<teamname>"
出力例
{"role": "admin", "name": "superteam", "avatar": {"name": "superteam", "hash": "48cb6d114200039fed5c601480653ae7371d5a8849521d4c3bf2418ea013fc0f", "color": "#9467bd", "kind": "team"}}
チーム権限は、
DELETE /api/v1/repository/{repository}/permissions/team/{teamname}
ンドを使用して削除できます。以下に例を示します。$ curl -X DELETE \ -H "Authorization: Bearer <access_token>" \ "https://quay-server.example.com/api/v1/repository/<namespace>/<repository>/permissions/team/<teamname>"
このコマンドは CLI に出力を返しません。
6.12. 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.12.1. Red Hat Quay API を使用した名前空間の自動プルーニングポリシーの作成
Red Hat Quay API エンドポイントを使用して、名前空間の自動プルーニングポリシーを管理できます。
前提条件
-
config.yaml
ファイルでBROWSER_API_CALLS_XHR_ONLY: false
を設定している。 - OAuth アクセストークンを作成している。
- Red Hat Quay にログインしている。
手順
次の
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"}
オプション: 組織にポリシーを追加し、
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
tagPatternMatches
をtrue
に設定すると、指定された正規表現パターンに一致するタグがプルーニングされます。この例では、^v*
に一致するタグがプルーニングされます。
出力例
{"uuid": "ebf7448b-93c3-4f14-bf2f-25aa6857c7b0"}
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>"
このコマンドは出力を返しません。次のステップに進みます。
次のコマンドを入力して、自動プルーニングポリシーを確認します。
$ 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}]}
次のコマンドを入力すると、組織の自動プルーニングポリシーを削除できます。ポリシーを削除するには 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 にログインしている。
手順
次の
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"}
次のコマンドを入力して、自動プルーニングポリシーを確認します。
$ 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}]}
次のコマンドを入力すると、自動プルーニングポリシーを削除できます。ポリシーを削除するには 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 にログインしている。
手順
次の
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"}
オプション: ポリシーを追加し、
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
tagPatternMatches
をfalse
に設定すると、指定された正規表現パターンに 一致しない すべてのタグがプルーニングされます。この例では、^test.
以外 のすべてのタグがプルーニングされます。
出力例
{"uuid": "b53d8d3f-2e73-40e7-96ff-736d372cd5ef"}
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>"
このコマンドは出力を返しません。次の手順に進み、自動プルーニングポリシーを確認します。
次のコマンドを入力して、自動プルーニングポリシーを確認します。
$ 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}]}
次のコマンドを入力すると、自動プルーニングポリシーを削除できます。ポリシーを削除するには 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
権限がある。
手順
次の
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"}
オプション: 現在のユーザーに対してポリシーを追加し、
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"}
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 に出力は返されません。
次のコマンドを入力して、自動プルーニングポリシーを確認します。
$ 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}
次のコマンドを入力すると、自動プルーニングポリシーを削除できます。ポリシーを削除するには 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"}
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": []}
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"}
6.15. レジストリーコンテキストに対する検索
search
API エンドポイントを使用して、すべてのレジストリーコンテキストに対して検索を実行できます。
手順
GET /api/v1/find/repositories
エンドポイントを使用して、指定されたクエリーに一致するアプリケーションとリポジトリーのリストを取得します。$ curl -X GET "https://quay-server.example.com/api/v1/find/repositories?query=<repo_name>&page=1&includeUsage=true" \ -H "Authorization: Bearer <bearer_token>"
出力例
{"results": [], "has_additional": false, "page": 2, "page_size": 10, "start_index": 10}
GET /api/v1/find/all
エンドポイントを使用して、指定したクエリーに一致するエンティティーとリソースのリストを取得します。$ curl -X GET "https://quay-server.example.com/api/v1/find/all?query=<mysearchterm>" \ -H "Authorization: Bearer <bearer_token>"
出力例
{"results": [{"kind": "repository", "title": "repo", "namespace": {"title": "user", "kind": "user", "avatar": {"name": "quayadmin", "hash": "6d640d802fe23b93779b987c187a4b7a4d8fbcbd4febe7009bdff58d84498fba", "color": "#f7b6d2", "kind": "user"}, "name": "quayadmin", "score": 1, "href": "/user/quayadmin"}, "name": "busybox", "description": null, "is_public": false, "score": 4.0, "href": "/repository/quayadmin/busybox"}]}
GET /api/v1/entities/{prefix}
エンドポイントを使用して、指定した接頭辞に一致するエンティティーのリストを取得します。$ curl -X GET "https://quay-server.example.com/api/v1/entities/<prefix>?includeOrgs=<true_or_false>&includeTeams=<true_or_false>&namespace=<namespace>" \ -H "Authorization: Bearer <bearer_token>"
出力例
{"results": [{"name": "quayadmin", "kind": "user", "is_robot": false, "avatar": {"name": "quayadmin", "hash": "6d640d802fe23b93779b987c187a4b7a4d8fbcbd4febe7009bdff58d84498fba", "color": "#f7b6d2", "kind": "user"}}]}
6.16. API を使用した Clair セキュリティースキャンの表示
API を使用して Clair セキュリティースキャンを表示できます。
手順
リポジトリー内の特定のマニフェストに関するセキュリティー情報を取得するには、
GET /api/v1/repository/{repository}/manifest/{manifestref}/security
エンドポイントを使用します。以下に例を示します。$ curl -X GET \ -H "Authorization: Bearer <bearer_token>" \ -H "Accept: application/json" \ "https://quay-server.example.com/api/v1/repository/<namespace>/<repository>/manifest/<manifest_digest>/security?vulnerabilities=<true_or_false>"
出力例
{"status": "queued", "data": null}
6.17. Red Hat Quay API を使用してスーパーユーザーとしてデプロイメントを管理する
Red Hat Quay UI を通じて、スーパーユーザーは、ユーザー、サービスキー、ユーザーのクォータなど、レジストリーの側面を作成、リスト表示、変更、削除することができます。
6.17.1. Red Hat Quay API を使用したユーザーアカウントの作成
API を使用して Red Hat Quay リポジトリーの新しいユーザーを作成するには、次の手順に従います。
前提条件
- スーパーユーザーとして Red Hat Quay デプロイメントにログインしている。
- OAuth アクセストークンを作成 した。
-
config.yaml
ファイルでBROWSER_API_CALLS_XHR_ONLY: false
を設定している。
手順
次のコマンドを入力し、
POST /api/v1/superuser/users/
エンドポイントを使用して新しいユーザーを作成します。$ curl -X POST -H "Authorization: Bearer <bearer_token>" -H "Content-Type: application/json" -d '{ "username": "newuser", "email": "newuser@example.com" }' "https://<quay-server.example.com>/api/v1/superuser/users/"
出力例
{"username": "newuser", "email": "newuser@example.com", "password": "123456789", "encrypted_password": "<example_encrypted_password>/JKY9pnDcsw="}
Red Hat Quay レジストリーエンドポイント (例:
quay-server.example.com
) に移動し、API 呼び出しから生成されたユーザー名とパスワードを使用してログインします。このシナリオでは、ユーザー名はnewuser
、パスワードは123456789
です。または、CLI を使用してレジストリーにログインすることもできます。以下に例を示します。$ podman login <quay-server.example.com>
出力例
username: newuser password: 123456789
オプション:
GET /api/v1/superuser/users/
エンドポイントを使用して、スーパーユーザーを含むすべてのユーザーのリストを取得できます。$ curl -X GET -H "Authorization: Bearer <bearer_token>" "https://<quay-server.example.com>/api/v1/superuser/users/"
注記GET/api/v1/superuser/users/
エンドポイントは、config.yaml
ファイルでAUTHENTICATION_TYPE: Database
が設定されている場合にのみ、ユーザーとスーパーユーザーを返します。LDAP
認証タイプでは機能しません。出力例
{"users": [{"kind": "user", "name": "quayadmin", "username": "quayadmin", "email": "quay@quay.com", "verified": true, "avatar": {"name": "quayadmin", "hash": "b28d563a6dc76b4431fc7b0524bbff6b810387dac86d9303874871839859c7cc", "color": "#17becf", "kind": "user"}, "super_user": true, "enabled": true}, {"kind": "user", "name": "newuser", "username": "newuser", "email": "newuser@example.com", "verified": true, "avatar": {"name": "newuser", "hash": "f338a2c83bfdde84abe2d3348994d70c34185a234cfbf32f9e323e3578e7e771", "color": "#9edae5", "kind": "user"}, "super_user": false, "enabled": true}]}
6.17.2. Red Hat Quay API を使用したユーザーの削除
API を使用して Red Hat Quay からユーザーを削除するには、次の手順に従います。
ユーザーを削除すると、このユーザーが自分のプライベートアカウントにあったリポジトリーはすべて使用できなくなります。
前提条件
- スーパーユーザーとして Red Hat Quay デプロイメントにログインしている。
- OAuth アクセストークンを作成 した。
-
config.yaml
ファイルでBROWSER_API_CALLS_XHR_ONLY: false
を設定している。
手順
コマンドラインから次の
DELETE /api/v1/superuser/users/{username}
コマンドを入力し、ユーザーを削除します。$ curl -X DELETE -H "Authorization: Bearer <insert token here>" https://<quay-server.example.com>/api/v1/superuser/users/<username>
CLI からユーザーを削除する場合、CLI は情報を返しません。削除を確認するには、Superuser Admin Panel → Users に移動するか、次の
GET /api/v1/superuser/users/
コマンドを入力して、Red Hat Quay UI を確認します。すると、ユーザーが存在するかどうかを確認できます。注記GET/api/v1/superuser/users/
エンドポイントは、config.yaml
ファイルでAUTHENTICATION_TYPE: Database
が設定されている場合にのみ、ユーザーとスーパーユーザーを返します。LDAP
認証タイプでは機能しません。$ curl -X GET -H "Authorization: Bearer <bearer_token>" "https://<quay-server.example.com>/api/v1/superuser/users/"
6.17.3. Red Hat Quay API を使用してスーパーユーザーとして組織を管理する
スーパーユーザーは、Red Hat Quay API を使用して組織をリスト、変更、および削除することができます。
手順
すべての組織をリストするには、
GET /api/v1/superuser/organizations
エンドポイントを使用します。$ curl -L -X GET \ -H "Authorization: Bearer <bearer_token>" \ "https://<quay_server>/api/v1/superuser/organizations?name=<organization_name>"
出力例
{"organizations": [{"name": "fed_test", "email": "fe11fc59-bd09-459a-a21c-b57692d151c9", "avatar": {"name": "fed_test", "hash": "e2ce1fb42ec2e0602362beb64b5ebd1e6ad291b710a0355f9296c16157bef3cb", "color": "#ff7f0e", "kind": "org"}, "quotas": [{"id": 3, "limit_bytes": 10737418240, "limits": []}], "quota_report": {"quota_bytes": 0, "configured_quota": 10737418240, "running_backfill": "complete", "backfill_status": "complete"}}, {"name": "test", "email": "new-contact@test-org.com", "avatar": {"name": "test", "hash": "a15d479002b20f211568fd4419e76686d2b88a4980a5b4c4bc10420776c5f6fe", "color": "#aec7e8", "kind": "org"}, "quotas": [{"id": 2, "limit_bytes": 10737418240, "limits": [{"id": 1, "type": "Reject", "limit_percent": 90}]}], "quota_report": {"quota_bytes": 0, "configured_quota": 10737418240, "running_backfill": "complete", "backfill_status": "complete"}}]}
組織の情報を変更または更新するには、
PUT /api/v1/superuser/organizations/{name}
エンドポイントを使用します。$ curl -X PUT \ -H "Authorization: Bearer <bearer_token>" \ -H "Content-Type: application/json" \ -d '{ "email": "<contact_email>", "invoice_email": <boolean_value>, "invoice_email_address": "<invoice_email_address>", "tag_expiration_s": <expiration_seconds> }' \ "https://<quay_server>/api/v1/superuser/organizations/<organization_name>"
出力例
{"name": "test", "email": "new-contact@test-org.com", "avatar": {"name": "test", "hash": "a15d479002b20f211568fd4419e76686d2b88a4980a5b4c4bc10420776c5f6fe", "color": "#aec7e8", "kind": "org"}, "quotas": [{"id": 2, "limit_bytes": 10737418240, "limits": [{"id": 1, "type": "Reject", "limit_percent": 90}]}], "quota_report": {"quota_bytes": 0, "configured_quota": 10737418240, "running_backfill": "complete", "backfill_status": "complete"}}
組織を削除するには、
DELETE /api/v1/superuser/organizations/{name}
エンドポイントを使用します。$ curl -X DELETE \ -H "Authorization: Bearer <bearer_token>" \ "https://<quay_server>/api/v1/superuser/organizations/<organization_name>"
このコマンドは CLI に出力を返しません。
6.17.4. Red Hat Quay API を使用してスーパーユーザーとしてログをリスト表示する
Red Hat Quay スーパーユーザーは、現在のシステムの使用状況ログをリストできます。
手順
現在のシステムの使用状況ログをリスト表示するには、
GET /api/v1/superuser/logs
エンドポイントを使用します。$ curl -X GET \ -H "Authorization: Bearer <bearer_token>" \ "https://<quay_server>/api/v1/superuser/logs?starttime=<start_time>&endtime=<end_time>&page=<page_number>&next_page=<next_page_token>"
出力例
{"start_time": "Mon, 17 Feb 2025 19:29:14 -0000", "end_time": "Wed, 19 Feb 2025 19:29:14 -0000", "logs": [{"kind": "login_success", "metadata": {"type": "quayauth", "useragent": "Mozilla/5.0 (X11; Linux x86_64; rv:134.0) Gecko/20100101 Firefox/134.0"}, "ip": "192.168.1.131", "datetime": "Tue, 18 Feb 2025 19:28:15 -0000", "namespace": {"kind": "user", "name": "quayadmin", "avatar": {"name": "quayadmin", "hash": "6d640d802fe23b93779b987c187a4b7a4d8fbcbd4febe7009bdff58d84498fba", "color": "#f7b6d2", "kind": "user"}}}], "next_page": "gAAAAABntN-KbPJDI0PpcHmWjRCmQTLiCprE_KXiOSidbGZ7Ireu8pVTgGUIstijNhmiLzlAv_S3HOsCrKWnuBmoQYZ3F53Uxg=="}
レジストリーのサイズに関する情報を取得するには、
GET /api/v1/superuser/registrysize/
エンドポイントを使用します。$ curl -X GET \ -H "Authorization: Bearer <bearer_token>" \ "https://<quay_server>/api/v1/superuser/registrysize/"
出力例
{"size_bytes": 0, "last_ran": null, "running": false, "queued": false}
レジストリーサイズ情報を定義するには、
POST /api/v1/superuser/registrysize/
エンドポイントを使用します。$ curl -X POST "https://quay-server.example.com/api/v1/superuser/registrysize/" \ -H "Authorization: Bearer <ACCESS_TOKEN>" \ -H "Content-Type: application/json" \ -d '{ "namespace": "<namespace>", "last_ran": 1700000000, "queued": true, "running": false }'
このコマンドは CLI に出力を返しません。
6.17.5. Red Hat Quay API を使用した組織のクォータの管理
クォータは、スーパーユーザー管理者権限を持つ Red Hat Quay API を使用して管理できます。これらのエンドポイントにより、スーパーユーザーはレジストリー内のすべての組織のクォータポリシーを管理できます。
手順
組織の割り当てポリシーを作成するには、
POST /api/v1/superuser/organization/{namespace}/quota
API エンドポイントを使用します。$ curl -X POST "https://quay-server.example.com/api/v1/superuser/organization/<namespace>/quota" \ -H "Authorization: Bearer <ACCESS_TOKEN>" \ -H "Content-Type: application/json" \ -d '{ "limit_bytes": 10737418240 }'
出力例
"Created"
GET /api/v1/superuser/organization/{namespace}/quota
API エンドポイントを使用して、クォータ ID を含むポリシーに関する情報を取得します。$ curl -X GET "https://quay-server.example.com/api/v1/superuser/organization/<namespace>/quota" \ -H "Authorization: Bearer <ACCESS_TOKEN>"
出力例
[{"id": 2, "limit_bytes": 10737418240, "limit": "10.0 GiB", "default_config": false, "limits": [{"id": 1, "type": "Reject", "limit_percent": 90}], "default_config_exists": false}]
PUT /api/v1/superuser/organization/{namespace}/quota/{quota_id}
API エンドポイントを使用して、クォータポリシーを変更します。$ curl -X PUT "https://quay-server.example.com/api/v1/superuser/organization/<namespace>/quota/<quota_id>" \ -H "Authorization: Bearer <ACCESS_TOKEN>" \ -H "Content-Type: application/json" \ -d '{ "limit_bytes": <NEW_QUOTA_LIMIT> }'
出力例
{"id": 2, "limit_bytes": 10737418240, "limit": "10.0 GiB", "default_config": false, "limits": [{"id": 1, "type": "Reject", "limit_percent": 90}], "default_config_exists": false}
DELETE/api/v1/superuser/organization/{namespace}/quota/{quota_id}
API エンドポイントを使用します。$ curl -X DELETE "https://quay-server.example.com/api/v1/superuser/organization/<namespace>/quota/<quota_id>" \ -H "Authorization: Bearer <ACCESS_TOKEN>"
このコマンドは CLI に出力を返しません。
6.17.6. Red Hat Quay API を使用したユーザークォータの管理
スーパーユーザーとして、指定された組織のユーザークォータを管理できます。
手順
POST /api/v1/superuser/users/{namespace}/quota
エンドポイントを使用して、組織内の特定のユーザーに対するクォータポリシーを作成します。$ curl -X POST "https://quay-server.example.com/api/v1/superuser/users/<username>/quota" \ -H "Authorization: Bearer <ACCESS_TOKEN>" \ -H "Content-Type: application/json" \ -d '{ "limit_bytes": <QUOTA_LIMIT> }'
出力例
"Created"
GET /api/v1/superuser/users/{namespace}/quota
エンドポイントを使用して、ユーザーに割り当てられたクォータのリストを返します。$ curl -X GET "https://quay-server.example.com/api/v1/superuser/users/<username>/quota" \ -H "Authorization: Bearer <ACCESS_TOKEN>"
出力例
[{"id": 6, "limit_bytes": 10737418240, "limit": "10.0 GiB", "default_config": false, "limits": [], "default_config_exists": false}]
PUT /api/v1/superuser/users/{namespace}/quota/{quota_id}
エンドポイントを使用して、ユーザーのポリシーを調整します。$ curl -X PUT "https://quay-server.example.com/api/v1/superuser/users/<username>/quota/<quota_id>" \ -H "Authorization: Bearer <ACCESS_TOKEN>" \ -H "Content-Type: application/json" \ -d '{ "limit_bytes": <NEW_QUOTA_LIMIT> }'
出力例
{"id": 6, "limit_bytes": 10737418240, "limit": "10.0 GiB", "default_config": false, "limits": [], "default_config_exists": false}
DELETE /api/v1/superuser/users/{namespace}/quota/{quota_id}
エンドポイントを使用して、ユーザーのポリシーを削除します。$ curl -X DELETE "https://quay-server.example.com/api/v1/superuser/users/<username>/quota/<quota_id>" \ -H "Authorization: Bearer <ACCESS_TOKEN>"
このコマンドは CLI に出力を返しません。
6.17.7. Red Hat Quay API を使用したビルド情報の取得
スーパーユーザーは、Red Hat Quay API を使用してビルドに関する情報を取得できます。
手順
GET /api/v1/superuser/{build_uuid}/build
エンドポイントを使用して、ビルドに関する情報を返します。$ curl -X GET "https://quay-server.example.com/api/v1/superuser/<build_uuid>/build" \ -H "Authorization: Bearer <ACCESS_TOKEN>"
GET /api/v1/superuser/{build_uuid}/status
API エンドポイントを使用して、ビルド uuid で指定されたビルドのステータスを返します。$ curl -X GET "https://quay-server.example.com/api/v1/superuser/<build_uuid>/status" \ -H "Authorization: Bearer <ACCESS_TOKEN>"
GET /api/v1/superuser/{build_uuid}/logs
API エンドポイントを使用して、ビルド uuid で指定されたビルドのビルドログを返します。$ curl -X GET "https://quay-server.example.com/api/v1/superuser/<build_uuid>/logs" \ -H "Authorization: Bearer <ACCESS_TOKEN>"
6.17.8. Red Hat Quay API を使用してスーパーユーザーとしてサービスキーを管理する
スーパーユーザーは、Red Hat Quay API を使用してサービスキーを作成、リスト、変更、および削除できます。
手順
POST /api/v1/superuser/keys
エンドポイントを使用して、サービスキーを作成します。$ curl -X POST \ -H "Authorization: Bearer <bearer_token>" \ -H "Content-Type: application/json" \ -d '{ "service": "<service_name>", "expiration": <unix_timestamp> }' \ "<quay_server>/api/v1/superuser/keys"
出力例
{"message":""}
POST/api/v1/superuser/approvedkeys/{kid}
エンドポイントを使用して、サービスキーを承認します。$ curl -X POST \ -H "Authorization: Bearer <bearer_token>" \ -H "Content-Type: application/json" \ -d '{ "notes": "<approval_notes>" }' \ "https://<quay_server>/api/v1/superuser/approvedkeys/<kid>"
このコマンドは CLI に出力を返しません。
GET /api/v1/superuser/keys
エンドポイントを使用して、サービスキーをリストします。$ curl -X GET \ -H "Authorization: Bearer <bearer_token>" \ "https://<quay_server>/api/v1/superuser/keys"
出力例
{"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"}]}
GET /api/v1/superuser/keys/{kid}
エンドポイントを使用して、サービスアカウントに関する情報をその子アカウント別に取得します。$ curl -X GET \ -H "Authorization: Bearer <bearer_token>" \ "https://<quay_server>/api/v1/superuser/keys/<kid>"
出力例
{"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"}
PUT /api/v1/superuser/keys/{kid}
エンドポイントを使用して、メタデータなどのサービスキーを更新します。$ curl -X PUT \ -H "Authorization: Bearer <bearer_token>" \ -H "Content-Type: application/json" \ -d '{ "name": "<service_key_name>", "metadata": {"<key>": "<value>"}, "expiration": <unix_timestamp> }' \ "https://<quay_server>/api/v1/superuser/keys/<kid>"
出力例
{"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"}
DELETE /api/v1/superuser/keys/{kid}
エンドポイントを使用して、サービスキーを削除します。$ curl -X DELETE \ -H "Authorization: Bearer <bearer_token>" \ "https://<quay_server>/api/v1/superuser/keys/<kid>"
このコマンドは CLI に出力を返しません。
6.18. Red Hat Quay API を使用したタグの管理
タグは、Red Hat Quay API を使用して変更、復元、削除、またはリストできます。
手順
PUT /api/v1/repository/{repository}/tag/{tag}
エンドポイントを使用して、タグが指すイメージを変更したり、新しいタグを作成したりします。$ curl -X PUT "https://quay-server.example.com/api/v1/repository/<namespace>/<repo_name>/tag/<tag_name>" \ -H "Authorization: Bearer <ACCESS_TOKEN>" \ -H "Content-Type: application/json" \ -d '{"manifest_digest": "<MANIFEST_DIGEST>"}'
出力例
"Updated"
POST /api/v1/repository/{repository}/tag/{tag}/restore
エンドポイントを使用しして、リポジトリータグをリポジトリー内の以前のイメージに戻します。$ curl -X POST "https://quay-server.example.com/api/v1/repository/<namespace>/<repo_name>/tag/<tag_name>/restore" \ -H "Authorization: Bearer <your_access_token>" \ -H "Content-Type: application/json" \ -d '{"manifest_digest": "sha256:<your_manifest_digest>"}'
出力例
{}
GET /api/v1/repository/{repository}/tag/
エンドポイントを使用して、リポジトリータグのリストを取得します。$ curl -X GET "https://quay-server.example.com/api/v1/repository/<namespace>/<repo_name>/tag/" \ -H "Authorization: Bearer <your_access_token>" \ -H "Content-Type: application/json"
出力例
{"tags": [{"name": "test", "reversion": true, "start_ts": 1740496373, "manifest_digest": "sha256:d08334991a3dba62307016833083d6433f489ab0f7d36d0a4771a20b4569b2f6", "is_manifest_list": false, "size": 2280303, "last_modified": "Tue, 25 Feb 2025 15:12:53 -0000"}, {"name": "test", "reversion": false, "start_ts": 1740495442, "end_ts": 1740496373, "manifest_digest": "sha256:d08334991a3dba62307016833083d6433f489ab0f7d36d0a4771a20b4569b2f6", "is_manifest_list": false, "size": 2280303, "last_modified": "Tue, 25 Feb 2025 14:57:22 -0000", "expiration": "Tue, 25 Feb 2025 15:12:53 -0000"}, {"name": "test", "reversion": false, "start_ts": 1740495408, "end_ts": 1740495442, "manifest_digest": "sha256:d08334991a3dba62307016833083d6433f489ab0f7d36d0a4771a20b4569b2f6", "is_manifest_list": false, "size": 2280303, "last_modified": "Tue, 25 Feb 2025 14:56:48 -0000", "expiration": "Tue, 25 Feb 2025 14:57:22 -0000"}], "page": 1, "has_additional": false}
DELETE /api/v1/repository/{repository}/tag/{tag}
エンドポイントを使用して、リポジトリーからタグを削除します。$ curl -X DELETE "https://quay-server.example.com/api/v1/repository/<namespace>/<repo_name>/tag/<tag_name>" \ -H "Authorization: Bearer <your_access_token>"
このコマンドは CLI に出力を返しません。
6.19. API を使用したチームの管理
チームは Red Hat Quay API を使用して管理できます。
6.19.1. API を使用したチームメンバーとリポジトリー権限の管理
チームにメンバーを追加する (直接招待またはメールによる)、またはチームからメンバーを削除するには、次の手順に従います。
前提条件
- OAuth アクセストークンを作成 した。
-
config.yaml
ファイルでBROWSER_API_CALLS_XHR_ONLY: false
を設定している。
手順
PUT /api/v1/organization/{orgname}/team/{teamname}/members/{membername}
コマンドを入力し、既存のチームにメンバーを追加または招待します。$ curl -X PUT \ -H "Authorization: Bearer <your_access_token>" \ "<quay-server.example.com>/api/v1/organization/<organization_name>/team/<team_name>/members/<member_name>"
出力例
{"name": "testuser", "kind": "user", "is_robot": false, "avatar": {"name": "testuser", "hash": "d51d17303dc3271ac3266fb332d7df919bab882bbfc7199d2017a4daac8979f0", "color": "#5254a3", "kind": "user"}, "invited": false}
DELETE /api/v1/organization/{orgname}/team/{teamname}/members/{membername}
コマンドを入力し、チームのメンバーを削除します。$ curl -X DELETE \ -H "Authorization: Bearer <your_access_token>" \ "<quay-server.example.com>/api/v1/organization/<organization_name>/team/<team_name>/members/<member_name>"
このコマンドは CLI に出力しません。メンバーが削除されたことを確認するには、
GET /api/v1/organization/{orgname}/team/{teamname}/members
コマンドを入力し、出力にメンバーが返されないことを確認します。$ curl -X GET \ -H "Authorization: Bearer <your_access_token>" \ "<quay-server.example.com>/api/v1/organization/<organization_name>/team/<team_name>/members"
出力例
{"name": "owners", "members": [{"name": "quayadmin", "kind": "user", "is_robot": false, "avatar": {"name": "quayadmin", "hash": "b28d563a6dc76b4431fc7b0524bbff6b810387dac86d9303874871839859c7cc", "color": "#17becf", "kind": "user"}, "invited": false}, {"name": "test-org+test", "kind": "user", "is_robot": true, "avatar": {"name": "test-org+test", "hash": "aa85264436fe9839e7160bf349100a9b71403a5e9ec684d5b5e9571f6c821370", "color": "#8c564b", "kind": "robot"}, "invited": false}], "can_edit": true}
PUT /api/v1/organization/{orgname}/team/{teamname}/invite/{email}
コマンドを入力し、メールアドレスでユーザーを既存のチームに招待できます。$ curl -X PUT \ -H "Authorization: Bearer <your_access_token>" \ "<quay-server.example.com>/api/v1/organization/<organization_name>/team/<team_name>/invite/<email>"
DELETE /api/v1/organization/{orgname}/team/{teamname}/invite/{email}
コマンドを入力し、チームに参加させるためのメールアドレスの招待を削除できます。以下に例を示します。$ curl -X DELETE \ -H "Authorization: Bearer <your_access_token>" \ "<quay-server.example.com>/api/v1/organization/<organization_name>/team/<team_name>/invite/<email>"
6.19.2. API を使用して組織内のチームのロールを設定する
API を使用して組織内のチームのロールを表示および設定するには、次の手順に従います。
前提条件
- OAuth アクセストークンを作成 した。
-
config.yaml
ファイルでBROWSER_API_CALLS_XHR_ONLY: false
を設定している。
手順
組織のチームのリポジトリー権限のリストを返すには、次の
GET/api/v1/organization/{orgname}/team/{teamname}/permissions
コマンドを入力します。このコマンドで情報を取得するには、チームがリポジトリーに追加されている必要があることに注意してください。$ curl -X GET \ -H "Authorization: Bearer <your_access_token>" \ "<quay-server.example.com>/api/v1/organization/<organization_name>/team/<team_name>/permissions"
出力例
{"permissions": [{"repository": {"name": "api-repo", "is_public": true}, "role": "admin"}]}
PUT/api/v1/organization/{orgname}/team/{teamname}
コマンドを使用して、組織内のチームを作成または更新し、指定されたロールを admin、member、または creator にすることができます。以下に例を示します。$ curl -X PUT \ -H "Authorization: Bearer <your_access_token>" \ -H "Content-Type: application/json" \ -d '{ "role": "<role>" }' \ "<quay-server.example.com>/api/v1/organization/<organization_name>/team/<team_name>"
出力例
{"name": "testteam", "description": "", "can_view": true, "role": "creator", "avatar": {"name": "testteam", "hash": "827f8c5762148d7e85402495b126e0a18b9b168170416ed04b49aae551099dc8", "color": "#ff7f0e", "kind": "team"}, "new_team": false}
6.19.3. API を使用した組織内のチームの削除
API を使用して組織内のチームを削除するには、次の手順に従います。
前提条件
- OAuth アクセストークンを作成 した。
-
config.yaml
ファイルでBROWSER_API_CALLS_XHR_ONLY: false
を設定している。
手順
DELETE /api/v1/organization/{orgname}/team/{teamname}
コマンドを入力すると、組織内のチームを削除できます。$ curl -X DELETE \ -H "Authorization: Bearer <your_access_token>" \ "<quay-server.example.com>/api/v1/organization/<organization_name>/team/<team_name>"
このコマンドは CLI に出力を返しません。
6.20. Red Hat Quay API を使用したビルドの管理
ビルドは Red Hat Quay API を使用して管理できます。
手順
GET /api/v1/repository/{repository}/trigger/
エンドポイントを使用して、指定したリポジトリーのトリガーをリストします。$ curl -X GET "https://quay-server.example.com/api/v1/repository/example_namespace/example_repo/trigger/" \ -H "Authorization: Bearer <your_access_token>"
出力例
{"triggers": [{"id": "32ca5eae-a29f-46c7-8f44-3221ca417c92", "service": "custom-git", "is_active": false, "build_source": null, "repository_url": null, "config": {}, "can_invoke": true, "enabled": true, "disabled_reason": null}]}
POST /api/v1/repository/{repository}/trigger/{trigger_uuid}/activate
エンドポイントを使用して、指定されたビルドトリガーをアクティブ化します。$ curl -X POST "https://quay-server.example.com/api/v1/repository/example_namespace/example_repo/trigger/example-trigger-uuid/activate" \ -H "Authorization: Bearer <your_access_token>" \ -H "Content-Type: application/json" \ -d '{ "config": { "branch": "main" }, "pull_robot": "example+robot" }'
POST /api/v1/repository/{repository}/trigger/{trigger_uuid}/start
エンドポイントを使用して、指定されたトリガーからビルドを手動で開始します。$ curl -X POST "https://quay-server.example.com/api/v1/repository/example_namespace/example_repo/trigger/example-trigger-uuid/start" \ -H "Authorization: Bearer <your_access_token>" \ -H "Content-Type: application/json" \ -d '{ "branch_name": "main", "commit_sha": "abcdef1234567890", "refs": "refs/heads/main" }'
GET /api/v1/repository/{repository}/trigger/{trigger_uuid}/builds
エンドポイントを使用して、指定したトリガーが開始したビルドをリストします。$ curl -X GET "https://quay-server.example.com/api/v1/repository/example_namespace/example_repo/trigger/example-trigger-uuid/builds?limit=10" \ -H "Authorization: Bearer <your_access_token>"
GET /api/v1/repository/{repository}/trigger/{trigger_uuid}
エンドポイントを使用して、指定したビルドトリガーの情報を取得します。$ curl -X GET "https://quay-server.example.com/api/v1/repository/example_namespace/example_repo/trigger/example-trigger-uuid" \ -H "Authorization: Bearer <your_access_token>"
PUT /api/v1/repository/{repository}/trigger/{trigger_uuid}
エンドポイントを使用して、指定したビルドトリガーを更新します。$ curl -X PUT "https://quay-server.example.com/api/v1/repository/example_namespace/example_repo/trigger/example-trigger-uuid" \ -H "Authorization: Bearer <your_access_token>" \ -H "Content-Type: application/json" \ -d '{"enabled": true}'
DELETE /api/v1/repository/{repository}/trigger/{trigger_uuid}
エンドポイントを使用して、指定したビルドトリガーを削除します。$ curl -X DELETE "https://quay-server.example.com/api/v1/repository/example_namespace/example_repo/trigger/example-trigger-uuid" \ -H "Authorization: Bearer <your_access_token>"
6.21. Red Hat Quay API を使用して現在のユーザーオプションを管理する
リポジトリーにスターを付けたり、アカウントに関する情報を取得したりするなどの一部のユーザーオプションは、Red Hat Quay API で利用できます。
手順
GET /api/v1/user/
エンドポイントを使用して、認証されたユーザーのユーザー情報を取得します。$ curl -X GET "https://quay-server.example.com/api/v1/user/" \ -H "Authorization: Bearer <your_access_token>"
出力例
{"anonymous": false, "username": "quayadmin", "avatar": {"name": "quayadmin", "hash": "6d640d802fe23b93779b987c187a4b7a4d8fbcbd4febe7009bdff58d84498fba", "color": "#f7b6d2", "kind": "user"}, "can_create_repo": true, "is_me": true, "verified": true, "email": "test@gmil.com", "logins": [], "invoice_email": false, "invoice_email_address": null, "preferred_namespace": false, "tag_expiration_s": 1209600, "prompts": [], "company": null, "family_name": null, "given_name": null, "location": null, "is_free_account": true, "has_password_set": true, "quotas": [{"id": 4, "limit_bytes": 2199023255552, "limits": [{"id": 3, "type": "Reject", "limit_percent": 100}]}], "quota_report": {"quota_bytes": 2280675, "configured_quota": 2199023255552, "running_backfill": "complete", "backfill_status": "complete"}, "organizations": [{"name": "test", "avatar": {"name": "test", "hash": "a15d479002b20f211568fd4419e76686d2b88a4980a5b4c4bc10420776c5f6fe", "color": "#aec7e8", "kind": "org"}, "can_create_repo": true, "public": false, "is_org_admin": true, "preferred_namespace": false}, {"name": "sample", "avatar": {"name": "sample", "hash": "ba560c68f1d26e8c6b911ac9b5d10d513e7e43e576cc2baece1b8a46f36a29a5", "color": "#b5cf6b", "kind": "org"}, "can_create_repo": true, "public": false, "is_org_admin": true, "preferred_namespace": false}], "super_user": true}
GET /api/v1/users/{username}
エンドポイントを使用して、指定されたユーザーのユーザー情報を取得します。$ curl -X GET "https://quay-server.example.com/api/v1/users/example_user" \ -H "Authorization: Bearer <your_access_token>"
出力例
{"anonymous": false, "username": "testuser", "avatar": {"name": "testuser", "hash": "f660ab912ec121d1b1e928a0bb4bc61b15f5ad44d5efdc4e1c92a25e99b8e44a", "color": "#6b6ecf", "kind": "user"}, "super_user": false}
POST /api/v1/user/starred
エンドポイントを使用して、リポジトリーにスターを付けます。$ curl -X POST "https://quay-server.example.com/api/v1/user/starred" \ -H "Authorization: Bearer <your_access_token>" \ -H "Content-Type: application/json" \ -d '{ "namespace": "<namespace>", "repository": "<repository_name>" }'
出力例
{"namespace": "test", "repository": "testrepo"}
GET /api/v1/user/starred
エンドポイントを使用して、スター付きリポジトリーをすべてリストします。$ curl -X GET "https://quay-server.example.com/api/v1/user/starred?next_page=<next_page_token>" \ -H "Authorization: Bearer <your_access_token>"
出力例
{"repositories": [{"namespace": "test", "name": "testrepo", "description": "This repository is now under maintenance.", "is_public": true}]}
DELETE /api/v1/user/starred/{repository}
エンドポイントを使用して、リポジトリーからスターを削除します。$ curl -X DELETE "https://quay-server.example.com/api/v1/user/starred/namespace/repository-name" \ -H "Authorization: Bearer <your_access_token>"
このコマンドは CLI に出力を返しません。