# Schedule Rule

> **Package : spaceone.api.power\_scheduler.v1**

## ScheduleRule

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

| NO | Method                | Request Type                                            | Response Type                                                                                                      | Description |
| -- | --------------------- | ------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ | ----------- |
| 1  | [**create**](#create) | [CreateScheduleRuleRequest](#createschedulerulerequest) | [RuleInfo](#ruleinfo)                                                                                              |             |
| 2  | [**update**](#update) | [UpdateScheduleRuleRequest](#updateschedulerulerequest) | [RuleInfo](#ruleinfo)                                                                                              |             |
| 3  | [**delete**](#delete) | [ScheduleRuleRequest](#schedulerulerequest)             | [google.protobuf.Empty](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/empty.proto)   |             |
| 4  | [**get**](#get)       | [GetScheduleRuleRequest](#getschedulerulerequest)       | [RuleInfo](#ruleinfo)                                                                                              |             |
| 5  | [**list**](#list)     | [ScheduleRuleQuery](#schedulerulequery)                 | [RulesInfo](#rulesinfo)                                                                                            |             |
| 6  | [**stat**](#stat)     | [ScheduleRuleStatQuery](#schedulerulestatquery)         | [google.protobuf.Struct](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/struct.proto) |             |

### create

> **POST** /power-scheduler/v1/schedule-rules

| Type     | Message                                                 |
| -------- | ------------------------------------------------------- |
| Request  | [CreateScheduleRuleRequest](#createschedulerulerequest) |
| Response | [RuleInfo](#ruleinfo)                                   |

### update

> **PUT** /power-scheduler/v1/schedule-rule/{schedule\_rule\_id}

| Type     | Message                                                 |
| -------- | ------------------------------------------------------- |
| Request  | [UpdateScheduleRuleRequest](#updateschedulerulerequest) |
| Response | [RuleInfo](#ruleinfo)                                   |

### delete

> **DELETE** /power-scheduler/v1/schedule-rule/{schedule\_rule\_id}

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

### get

> **GET** /power-scheduler/v1/schedule-rule/{schedule\_rule\_id}

| Type     | Message                                           |
| -------- | ------------------------------------------------- |
| Request  | [GetScheduleRuleRequest](#getschedulerulerequest) |
| Response | [RuleInfo](#ruleinfo)                             |

### list

> **GET** /power-scheduler/v1/schedule-rules
>
> **POST** /power-scheduler/v1/schedule-rules/search

| Type     | Message                                 |
| -------- | --------------------------------------- |
| Request  | [ScheduleRuleQuery](#schedulerulequery) |
| Response | [RulesInfo](#rulesinfo)                 |

### stat

> **POST** /power-scheduler/v1/schedule-rules/stat

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

## Message

### CreateScheduleRuleRequest

| No | Field        | Type                                                                                            | Required | Description |
| -- | ------------ | ----------------------------------------------------------------------------------------------- | -------- | ----------- |
| 1  | schedule\_id | string                                                                                          | ✅        |             |
| 2  | name         | string                                                                                          | ❌        |             |
| 3  | state        | <ul><li>SCHEDULERULESTATE\_NONE</li><li>RUNNING</li><li>STOPPED</li></ul>                       | ✅        |             |
| 4  | rule\_type   | <ul><li>RULETYPE\_NONE</li><li>ROUTINE</li><li>TICKET</li></ul>                                 | ✅        |             |
| 5  | rule         | [list of Rule](#rule)                                                                           | ✅        |             |
| 6  | priority     | [int32](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/type.proto) | ❌        |             |
| 7  | tags         | list of spaceone.api.core.v1.Tag                                                                | ❌        |             |
| 8  | user\_id     | string                                                                                          | ✅        |             |
| 9  | domain\_id   | string                                                                                          | ✅        |             |

### GetScheduleRuleRequest

| No | Field              | Type           | Required | Description |
| -- | ------------------ | -------------- | -------- | ----------- |
| 1  | schedule\_rule\_id | string         | ✅        |             |
| 2  | domain\_id         | string         | ✅        |             |
| 3  | only               | list of string | ❌        |             |

### Rule

| No | Field | Type                                                                                                    | Description |
| -- | ----- | ------------------------------------------------------------------------------------------------------- | ----------- |
| 1  | day   | string                                                                                                  |             |
| 2  | date  | string                                                                                                  |             |
| 3  | times | [list of int32](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/type.proto) |             |

### RuleInfo

| No | Field              | Type                                                                                                                     | Description |
| -- | ------------------ | ------------------------------------------------------------------------------------------------------------------------ | ----------- |
| 1  | schedule\_rule\_id | string                                                                                                                   |             |
| 2  | name               | string                                                                                                                   |             |
| 3  | state              | <ul><li>SCHEDULERULESTATE\_NONE</li><li>RUNNING</li><li>STOPPED</li></ul>                                                |             |
| 4  | rule\_type         | <ul><li>RULETYPE\_NONE</li><li>ROUTINE</li><li>TICKET</li></ul>                                                          |             |
| 5  | rule               | [list of Rule](#rule)                                                                                                    |             |
| 6  | priority           | [int32](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/type.proto)                          |             |
| 7  | schedule\_id       | string                                                                                                                   |             |
| 8  | tags               | list of spaceone.api.core.v1.Tag                                                                                         |             |
| 9  | project\_id        | string                                                                                                                   |             |
| 10 | domain\_id         | string                                                                                                                   |             |
| 11 | created\_by        | string                                                                                                                   |             |
| 12 | created\_at        | [google.protobuf.Timestamp](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/timestamp.proto) |             |

### RulesInfo

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

### ScheduleRuleQuery

| No | Field              | Type                                                                                               | Required | Description |
| -- | ------------------ | -------------------------------------------------------------------------------------------------- | -------- | ----------- |
| 1  | query              | [spaceone.api.core.v1.Query](https://spaceone-dev.gitbook.io/api-reference/common-v1/search-query) | ❌        |             |
| 2  | schedule\_rule\_id | string                                                                                             | ❌        |             |
| 3  | schedule\_id       | string                                                                                             | ❌        |             |
| 4  | name               | string                                                                                             | ❌        |             |
| 5  | priority           | [int32](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/type.proto)    | ❌        |             |
| 6  | state              | <ul><li>SCHEDULERULESTATE\_NONE</li><li>RUNNING</li><li>STOPPED</li></ul>                          | ❌        |             |
| 7  | project\_id        | string                                                                                             | ❌        |             |
| 8  | domain\_id         | string                                                                                             | ✅        |             |

### ScheduleRuleRequest

| No | Field              | Type   | Required | Description |
| -- | ------------------ | ------ | -------- | ----------- |
| 1  | schedule\_rule\_id | string | ✅        |             |
| 2  | domain\_id         | string | ✅        |             |

### ScheduleRuleStatQuery

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

### UpdateScheduleRuleRequest

| No | Field              | Type                                                                      | Required | Description |
| -- | ------------------ | ------------------------------------------------------------------------- | -------- | ----------- |
| 1  | schedule\_rule\_id | string                                                                    | ✅        |             |
| 2  | name               | string                                                                    | ❌        |             |
| 3  | state              | <ul><li>SCHEDULERULESTATE\_NONE</li><li>RUNNING</li><li>STOPPED</li></ul> | ❌        |             |
| 4  | rule               | [list of Rule](#rule)                                                     | ❌        |             |
| 5  | tags               | list of spaceone.api.core.v1.Tag                                          | ❌        |             |
| 6  | domain\_id         | string                                                                    | ✅        |             |
