# OMS Audit Events Service

The OMS Audit Events Service contains records of model changes and various events that occur within the OMS. This service is responsible for retrieving these event logs from the OMS.

### `GET` List OMS Audit Events

This service is used to retrieve list of audit events from OMS.

**Path:** `/api/v1/oms/settings/audit_events/`

**Payload**

No payload is required.

**Filters**

| Parameter     | Data Type  | In          | Description                           |
| ------------- | ---------- | ----------- | ------------------------------------- |
| url           | `string`   | query param | Filters the event url                 |
| content\_type | `int`      | query param | Filters the event object content type |
| object\_id    | `int`      | query param | Filters the event object              |
| start\_date   | `datetime` | query param | Filters the event start date          |
| end\_date     | `datetime` | body        | Filters the event end date            |

**Example Request**

To run this service, a `GET` request should be sent to `/api/v1/oms/settings/audit_events/` endpoint.

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

```python
import requests

url = "https://{oms_base_url}/api/v1/oms/settings/audit_events/?url=https://example-url.com&content_type=1"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

headers = {
'Accept': 'application/json',
'Authorization': 'Token {}'.format(api_token)
}

response = requests.request("get", url, headers=headers)

print(response.text)
```

**Example Response (201 CREATED)**

In a successful response with a status code of 200 OK, the response body contains list of audit event objects.

| Parameter     | Data Type | Description                                                                       |
| ------------- | --------- | --------------------------------------------------------------------------------- |
| uuid          | uuid      | Unique ID of the audit event                                                      |
| timestamp     | datetime  | Timestamp of the event                                                            |
| remote\_addr  | string    | If event has remote address, this parameter shows the remote address of the event |
| url           | string    | URL of the event                                                                  |
| query\_params | object    | If event has query params, this parameter shows the query params of the event     |
| post\_data    | object    | If event has post data, this parameter shows the post data of the event           |
| headers       | object    | Headers of the event                                                              |
| object\_id    | int       | Related object ID of the event                                                    |
| content       | object    | Content of the event                                                              |
| user          | int       | If event is triggered by user, this parameter shows the user of the event.        |
| content\_type | int       | Related object content type of the event                                          |

```json
    {
    "count": 100,
    "next": "https://demo.omnitron.akinon.net/api/v1/oms/settings/audit_events/?page=2",
    "previous": null,
    "results": [
        {
            "uuid": "410237f7-2a6f-48de-9c41-b988326d7607",
            "timestamp": "2023-10-16T09:00:00.929094Z",
            "remote_addr": null,
            "url": "https://example.com",
            "query_params": {},
            "post_data": {},
            "headers": {},
            "object_id": 859,
            "content": {
                "new_data": {
                    "quantity": 2.0
                },
                "old_data": {
                    "quantity": 1.0
                },
            },
            "user": null,
            "content_type": 41
        }
    ]
}
```
