検索

10.3. API を使用した通知の作成

download PDF

通知を追加するには、次の手順を実行します。

前提条件

  • リポジトリーが作成済みである。
  • リポジトリーの管理者権限がある。
  • OAuth アクセストークンを作成 した。
  • config.yaml ファイルで BROWSER_API_CALLS_XHR_ONLY: false を設定した。

手順

  1. 次の 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}
  2. 次の 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

    出力例

    {}

  3. 次の 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>
  4. リポジトリー通知を削除するには、次の 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/{uuid} コマンドを入力すると、すべての通知のリストを取得できます。

    $ 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": []}

Red Hat logoGithubRedditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

Red Hat ドキュメントについて

Red Hat をお使いのお客様が、信頼できるコンテンツが含まれている製品やサービスを活用することで、イノベーションを行い、目標を達成できるようにします。

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

© 2024 Red Hat, Inc.