# RoutingPolicies

## RoutingPolicies - Create

Creates a new Routing Policy.

**POST**

```
https://api-server-host-name/configapi/{pool_UUID}/{logpoint_identifier}/RoutingPolicies
```

### Parameters

| Field             | Label in UI      | Type    | Description                                                                                                        |
| ----------------- | ---------------- | ------- | ------------------------------------------------------------------------------------------------------------------ |
| catch\_all        | Catch All        | String  | It is the default Repo. If none of the routing criteria matches then the default repo is selected. Mandatory Field |
| policy\_name      | Policy Name      | String  | Routing Policy name. Mandatory Field                                                                               |
| routing\_criteria | Routing Criteria | \[json] | This field can be an empty List `[]` if Routing criteria doesn't need to be defined. See details below.            |

<details>

<summary>Routing criteria details (expand)</summary>

To define **routing criteria**, you must provide the following parameters:

* `category`: Value can be `"simple"` or `"type_based"`.
* `operation`: Value must be `"Equals"`.
* `prefix`: Value can be `"true"` or `"false"`. Mandatory only when `category = "type_based"`.
* `event_key`: Event id. Mandatory only when `category = "simple"`.
* `source_key`: Source id.
* `type`: Value can only be `"ip"` or `"string"` or `"num"`. Mandatory only when `category = "type_based"`.

</details>

### Request Example

{% code title="" %}

```json
{
    "data": {
        "catch_all": "default",
        "routing_criteria": [
            {
                "repo": "_logpoint",
                "drop": "store",
                "type": "KeyPresent",
                "key": "aa",
                "value": ""
            },
            {
                "repo": "",
                "drop": "store",
                "type": "KeyPresentValueMatches",
                "key": "hh",
                "value": "oo"
            }
        ],
        "policy_name": "testPolicy"
    }
}
```

{% endcode %}

### Success Response

{% code title="" %}

```json
{
    "status": "Success",
    "message": "/monitorapi/{pool_UUID}/{logpoint_identifier}/orders/{request_id}"
}
```

{% endcode %}

## RoutingPolicies - Edit

Edits the Routing Policy with given ID.

**PUT**

```
https://api-server-host-name/configapi/{pool_UUID}/{logpoint_identifier}/RoutingPolicies/{id}
```

### Parameters

| Field             | Label in UI      | Type    | Description                                                                                                                              |
| ----------------- | ---------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| policy\_name      | Policy Name      | String  | Routing Policy name. Mandatory Field                                                                                                     |
| catch\_all        | Catch All        | String  | It is the default repo. If none of the routing criteria is matched then the default repo is selected. Mandatory Field                    |
| id                | -                | String  | Routing Policy id. Mandatory Field                                                                                                       |
| routing\_criteria | Routing Criteria | \[json] | This field can be an empty List `[]` if Routing criteria doesn't need to be defined. See routing criteria details in the Create section. |

### Request Example

{% code title="Request body (JSON)" %}

```json
{
    "data": {
        "routing_criteria": [
            {
                "repo": "_logpoint",
                "drop": "store",
                "type": "KeyPresent",
                "key": "aa",
                "value": ""
            },
            {
                "repo": "",
                "drop": "store",
                "type": "KeyPresentValueMatches",
                "key": "hh",
                "value": "oo"
            }
        ],
        "policy_name": "testPolicy",
        "catch_all": "default"
    }
}
```

{% endcode %}

### Success Response

{% code title="Response (JSON)" %}

```json
{
    "status": "Success",
    "message": "/monitorapi/{pool_UUID}/{logpoint_identifier}/orders/{request_id}"
}
```

{% endcode %}

## RoutingPolicies - Get

Fetches a Routing Policy with given ID.

**GET**

```
https://api-server-host-name/configapi/{pool_UUID}/{logpoint_identifier}/RoutingPolicies/{id}
```

### Parameter

| Field | Label in UI | Type   | Description        |
| ----- | ----------- | ------ | ------------------ |
| id    | -           | String | Routing Policy id. |

### Success Response

{% code title="" %}

```json
{
    "routing_criteria": [
        {
            "type": "KeyPresent",
            "key": "aa",
            "value": "",
            "repo": "_logpoint",
            "drop": "store"
        },
        {
            "type": "KeyPresentValueMatches",
            "key": "hh",
            "value": "oo",
            "repo": "",
            "drop": "store"
        }
    ],
    "policy_name": "testPolicy",
    "catch_all": "default",
    "id": "574fb123d8aaa4625bfe2d23"
}
```

{% endcode %}

## RoutingPolicies - List

Lists all Routing Policies.

**GET**

```
https://api-server-host-name/configapi/{pool_UUID}/{logpoint_identifier}/RoutingPolicies
```

### Success Response

{% code title="" %}

```json
[
    {
        "catch_all": "default",
        "routing_criteria": [
            {
                "repo": "_logpoint",
                "drop": "store",
                "type": "KeyPresent",
                "key": "aa",
                "value": ""
            },
            {
                "repo": "",
                "drop": "store",
                "type": "KeyPresentValueMatches",
                "key": "hh",
                "value": "oo"
            }
        ],
        "policy_name": "testPolicy",
        "id": "574fb123d8aaa4625bfe2d23"
    }
]
```

{% endcode %}

## RoutingPolicies - Trash

Deletes the Routing Policy with given ID.

**DELETE**

```
https://api-server-host-name/configapi/{pool_UUID}/{logpoint_identifier}/RoutingPolicies/{id}
```

### Parameter

| Field | Label in UI | Type   | Description                        |
| ----- | ----------- | ------ | ---------------------------------- |
| id    | -           | String | Routing Policy id. Mandatory Field |

### Success Response

{% code title="" %}

```json
{
    "status": "Success",
    "message": "/monitorapi/{pool_UUID}/{logpoint_identifier}/orders/{request_id}"
}
```

{% endcode %}
