6.10. 使用 Red Hat Quay API 建立配额


组织可以通过 API 端点创建和管理。使用 Red Hat Quay API,您可以创建机构、查看机构信息、为机构创建代理缓存,编辑具有机构访问权限的用户、更改机构详情、删除机构等。

6.10.1. 使用 Red Hat Quay API 创建机构

使用以下步骤使用 Red Hat Quay API 创建新机构。

先决条件

流程

  1. 输入以下命令使用 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/"
    Copy to Clipboard Toggle word wrap

    输出示例

    "Created"
    Copy to Clipboard Toggle word wrap
  2. 创建后,可以更改机构详情,如添加电子邮件地址,带有 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>"
          }'
    Copy to Clipboard Toggle word wrap

    输出示例

    {"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"}}
    Copy to Clipboard Toggle word wrap

6.10.2. 使用 Red Hat Quay API 删除机构

使用以下步骤使用 Red Hat Quay API 删除机构。

先决条件

流程

  1. 输入以下命令使用 DELETE /api/v1/organization/{orgname} 端点删除机构:

    $ curl -X DELETE \
      -H "Authorization: Bearer <bearer_token>" \
      "https://<quay-server.example.com>/api/v1/organization/<organization_name>"
    Copy to Clipboard Toggle word wrap
  2. 从 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>"
    Copy to Clipboard Toggle word wrap

    输出示例

    {"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}
    Copy to Clipboard Toggle word wrap

6.10.3. 使用 API 检索机构成员信息

有关机构成员的信息可以通过 Red Hat Quay API 检索。

流程

  1. 使用 GET /api/v1/organization/{orgname}/members 返回机构成员列表:

    $ curl -X GET "https://<quay-server.example.com>/api/v1/organization/<orgname>/members" \
      -H "Authorization: Bearer <access_token>"
    Copy to Clipboard Toggle word wrap

    输出示例

    {"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": []}]}
    Copy to Clipboard Toggle word wrap

  2. 您可以使用 GET /api/v1/organization/{orgname}/collaborators 返回机构 collaborators 列表:

    $ curl -X GET "https://<quay-server.example.com>/api/v1/organization/{orgname}/collaborators" \
      -H "Authorization: Bearer <access_token>"
    Copy to Clipboard Toggle word wrap

    输出示例

    {"collaborators": [user-test]}
    Copy to Clipboard Toggle word wrap

  3. 使用 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>"
    Copy to Clipboard Toggle word wrap

    输出示例

    {"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"]}
    Copy to Clipboard Toggle word wrap

  4. 使用 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>"
    Copy to Clipboard Toggle word wrap

    此命令不返回输出。

6.10.4. 使用 Red Hat Quay API 创建机构应用程序

可以使用 Red Hat Quay UI 创建机构应用程序。

注意

可以使用 UI 创建机构应用,但必须在 UI 上创建 OAuth 2 访问令牌。

流程

  1. 使用 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>"
          }'
    Copy to Clipboard Toggle word wrap

    输出示例

    {"name": "new-application", "description": "", "application_uri": "", "client_id": "E6GJSHOZMFBVNHTHNB53", "client_secret": "SANSWCWSGLVAUQ60L4Q4CEO3C1QAYGEXZK2VKJNI", "redirect_uri": "", "avatar_email": null}
    Copy to Clipboard Toggle word wrap

  2. 使用 GET /api/v1/organization/{orgname}/applications 端点返回所有机构应用程序的列表。例如:

    $ curl -X GET "https://<quay-server.example.com>/api/v1/organization/<orgname>/applications" \
      -H "Authorization: Bearer <access_token>"
    Copy to Clipboard Toggle word wrap

    输出示例

    {"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}]}
    Copy to Clipboard Toggle word wrap

    也可以使用 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>"
    Copy to Clipboard Toggle word wrap

    输出示例

    {"name": "test", "description": "", "application_uri": "", "client_id": "MCJ61D8KQBFS2DXM56S2", "client_secret": "J5G7CCX5QCA8Q5XZLWGI7USJPSM4M5MQHJED46CF", "redirect_uri": "", "avatar_email": null}
    Copy to Clipboard Toggle word wrap

  3. 创建后,可以使用 PUT /api/v1/organization/{orgname}/applications/{client_id} 端点更新机构应用程序,例如,添加重定向 URI 或新描述:

    $ 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"
          }'
    Copy to Clipboard Toggle word wrap
  4. 创建后,可以使用 GET /api/v1/app/{client_id} 端点返回应用程序信息:

    $ curl -X GET "https://<quay-server.example.com>/api/v1/app/<client_id>" \
      -H "Authorization: Bearer <access_token>"
    Copy to Clipboard Toggle word wrap

    输出示例

    {"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"}}}
    Copy to Clipboard Toggle word wrap

  5. 可以使用 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>"
    Copy to Clipboard Toggle word wrap

    此命令不返回输出。

6.10.5. 使用 Red Hat Quay API 为机构配置代理缓存

可以使用 Red Hat Quay API 配置机构的代理缓存。

流程

  1. 使用 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>"
          }'
    Copy to Clipboard Toggle word wrap
  2. 使用 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>"
          }'
    Copy to Clipboard Toggle word wrap
  3. 使用 GET /api/v1/organization/{orgname}/proxycache 端点获取有关 proxcy 缓存的信息。例如:

    $ curl -X GET "https://<quay-server.example.com>/api/v1/organization/{orgname}/proxycache" \
      -H "Authorization: Bearer <access_token>"
    Copy to Clipboard Toggle word wrap

    输出示例

    {"upstream_registry": "quay.io", "expiration_s": 86400, "insecure": false}
    Copy to Clipboard Toggle word wrap

  4. 使用 DELETE /api/v1/organization/{orgname}/proxycache 端点

    $ curl -X DELETE "https://<quay-server.example.com>/api/v1/organization/{orgname}/proxycache" \
      -H "Authorization: Bearer <access_token>"
    Copy to Clipboard Toggle word wrap

    输出示例

    "Deleted"
    Copy to Clipboard Toggle word wrap

返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat