11.3. 使用 API 创建通知
使用以下步骤添加通知。
先决条件
- 您已创建了一个存储库。
- 您有对该存储库的管理特权。
- 您已创建了 OAuth 访问令牌。
流程
输入以下
POST /api/v1/repository/{repository}/notification
命令在存储库上创建通知:Copy to Clipboard Copied! Toggle word wrap Toggle overflow 此命令不会在 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}
{"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}
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 您可以通过输入以下
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
$ curl -X POST \ -H "Authorization: Bearer <bearer_token>" \ https://<quay-server.example.com>/api/v1/repository/<repository>/notification/<uuid>/test
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 输出示例
{}
{}
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 您可以通过输入以下
POST /api/v1/repository/{repository}/notification/{uuid}
命令重置存储库通知失败:curl -X POST \ -H "Authorization: Bearer <bearer_token>" \ https://<quay-server.example.com>/api/v1/repository/<repository>/notification/<uuid>
$ curl -X POST \ -H "Authorization: Bearer <bearer_token>" \ https://<quay-server.example.com>/api/v1/repository/<repository>/notification/<uuid>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 输入以下
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>
$ curl -X DELETE \ -H "Authorization: Bearer <bearer_token>" \ https://<quay-server.example.com>/api/v1/repository/<namespace>/<repository_name>/notification/<uuid>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 此命令不会在 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
$ curl -X GET -H "Authorization: Bearer <bearer_token>" -H "Accept: application/json" https://<quay-server.example.com>/api/v1/repository/<namespace>/<repository_name>/notification
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 输出示例
{"notifications": []}
{"notifications": []}
Copy to Clipboard Copied! Toggle word wrap Toggle overflow