7.5. 使用 API 调整存储库的访问设置
使用以下步骤,通过使用 API 调整存储库的用户或机器人帐户的访问设置。
先决条件
- 您已创建了用户帐户或机器人帐户。
- 您已创建了 OAuth 访问令牌。
流程
输入以下
PUT /api/v1/repository/{repository}/permissions/user/{username}
命令更改用户权限:curl -X PUT \ -H "Authorization: Bearer <bearer_token>" \ -H "Content-Type: application/json" \ -d '{"role": "admin"}' \ https://<quay-server.example.com>/api/v1/repository/<namespace>/<repository>/permissions/user/<username>
$ curl -X PUT \ -H "Authorization: Bearer <bearer_token>" \ -H "Content-Type: application/json" \ -d '{"role": "admin"}' \ https://<quay-server.example.com>/api/v1/repository/<namespace>/<repository>/permissions/user/<username>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 输出示例
{"role": "admin", "name": "quayadmin+test", "is_robot": true, "avatar": {"name": "quayadmin+test", "hash": "ca9afae0a9d3ca322fc8a7a866e8476dd6c98de543decd186ae090e420a88feb", "color": "#8c564b", "kind": "robot"}}
{"role": "admin", "name": "quayadmin+test", "is_robot": true, "avatar": {"name": "quayadmin+test", "hash": "ca9afae0a9d3ca322fc8a7a866e8476dd6c98de543decd186ae090e420a88feb", "color": "#8c564b", "kind": "robot"}}
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 要删除当前权限,您可以输入
DELETE /api/v1/repository/{repository}/permissions/user/{username}
命令:curl -X DELETE \ -H "Authorization: Bearer <bearer_token>" \ -H "Accept: application/json" \ https://<quay-server.example.com>/api/v1/repository/<namespace>/<repository>/permissions/user/<username>
$ curl -X DELETE \ -H "Authorization: Bearer <bearer_token>" \ -H "Accept: application/json" \ https://<quay-server.example.com>/api/v1/repository/<namespace>/<repository>/permissions/user/<username>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 此命令不会返回 CLI 中的任何输出。反之,您可以通过输入
GET /api/v1/repository/{repository}/permissions/user/
命令来检查权限是否已删除:curl -X GET \ -H "Authorization: Bearer <bearer_token>" \ -H "Accept: application/json" \ https://<quay-server.example.com>/api/v1/repository/<namespace>/<repository>/permissions/user/<username>/
$ curl -X GET \ -H "Authorization: Bearer <bearer_token>" \ -H "Accept: application/json" \ https://<quay-server.example.com>/api/v1/repository/<namespace>/<repository>/permissions/user/<username>/
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 输出示例
{"message":"User does not have permission for repo."}
{"message":"User does not have permission for repo."}
Copy to Clipboard Copied! Toggle word wrap Toggle overflow