Webhook
=======

get\_\ *webhook*
----------------

**コードサンプル**

.. code:: shell


   #  You can also use wget

   curl -X GET https://PEM-SERVER-IP/pem/api/v17/webhook/ \
     -H Accept: application/json \
     -H X-Auth-Token: string

.. code:: python

   import requests
   headers = {
     Accept: application/json,
     X-Auth-Token: string
   }

   r = requests.get(https://PEM-SERVER-IP/pem/api/v17/webhook/, headers = headers)

   print(r.json())

.. code:: javascript

   const headers = {
     Accept: "application/json",
     "X-Auth-Token": "string",
   };

   fetch("https://PEM-SERVER-IP/pem/api/v17/webhook/", {
     method: "GET",

     headers: headers,
   })
     .then(function (res) {
       return res.json();
     })
     .then(function (body) {
       console.log(body);
     });

``GET /webhook/``

*Webhookリストを取得します。*

Webhookのリストを返します。 ``name`` 完全一致または\ ``name_contains``
部分文字列検索クエリパラメーターを介してオプションの名前ベースのフィルタリングをサポートします。

パラメーター
^^^^^^^^^^^^

.. csv-table::
  :header: Name,In,Type,Required,Description
  :widths: 11,7,7,7,17
  :align: left
  :class: longtable

  X-Auth-Token,header,string,true,承認トークン
  name,query,string,false,完全な名前の一致大文字と小文字を区別してWebhookをフィルタリングします。 name_containsと相互排他的。
  name_contains,query,string,false,部分文字列の一致大文字と小文字を区別してWebhookをフィルタリングします。 nameと相互排他的。

**応答例**

.. raw:: html

   <Details summary="200 Response">

.. code:: json

   [
     {
       "id": 0,
       "name": "string",
       "url": "string",
       "enabled": true,
       "method": "POST",
       "http_headers": [
         {
           "http_header_id": 0,
           "http_header_key": "string",
           "http_header_value": "string"
         }
       ],
       "payload_template": "{text: You have new alert from PEM, attachments: [{text: AlertID \n%AlertID% \nAlertName \n%AlertName%}]}",
       "low_alert": true,
       "med_alert": true,
       "high_alert": true,
       "cleared_alert": true,
       "payload_type": "ALERT"
     }
   ]

.. raw:: html

   </Details>

応答
^^^^

.. csv-table::
  :header: Status,Meaning,Description,Schema
  :widths: 15,12,12,20
  :align: left
  :class: longtable

  200,:ref:`コマンドラインからのサーバーインストーラーの呼び出し<コマンドラインからのサーバーインストーラーの呼び出し>` ,ステータス200,Inline
  400, `Bad Request <https://tools.ietf.org/html/rfc7231#section-6.5.1>`__ ,相互排他性違反 `name`または類似の完全一致フィルタと`name_contains`または類似の部分文字列フィルタが両方とも同じ要求で指定されました。フィルタリングは、ペアのうちの1つのみを受け入れます。,Inline

レスポンススキーマ
^^^^^^^^^^^^^^^^^^

ステータスコード **200**

.. csv-table::
  :header: Name,Type,Required,Restrictions,Description
  :widths: 11,7,7,7,17
  :align: left
  :class: longtable

  _anonymous_,\ :ref:`Platform Compatibility <Schemas>` ],false,none,なし
  » id,integer,false,none,Webhook ID
  » name,string,false,none,Webhook名
  » url,string,false,none,Webhook URL
  » enabled,boolean,false,none,Webhookが有効になっているかどうかを判断します。
  » method,string,false,none,リクエストメソッド
  » http_headers,\ :ref:`Platform Compatibility <Schemas>` ],false,none,Webhookで使用されるHTTPヘッダーのキー/値ペアのリスト
  »» http_header_id,integer,false,none,HTTPヘッダーのID
  »» http_header_key,string,false,none,HTTPヘッダーキーの名前
  »» http_header_value,string,false,none,HTTPヘッダーキーの名前
  » payload_template,string,false,none,ペイロードテンプレート。以下は、Slackのペイロードの例です。
  » low_alert,boolean,false,none,低アラートを有効にするかどうかを決定します。
  » med_alert,boolean,false,none,中程度のアラートを有効にするかどうかを決定します。
  » high_alert,boolean,false,none,厳重なアラートを有効にするかどうかを決定します。
  » cleared_alert,boolean,false,none,クリアされたアラートが有効かどうかを判断します。
  » payload_type,string,false,none,ペイロードタイプ

