Webhook
=======

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

**Code samples**

.. code:: shell


   #  You can also use wget

   curl -X GET https://PEM-SERVER-IP/api/v14/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/api/v14/webhook/, headers = headers)

   print(r.json())

.. code:: javascript


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

   fetch(https://PEM-SERVER-IP/api/v14/webhook/,
   {
     method: GET,

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

``GET /webhook/``

- Retrieve the webhook list.\*

Parameters
^^^^^^^^^^

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

  X-Auth-Token,header,string,true,Token of authorization

**Example responses**

.. 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>

Responses
^^^^^^^^^

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

  200,:ref:`Invoking the server installer from the command line<Invoking the server installer from the command line>` ,Status 200,Inline

Response Schema
^^^^^^^^^^^^^^^

Status Code **200**

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

  *anonymous*,\ :ref:`Query information <Schemas>` ],false,none,none
  » id,integer,false,none,Webhook ID
  » name,string,false,none,Webhook name
  » url,string,false,none,Webhook URL
  » enabled,boolean,false,none,Determines whether the webhook is enabled.
  » method,string,false,none,Request method
  » http_headers,\ :ref:`Query information <Schemas>` ],false,none,List of the HTTP header key/value pairs to be used by the webhook
  »» http_header_id,integer,false,none,ID of the HTTP header
  »» http_header_key,string,false,none,Name of the HTTP header key
  »» http_header_value,string,false,none,Name of the HTTP header key
  » payload_template,string,false,none,Payload template. Below is payload example for slack.
  » low_alert,boolean,false,none,Determines whether the low alert is enabled.
  » med_alert,boolean,false,none,Determines whether the medium alert is enabled.
  » high_alert,boolean,false,none,Determines whether the high alert is enabled.
  » cleared_alert,boolean,false,none,Determines whether the cleared alert is enabled.
  » payload_type,string,false,none,Payload type

Enumerated Values
'''''''''''''''''

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

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

..  Note::
   This operation does not require authentication

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

**Code samples**

.. code:: shell


   #  You can also use wget

   curl -X POST https://PEM-SERVER-IP/api/v14/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/api/v14/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/api/v14/webhook/,
   {
     method: POST,
     body: inputBody,
     headers: headers
   })
   .then(function(res) {
       return res.json();
   }).then(function(body) {
       console.log(body);
   });

``POST /webhook/``

- Add a new webhook.\*

**Body parameter**

.. 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"
   }

.. _parameters-1:

Parameters
^^^^^^^^^^

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

  X-Auth-Token,header,string,true,Token of authorization
  body,body,:ref:`WebhookPostData<WebhookPostData>` ,true,none

**Example responses**

.. _responses-1:

Responses
^^^^^^^^^

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

  200,:ref:`Invoking the server installer from the command line<Invoking the server installer from the command line>` ,Webhook created successfully.,None

.. _response-schema-1:

Response Schema
^^^^^^^^^^^^^^^

..  Note::
   This operation does not require authentication

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

**Code samples**

.. code:: shell


   #  You can also use wget

   curl -X GET https://PEM-SERVER-IP/api/v14/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/api/v14/webhook/{webhook_id}, headers = headers)

   print(r.json())

.. code:: javascript


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

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

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

``GET /webhook/{webhook_id}``

- Retrieve information for the webhook, identified by the webhook_id.\*

.. _parameters-2:

Parameters
^^^^^^^^^^

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

  webhook_id,path,string,true,none
  X-Auth-Token,header,string,true,Token of authorization

**Example responses**

.. 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>

.. _responses-2:

Responses
^^^^^^^^^

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

  200,:ref:`Invoking the server installer from the command line<Invoking the server installer from the command line>` ,Status 200,:ref:`Webhook<Webhook>` 

..  Note::
   This operation does not require authentication

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

**Code samples**

.. code:: shell


   #  You can also use wget

   curl -X PUT https://PEM-SERVER-IP/api/v14/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/api/v14/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/api/v14/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}``

- Update the webhook information.\*

**Body parameter**

.. 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
   }

.. _parameters-3:

Parameters
^^^^^^^^^^

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

  webhook_id,path,string,true,none
  X-Auth-Token,header,string,true,Token of authorization
  body,body,:ref:`WebhookPutData<WebhookPutData>` ,true,none

**Example responses**

.. _responses-3:

Responses
^^^^^^^^^

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

  200,:ref:`Invoking the server installer from the command line<Invoking the server installer from the command line>` ,Webhook updated successfully.,None

.. _response-schema-2:

Response Schema
^^^^^^^^^^^^^^^

..  Note::
   This operation does not require authentication

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

**Code samples**

.. code:: shell


   #  You can also use wget

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

.. code:: python

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

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

   print(r.json())

.. code:: javascript


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

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

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

``DELETE /webhook/{webhook_id}``

- Delete the webhook.\*

.. _parameters-4:

Parameters
^^^^^^^^^^

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

  webhook_id,path,string,true,none
  X-Auth-Token,header,string,true,Token of authorization

**Example responses**

.. _responses-4:

Responses
^^^^^^^^^

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

  200,:ref:`Invoking the server installer from the command line<Invoking the server installer from the command line>` ,Webhook deleted successfully,None

.. _response-schema-3:

Response Schema
^^^^^^^^^^^^^^^

..  Note::
   This operation does not require authentication
