# Event Rule

> **Package : spaceone.api.monitoring.v1**

## EventRule

{% hint style="info" %}
**EventRule Methods:**
{% endhint %}

| Method                             | Request                                                     | Response                                                                                                           |
| ---------------------------------- | ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| [**create**](#create)              | [CreateEventRuleRequest](#createeventrulerequest)           | [EventRuleInfo](#eventruleinfo)                                                                                    |
| [**update**](#update)              | [UpdateEventRuleRequest](#updateeventrulerequest)           | [EventRuleInfo](#eventruleinfo)                                                                                    |
| [**change\_order**](#change_order) | [ChangeEventRuleOrderRequest](#changeeventruleorderrequest) | [EventRuleInfo](#eventruleinfo)                                                                                    |
| [**delete**](#delete)              | [EventRuleRequest](#eventrulerequest)                       | [google.protobuf.Empty](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/empty.proto)   |
| [**get**](#get)                    | [GetEventRuleRequest](#geteventrulerequest)                 | [EventRuleInfo](#eventruleinfo)                                                                                    |
| [**list**](#list)                  | [EventRuleQuery](#eventrulequery)                           | [EventRulesInfo](#eventrulesinfo)                                                                                  |
| [**stat**](#stat)                  | [EventRuleStatQuery](#eventrulestatquery)                   | [google.protobuf.Struct](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/struct.proto) |

### create

> **POST** /monitoring/v1/event-rules

| Type     | Message                                           |
| -------- | ------------------------------------------------- |
| Request  | [CreateEventRuleRequest](#createeventrulerequest) |
| Response | [EventRuleInfo](#eventruleinfo)                   |

### update

> **PUT** /monitoring/v1/event-rule/{event\_rule\_id}

> Changes a priority order between EventRules to apply. EventRules are filtered by the order configured.

| Type     | Message                                           |
| -------- | ------------------------------------------------- |
| Request  | [UpdateEventRuleRequest](#updateeventrulerequest) |
| Response | [EventRuleInfo](#eventruleinfo)                   |

{% tabs %}
{% tab title="Request Example" %}

```
{
    "event_rule_id": "er-123456789012",
    "conditions": [
        {
            "key": "description",
            "value": "ELB",
            "operator": "contain"
        }
    ],
    "conditions_policy": "ALL",
    "actions": {
        "change_assignee": "user2@email.com",
        "change_urgency": "HIGH",
        "change_project": "project-123456789012",
        "add_additional_info": {
            "type": "personal rule"
        },
        "no_notification": true
    },
    "options": {},
    "domain_id": "domain-123456789012"
}
```

{% endtab %}

{% tab title="Response Example" %}

```
{
    "event_rule_id": "er-123456789012",
    "order": 2,
    "conditions": [
        {
            "key": "description",
            "value": "ELB",
            "operator": "contain"
        }
    ],
    "conditions_policy": "ALL",
    "actions": {
        "change_assignee": "user2@email.com",
        "change_urgency": "HIGH",
        "change_project": "project-123456789012",
        "add_additional_info": {
            "type": "personal rule"
        },
        "no_notification": true
    },
    "options": {},
    "scope": "PROJECT",
    "project_id": "project-123456789012",
    "tags": {},
    "domain_id": "domain-123456789012",
    "created_at": "2022-01-01T06:02:31.517Z"
}
```

{% endtab %}
{% endtabs %}

### change\_order

> **PUT** /monitoring/v1/event-rule/{event\_rule\_id}/order

> Updates a specific EventRule. You can make changes in EventRule settings.

| Type     | Message                                                     |
| -------- | ----------------------------------------------------------- |
| Request  | [ChangeEventRuleOrderRequest](#changeeventruleorderrequest) |
| Response | [EventRuleInfo](#eventruleinfo)                             |

{% tabs %}
{% tab title="Request Example" %}

```
{
    "event_rule_id": "er-123456789012",
    "order": 2,
    "domain_id": "domain-123456789012"
}
```

{% endtab %}

{% tab title="Response Example" %}

```
{
    "event_rule_id": "er-123456789012",
    "order": 2,
    "conditions": [
        {
            "key": "description",
            "value": "API",
            "operator": "contain"
        }
    ],
    "conditions_policy": "ALL",
    "actions": {
        "change_assignee": "user1@email.com",
        "change_urgency": "LOW",
        "change_project": "project-123456789012",
        "add_additional_info": {
            "type": "personal rule"
        },
        "no_notification": true
    },
    "options": {},
    "scope": "PROJECT",
    "project_id": "project-123456789012",
    "tags": {},
    "domain_id": "domain-123456789012",
    "created_at": "2022-01-02T06:02:31.517Z"
}
```

{% endtab %}
{% endtabs %}

### delete

> **DELETE** /monitoring/v1/event-rule/{event\_rule\_id}

> Deletes a specific EventRule. You must assign an EventRule resource to delete by specifying `event_rule_id`.

| Type     | Message                                                                                                          |
| -------- | ---------------------------------------------------------------------------------------------------------------- |
| Request  | [EventRuleRequest](#eventrulerequest)                                                                            |
| Response | [google.protobuf.Empty](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/empty.proto) |

{% tabs %}
{% tab title="Request Example" %}

```
{
    "event_rule_id": "er-123456789012",
    "domain_id": "domain-123456789012"
}
```

{% endtab %}
{% endtabs %}

### get

> **GET** /monitoring/v1/event-rule/{event\_rule\_id}

> Gets a specific EventRule. Prints detailed information about the EventRule.

| Type     | Message                                     |
| -------- | ------------------------------------------- |
| Request  | [GetEventRuleRequest](#geteventrulerequest) |
| Response | [EventRuleInfo](#eventruleinfo)             |

{% tabs %}
{% tab title="Request Example" %}

```
{
    "event_rule_id": "er-123456789012",
    "domain_id": "domain-123456789012"
}
```

{% endtab %}

{% tab title="Response Example" %}

```
{
    "event_rule_id": "er-123456789012",
    "order": 2,
    "conditions": [
        {
            "key": "title",
            "value": "ELB",
            "operator": "contain"
        }
    ],
    "conditions_policy": "ALL",
    "actions": {
        "change_assignee": "user1@email.com",
        "change_urgency": "LOW",
        "change_project": "project-123456789012",
        "add_additional_info": {},
        "no_notification": true
    },
    "options": {},
    "scope": "PROJECT",
    "project_id": "project-123456789012",
    "tags": {},
    "domain_id": "domain-123456789012",
    "created_at": "2022-01-01T06:12:30.226Z"
}
```

{% endtab %}
{% endtabs %}

### list

> **GET** /monitoring/v1/event-rules
>
> **POST** /monitoring/v1/event-rules/search

> Gets a list of all EventRules. You can use a query to get a filtered list of EventRules. For example, you can adjust the scope of the list to a certain Project or Domain.

| Type     | Message                           |
| -------- | --------------------------------- |
| Request  | [EventRuleQuery](#eventrulequery) |
| Response | [EventRulesInfo](#eventrulesinfo) |

{% tabs %}
{% tab title="Request Example" %}

```
{
    "project_id": "project-123456789012",
    "domain_id": "domain-123456789012"
}
```

{% endtab %}

{% tab title="Response Example" %}

```
{
    "results": [
        {
            "event_rule_id": "er-123456789012",
            "order": 1,
            "conditions": [
                {
                    "key": "title",
                    "value": "AWS",
                    "operator": "contain"
                }
            ],
            "conditions_policy": "ALL",
            "actions": {
                "change_assignee": "user2@email.com",
                "change_urgency": "HIGH",
                "add_additional_info": {},
                "no_notification": true
            },
            "options": {},
            "scope": "PROJECT",
            "project_id": "project-123456789012",
            "tags": {},
            "domain_id": "domain-123456789012",
            "created_at": "2022-01-01T06:33:58.388Z"
        },
        {
            "event_rule_id": "er-123456789012",
            "order": 2,
            "conditions": [
                {
                    "key": "title",
                    "value": "ELB",
                    "operator": "contain"
                }
            ],
            "conditions_policy": "ALL",
            "actions": {
                "change_assignee": "user1@email.com",
                "change_urgency": "LOW",
                "change_project": "project-123456789012",
                "add_additional_info": {},
                "no_notification": true
            },
            "options": {},
            "scope": "PROJECT",
            "project_id": "project-123456789012",
            "tags": {},
            "domain_id": "domain-123456789012",
            "created_at": "2022-01-01T06:12:30.226Z"
        }
    ],
    "total_count": 2
}
```

{% endtab %}
{% endtabs %}

### stat

> **POST** /monitoring/v1/event-rules/stat

| Type     | Message                                                                                                            |
| -------- | ------------------------------------------------------------------------------------------------------------------ |
| Request  | [EventRuleStatQuery](#eventrulestatquery)                                                                          |
| Response | [google.protobuf.Struct](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/struct.proto) |

##

## Message

### ChangeEventRuleOrderRequest

| Field           | Type                                                                                            | Required | Description |
| --------------- | ----------------------------------------------------------------------------------------------- | :------: | ----------- |
| event\_rule\_id | string                                                                                          |     ✔    |             |
| order           | [int32](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/type.proto) |     ✔    |             |
| domain\_id      | string                                                                                          |     ✔    |             |

### CreateEventRuleRequest

| Field              | Type                                                                                                               | Required | Description |
| ------------------ | ------------------------------------------------------------------------------------------------------------------ | -------- | ----------- |
| name               | string                                                                                                             | ✔        |             |
| conditions         | [list of EventRuleCondition](#eventrulecondition)                                                                  | ✔        |             |
| conditions\_policy | <ul><li>NONE</li><li>ALL</li><li>ANY</li><li>ALWAYS</li></ul>                                                      | ✔        |             |
| actions            | [EventRuleActions](#eventruleactions)                                                                              | ✔        |             |
| options            | [EventRuleOptions](#eventruleoptions)                                                                              | ✘        |             |
| project\_id        | string                                                                                                             | ✘        |             |
| tags               | [google.protobuf.Struct](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/struct.proto) | ✘        |             |
| domain\_id         | string                                                                                                             | ✔        |             |

### EventRuleActionResponder

| Field          | Type   | Description |
| -------------- | ------ | ----------- |
| resource\_type | string |             |
| resource\_id   | string |             |

### EventRuleActions

| Field                    | Type                                                                                                               | Description |
| ------------------------ | ------------------------------------------------------------------------------------------------------------------ | ----------- |
| change\_assignee         | string                                                                                                             |             |
| change\_urgency          | string                                                                                                             |             |
| change\_project          | string                                                                                                             |             |
| add\_project\_dependency | list of string                                                                                                     |             |
| add\_responder           | [list of EventRuleActionResponder](#eventruleactionresponder)                                                      |             |
| match\_service\_account  | [MatchRule](#matchrule)                                                                                            |             |
| add\_additional\_info    | [google.protobuf.Struct](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/struct.proto) |             |
| no\_notification         | bool                                                                                                               |             |

### EventRuleCondition

| Field    | Type   | Description |
| -------- | ------ | ----------- |
| key      | string |             |
| value    | string |             |
| operator | string |             |

### EventRuleInfo

| Field              | Type                                                                                                               | Description |
| ------------------ | ------------------------------------------------------------------------------------------------------------------ | ----------- |
| event\_rule\_id    | string                                                                                                             |             |
| name               | string                                                                                                             |             |
| order              | [int32](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/type.proto)                    |             |
| conditions         | [list of EventRuleCondition](#eventrulecondition)                                                                  |             |
| conditions\_policy | <ul><li>NONE</li><li>ALL</li><li>ANY</li><li>ALWAYS</li></ul>                                                      |             |
| actions            | [EventRuleActions](#eventruleactions)                                                                              |             |
| options            | [EventRuleOptions](#eventruleoptions)                                                                              |             |
| scope              | <ul><li>SCOPE\_NONE</li><li>GLOBAL</li><li>PROJECT</li></ul>                                                       |             |
| project\_id        | string                                                                                                             |             |
| tags               | [google.protobuf.Struct](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/struct.proto) |             |
| domain\_id         | string                                                                                                             |             |
| created\_at        | string                                                                                                             |             |

### EventRuleOptions

| Field            | Type | Description |
| ---------------- | ---- | ----------- |
| stop\_processing | bool |             |

### EventRuleQuery

| Field           | Type                                                                                               | Required | Description |
| --------------- | -------------------------------------------------------------------------------------------------- | -------- | ----------- |
| query           | [spaceone.api.core.v1.Query](https://spaceone-dev.gitbook.io/api-reference/common-v1/search-query) | ✘        |             |
| event\_rule\_id | string                                                                                             | ✘        |             |
| name            | string                                                                                             | ✘        |             |
| scope           | <ul><li>SCOPE\_NONE</li><li>GLOBAL</li><li>PROJECT</li></ul>                                       | ✘        |             |
| project\_id     | string                                                                                             | ✘        |             |
| domain\_id      | string                                                                                             | ✔        |             |

### EventRuleRequest

| Field           | Type   | Required | Description |
| --------------- | ------ | :------: | ----------- |
| event\_rule\_id | string |     ✔    |             |
| domain\_id      | string |     ✔    |             |

### EventRuleStatQuery

| Field      | Type                                                                                                             | Required | Description |
| ---------- | ---------------------------------------------------------------------------------------------------------------- | :------: | ----------- |
| query      | [spaceone.api.core.v1.StatisticsQuery](https://spaceone-dev.gitbook.io/api-reference/common-v1/statistics-query) |     ✔    |             |
| domain\_id | string                                                                                                           |     ✔    |             |

### EventRulesInfo

| Field        | Type                                                                                            | Description |
| ------------ | ----------------------------------------------------------------------------------------------- | ----------- |
| results      | [list of EventRuleInfo](#eventruleinfo)                                                         |             |
| total\_count | [int32](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/type.proto) |             |

### GetEventRuleRequest

| Field           | Type           | Required | Description |
| --------------- | -------------- | :------: | ----------- |
| event\_rule\_id | string         |     ✔    |             |
| domain\_id      | string         |     ✔    |             |
| only            | list of string |     ✘    |             |

### MatchRule

| Field  | Type   | Description |
| ------ | ------ | ----------- |
| source | string |             |
| target | string |             |

### UpdateEventRuleRequest

| Field              | Type                                                                                                               | Required | Description |
| ------------------ | ------------------------------------------------------------------------------------------------------------------ | -------- | ----------- |
| event\_rule\_id    | string                                                                                                             | ✔        |             |
| name               | string                                                                                                             | ✘        |             |
| conditions         | [list of EventRuleCondition](#eventrulecondition)                                                                  | ✘        |             |
| conditions\_policy | <ul><li>NONE</li><li>ALL</li><li>ANY</li><li>ALWAYS</li></ul>                                                      | ✘        |             |
| actions            | [EventRuleActions](#eventruleactions)                                                                              | ✘        |             |
| options            | [EventRuleOptions](#eventruleoptions)                                                                              | ✘        |             |
| tags               | [google.protobuf.Struct](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/struct.proto) | ✘        |             |
| domain\_id         | string                                                                                                             | ✔        |             |