列挙値
''''''

.. csv-table::
  :header: Property,Value
  :widths: 25,25
  :align: left
  :class: longtable

  method,POST
  method,PUT
  payload_type,ALERT
  payload_type,JOB

ステータスコード **400**

.. csv-table::
  :header: Name,Type,Required,Restrictions,Description
  :widths: 11,7,7,7,17
  :align: left
  :class: longtable

  » success,integer,false,none,なし
  » errormsg,string,false,none,なし

..  Note::
   この操作には認証が必要ありません

post\_\ *webhook*
-----------------

**コードサンプル**

.. code:: shell


   #  You can also use wget

   curl -X POST https://PEM-SERVER-IP/pem/api/v17/webhook/ \
     -H Content-Type: application/json \
     -H X-Auth-Token: string

.. code:: python

   import requests
   headers = {
     Content-Type: application/json,
     X-Auth-Token: string
   }

   r = requests.post(https://PEM-SERVER-IP/pem/api/v17/webhook/, headers = headers)

   print(r.json())

.. code:: javascript

   const inputBody = {
     "name": "string",
     "url": "string",
     "enabled": true,
     "method": "POST",
     "http_headers": [
       {
         "http_header_key": "string",
         "http_header_value": "string"
       }
     ],
     "payload_template": "{ Alert Name:%AlertName%,type:Webhook }",
     "low_alert": true,
     "med_alert": true,
     "high_alert": true,
     "cleared_alert": true,
     "payload_type": "ALERT"
   };
   const headers = {
     Content-Type:application/json,
     X-Auth-Token:string
   };

   fetch(https://PEM-SERVER-IP/pem/api/v17/webhook/,
   {
     method: POST,
     body: inputBody,
     headers: headers
   })
   .then(function(res) {
       return res.json();
   }).then(function(body) {
       console.log(body);
   });

``POST /webhook/``

*新しいWebhookを追加します。*

**ボディパラメーター**

.. code:: json

   {
     "name": "string",
     "url": "string",
     "enabled": true,
     "method": "POST",
     "http_headers": [
       {
         "http_header_key": "string",
         "http_header_value": "string"
       }
     ],
     "payload_template": "{ Alert Name:%AlertName%,type:Webhook }",
     "low_alert": true,
     "med_alert": true,
     "high_alert": true,
     "cleared_alert": true,
     "payload_type": "ALERT"
   }

.. _パラメーター-1:

パラメーター
^^^^^^^^^^^^

.. csv-table::
  :header: Name,In,Type,Required,Description
  :widths: 11,7,7,7,17
  :align: left
  :class: longtable

  X-Auth-Token,header,string,true,承認トークン
  body,body,:ref:`WebhookPostData<WebhookPostData>` ,true,なし

**応答例**

.. _応答-1:

応答
^^^^

.. csv-table::
  :header: Status,Meaning,Description,Schema
  :widths: 15,12,12,20
  :align: left
  :class: longtable

  200,:ref:`コマンドラインからのサーバーインストーラーの呼び出し<コマンドラインからのサーバーインストーラーの呼び出し>` ,Webhookが正常に作成されました。,None

.. _レスポンススキーマ-1:

レスポンススキーマ
^^^^^^^^^^^^^^^^^^

..  Note::
   この操作には認証が必要ありません

get\_\ *webhook*\ {webhook_id}
------------------------------

**コードサンプル**

.. code:: shell


   #  You can also use wget

   curl -X GET https://PEM-SERVER-IP/pem/api/v17/webhook/{webhook_id} \
     -H Accept: application/json \
     -H X-Auth-Token: string

.. code:: python

   import requests
   headers = {
     Accept: application/json,
     X-Auth-Token: string
   }

   r = requests.get(https://PEM-SERVER-IP/pem/api/v17/webhook/{webhook_id}, headers = headers)

   print(r.json())

.. code:: javascript

   const headers = {
     Accept: "application/json",
     "X-Auth-Token": "string",
   };

   fetch("https://PEM-SERVER-IP/pem/api/v17/webhook/{webhook_id}", {
     method: "GET",

     headers: headers,
   })
     .then(function (res) {
       return res.json();
     })
     .then(function (body) {
       console.log(body);
     });

``GET /webhook/{webhook_id}``

*webhook_idで識別されるWebhookの情報を取得します。*

.. _パラメーター-2:

パラメーター
^^^^^^^^^^^^

.. csv-table::
  :header: Name,In,Type,Required,Description
  :widths: 11,7,7,7,17
  :align: left
  :class: longtable

  webhook_id,path,string,true,なし
  X-Auth-Token,header,string,true,承認トークン

**応答例**

.. raw:: html

   <Details summary="200 Response">

.. code:: json

   {
     "id": 0,
     "name": "string",
     "url": "string",
     "enabled": true,
     "method": "POST",
     "http_headers": [
       {
         "http_header_id": 0,
         "http_header_key": "string",
         "http_header_value": "string"
       }
     ],
     "payload_template": "{text: You have new alert from PEM, attachments: [{text: AlertID \n%AlertID% \nAlertName \n%AlertName%}]}",
     "low_alert": true,
     "med_alert": true,
     "high_alert": true,
     "cleared_alert": true,
     "payload_type": "ALERT"
   }

.. raw:: html

   </Details>

.. _応答-2:

応答
^^^^

.. csv-table::
  :header: Status,Meaning,Description,Schema
  :widths: 15,12,12,20
  :align: left
  :class: longtable

  200,:ref:`コマンドラインからのサーバーインストーラーの呼び出し<コマンドラインからのサーバーインストーラーの呼び出し>` ,ステータス200,:ref:`Webhooks<Webhooks>` 

..  Note::
   この操作には認証が必要ありません

put\_\ *webhook*\ {webhook_id}
------------------------------

**コードサンプル**

.. code:: shell


   #  You can also use wget

   curl -X PUT https://PEM-SERVER-IP/pem/api/v17/webhook/{webhook_id} \
     -H Content-Type: application/json \
     -H X-Auth-Token: string

.. code:: python

   import requests
   headers = {
     Content-Type: application/json,
     X-Auth-Token: string
   }

   r = requests.put(https://PEM-SERVER-IP/pem/api/v17/webhook/{webhook_id}, headers = headers)

   print(r.json())

.. code:: javascript

   const inputBody = {
     "name": "string",
     "url": "string",
     "enabled": true,
     "method": "POST",
     "http_headers": {
       "added": [
         {
           "http_header_key": "string",
           "http_header_value": "string"
         }
       ],
       "changed": [
         {
           "http_header_id": 0,
           "http_header_key": "string",
           "http_header_value": "string"
         }
       ],
       "deleted": [
         {
           "http_header_id": 0
         }
       ],
       "payload_type": "ALERT"
     },
     "payload_template": "{text: You have new alert from PEM, attachments: [{text: AlertID \n%AlertID% \nAlertName \n%AlertName%}]}",
     "low_alert": true,
     "med_alert": true,
     "high_alert": true,
     "cleared_alert": true
   };
   const headers = {
     Content-Type:application/json,
     X-Auth-Token:string
   };

   fetch(https://PEM-SERVER-IP/pem/api/v17/webhook/{webhook_id},
   {
     method: PUT,
     body: inputBody,
     headers: headers
   })
   .then(function(res) {
       return res.json();
   }).then(function(body) {
       console.log(body);
   });

``PUT /webhook/{webhook_id}``

*Webhook情報を更新します。*

**ボディパラメーター**

.. code:: json

   {
     "name": "string",
     "url": "string",
     "enabled": true,
     "method": "POST",
     "http_headers": {
       "added": [
         {
           "http_header_key": "string",
           "http_header_value": "string"
         }
       ],
       "changed": [
         {
           "http_header_id": 0,
           "http_header_key": "string",
           "http_header_value": "string"
         }
       ],
       "deleted": [
         {
           "http_header_id": 0
         }
       ],
       "payload_type": "ALERT"
     },
     "payload_template": "{text: You have new alert from PEM, attachments: [{text: AlertID \n%AlertID% \nAlertName \n%AlertName%}]}",
     "low_alert": true,
     "med_alert": true,
     "high_alert": true,
     "cleared_alert": true
   }

.. _パラメーター-3:

パラメーター
^^^^^^^^^^^^

.. csv-table::
  :header: Name,In,Type,Required,Description
  :widths: 11,7,7,7,17
  :align: left
  :class: longtable

  webhook_id,path,string,true,なし
  X-Auth-Token,header,string,true,承認トークン
  body,body,:ref:`WebhookPutData<WebhookPutData>` ,true,なし

**応答例**

.. _応答-3:

応答
^^^^

.. csv-table::
  :header: Status,Meaning,Description,Schema
  :widths: 15,12,12,20
  :align: left
  :class: longtable

  200,:ref:`コマンドラインからのサーバーインストーラーの呼び出し<コマンドラインからのサーバーインストーラーの呼び出し>` ,Webhookが正常に更新されました。,None

.. _レスポンススキーマ-2:

レスポンススキーマ
^^^^^^^^^^^^^^^^^^

..  Note::
   この操作には認証が必要ありません

delete\_\ *webhook*\ {webhook_id}
---------------------------------

**コードサンプル**

.. code:: shell


   #  You can also use wget

   curl -X DELETE https://PEM-SERVER-IP/pem/api/v17/webhook/{webhook_id} \
     -H X-Auth-Token: string

.. code:: python

   import requests
   headers = {
     X-Auth-Token: string
   }

   r = requests.delete(https://PEM-SERVER-IP/pem/api/v17/webhook/{webhook_id}, headers = headers)

   print(r.json())

.. code:: javascript

   const headers = {
     "X-Auth-Token": "string",
   };

   fetch("https://PEM-SERVER-IP/pem/api/v17/webhook/{webhook_id}", {
     method: "DELETE",

     headers: headers,
   })
     .then(function (res) {
       return res.json();
     })
     .then(function (body) {
       console.log(body);
     });

``DELETE /webhook/{webhook_id}``

*Webhookを削除します。*

.. _パラメーター-4:

パラメーター
^^^^^^^^^^^^

.. csv-table::
  :header: Name,In,Type,Required,Description
  :widths: 11,7,7,7,17
  :align: left
  :class: longtable

  webhook_id,path,string,true,なし
  X-Auth-Token,header,string,true,承認トークン

**応答例**

.. _応答-4:

応答
^^^^

.. csv-table::
  :header: Status,Meaning,Description,Schema
  :widths: 15,12,12,20
  :align: left
  :class: longtable

  200,:ref:`コマンドラインからのサーバーインストーラーの呼び出し<コマンドラインからのサーバーインストーラーの呼び出し>` ,Webhookは正常に削除されました,None

.. _レスポンススキーマ-3:

レスポンススキーマ
^^^^^^^^^^^^^^^^^^

..  Note::
   この操作には認証が必要ありません
