6.21. 使用 Red Hat Quay API 管理当前用户选项


Red Hat Quay API 提供了一些用户选项,如星级存储库或获取您的帐户信息。

流程

  1. 使用 GET /api/v1/user/ 端点获取经过身份验证的用户的用户信息。

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

    输出示例

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

  2. 使用 GET /api/v1/users/{username} 端点获取指定用户的用户信息。

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

    输出示例

    {"anonymous": false, "username": "testuser", "avatar": {"name": "testuser", "hash": "f660ab912ec121d1b1e928a0bb4bc61b15f5ad44d5efdc4e1c92a25e99b8e44a", "color": "#6b6ecf", "kind": "user"}, "super_user": false}
    Copy to Clipboard Toggle word wrap

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

    输出示例

    {"namespace": "test", "repository": "testrepo"}
    Copy to Clipboard Toggle word wrap

  4. 使用 GET /api/v1/user/starred 端点列出所有 starred 存储库:

    $ curl -X GET "https://quay-server.example.com/api/v1/user/starred?next_page=<next_page_token>" \
      -H "Authorization: Bearer <your_access_token>"
    Copy to Clipboard Toggle word wrap

    输出示例

    {"repositories": [{"namespace": "test", "name": "testrepo", "description": "This repository is now under maintenance.", "is_public": true}]}
    Copy to Clipboard Toggle word wrap

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

    此命令不会在 CLI 中返回输出。

返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

Theme

© 2025 Red Hat