# Webhook Setup Services

All services related to webhook setup are listed in this document.

### `POST` Execute

This endpoint is used to add unregistered webhooks from the settings to the Omnitron client. Specifically, it checks the webhooks listed in the OMNITRON\_WEBHOOKS setting, and any webhooks found in the settings but not already registered with the Omnitron client will be added to the client.

**Path:** `/api/v1/oms/setup/webhooks/execute/`

**Request Body**

The following query parameters can be used to execute the setup.

| Parameter | Data Type | In     | Description                         |
| --------- | --------- | ------ | ----------------------------------- |
| token     | string    | header | The API key of the customer account |

**Example Request**

To execute this setup step, a `POST` request should be sent to\
the `/api/v1/oms/setup/webhooks/execute/` endpoint. In the headers, set\
the `Authorization` header to include the token for authentication.

Here's an example of how to make the request in python:

```python
import requests

url = "https://{domain_url}/api/v1/oms/setup/webhooks/execute/"
token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

headers = {
    'Content-Type': 'application/json',
    'Authorization': f'Token {token}'
}

response = requests.request('POST', url, headers=headers)

print(response.status_code)
```

**Response 204 No Content**

There is No Response.

### `GET` Get Async Status

This endpoint provides the status of the task executed by the "execute" endpoint. If there is no active task, the result will be returned as "READY."

**Path:** `/api/v1/oms/setup/webhooks/get_async_status/`

**Request Body**

The following query parameters can be used view the status of the setup task.

| Parameter | Data Type | In     | Description                         |
| --------- | --------- | ------ | ----------------------------------- |
| token     | string    | header | The API key of the customer account |

**Example Request**

To view the status of the task, a `GET` request should be sent to\
the `/api/v1/oms/setup/webhooks/get_async_status/` endpoint. In the headers, set\
the `Authorization` header to include the token for authentication.

Here's an example of how to make the request in python:

```python
import requests

url = "https://{domain_url}/api/v1/oms/setup/webhooks/get_async_status/"
token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

headers = {
    'Content-Type': 'application/json',
    'Authorization': f'Token {token}'
}

response = requests.request('POST', url, headers=headers)

print(response.json())
```

**Response 200 OK**

Possible values of result are:

* READY
* WORKING
* FINISHED
* FAILED
* ABORTED

| Parameter | Data Type | Description            |
| --------- | --------- | ---------------------- |
| result    | string    | The status of the task |

This example response serves as a reference to understand the structure and\
data format returned from this API service.

```json
{
  "result": "Ready"
}
```

### `GET` Is Required

This endpoint indicates whether the "execute" endpoint should be called or not. It evaluates whether there are any webhooks listed in the settings that are not registered within the Omnitron client. If there are unregistered webhooks in the settings, the result is returned as true.

**Path:** `/api/v1/oms/setup/webhooks/is_required/`

**Request Body**

The following query parameters can be used to execute the setup.

| Parameter | Data Type | In     | Description                         |
| --------- | --------- | ------ | ----------------------------------- |
| token     | string    | header | The API key of the customer account |

**Example Request**

To execute this setup step, a `POST` request should be sent to\
the `/api/v1/oms/setup/webhooks/is_required/` endpoint. In the headers, set\
the `Authorization` header to include the token for authentication.\
Here's an example of how to make the request in python:

```python
import requests

url = "https://{domain_url}/api/v1/oms/setup/webhooks/is_required/"
token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

headers = {
    'Content-Type': 'application/json',
    'Authorization': f'Token {token}'
}

response = requests.request('POST', url, headers=headers)

print(response.status_code)
```

**Response 200 OK**

Possible values of result are true and false.

| Parameter | Data Type | Description                           |
| --------- | --------- | ------------------------------------- |
| reuslt    | string    | Whether the task should be run or not |

This example response serves as a reference to understand the structure and\
data format returned from this API service.

```json
{
  "result": "true"
}
```
