# Role

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

## Role

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

| NO | Method                | Request Type                            | Response Type                                                                                                      | Description |
| -- | --------------------- | --------------------------------------- | ------------------------------------------------------------------------------------------------------------------ | ----------- |
| 1  | [**create**](#create) | [CreateRoleRequest](#createrolerequest) | [RoleInfo](#roleinfo)                                                                                              |             |
| 2  | [**update**](#update) | [UpdateRoleRequest](#updaterolerequest) | [RoleInfo](#roleinfo)                                                                                              |             |
| 3  | [**delete**](#delete) | [RoleRequest](#rolerequest)             | [google.protobuf.Empty](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/empty.proto)   |             |
| 4  | [**get**](#get)       | [GetRoleRequest](#getrolerequest)       | [RoleInfo](#roleinfo)                                                                                              |             |
| 5  | [**list**](#list)     | [RoleQuery](#rolequery)                 | [RolesInfo](#rolesinfo)                                                                                            |             |
| 6  | [**stat**](#stat)     | [RoleStatQuery](#rolestatquery)         | [google.protobuf.Struct](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/struct.proto) |             |

### create

> **POST** /identity/v1/roles

| Type     | Message                                 |
| -------- | --------------------------------------- |
| Request  | [CreateRoleRequest](#createrolerequest) |
| Response | [RoleInfo](#roleinfo)                   |

### update

> **PUT** /identity/v1/roles/{role\_id}

| Type     | Message                                 |
| -------- | --------------------------------------- |
| Request  | [UpdateRoleRequest](#updaterolerequest) |
| Response | [RoleInfo](#roleinfo)                   |

### delete

> **DELETE** /identity/v1/roles/{role\_id}

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

### get

> **GET** /identity/v1/roles/{role\_id}

| Type     | Message                           |
| -------- | --------------------------------- |
| Request  | [GetRoleRequest](#getrolerequest) |
| Response | [RoleInfo](#roleinfo)             |

### list

> **GET** /identity/v1/roles
>
> **POST** /identity/v1/roles/search

| Type     | Message                 |
| -------- | ----------------------- |
| Request  | [RoleQuery](#rolequery) |
| Response | [RolesInfo](#rolesinfo) |

### stat

> **POST** /identity/v1/roles/stat

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

## Message

### CreateRoleRequest

| No | Field      | Type                                                                                                               | Required | Description |
| -- | ---------- | ------------------------------------------------------------------------------------------------------------------ | -------- | ----------- |
| 1  | name       | string                                                                                                             | ✅        |             |
| 2  | role\_type | <ul><li>NONE</li><li>SYSTEM</li><li>DOMAIN</li><li>PROJECT</li></ul>                                               | ✅        |             |
| 3  | policies   | [list of RolePolicy](#rolepolicy)                                                                                  | ✅        |             |
| 4  | tags       | [google.protobuf.Struct](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/struct.proto) | ❌        |             |
| 5  | domain\_id | string                                                                                                             | ✅        |             |

### GetRoleRequest

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

### RoleInfo

| No | Field       | Type                                                                                                                     | Description |
| -- | ----------- | ------------------------------------------------------------------------------------------------------------------------ | ----------- |
| 1  | role\_id    | string                                                                                                                   |             |
| 2  | name        | string                                                                                                                   |             |
| 3  | role\_type  | <ul><li>NONE</li><li>SYSTEM</li><li>DOMAIN</li><li>PROJECT</li></ul>                                                     |             |
| 4  | policies    | [list of RolePolicy](#rolepolicy)                                                                                        |             |
| 5  | tags        | [google.protobuf.Struct](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/struct.proto)       |             |
| 6  | domain\_id  | string                                                                                                                   |             |
| 7  | created\_at | [google.protobuf.Timestamp](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/timestamp.proto) |             |
| 8  | deleted\_at | [google.protobuf.Timestamp](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/timestamp.proto) |             |

### RolePolicy

| No | Field          | Type                                                  | Description |
| -- | -------------- | ----------------------------------------------------- | ----------- |
| 1  | policy\_type   | <ul><li>NONE</li><li>MANAGED</li><li>CUSTOM</li></ul> |             |
| 2  | policy\_id     | string                                                |             |
| 3  | repository\_id | string                                                |             |

### RoleQuery

| No | Field      | Type                                                                                               | Required | Description |
| -- | ---------- | -------------------------------------------------------------------------------------------------- | -------- | ----------- |
| 1  | query      | [spaceone.api.core.v1.Query](https://spaceone-dev.gitbook.io/api-reference/common-v1/search-query) | ❌        |             |
| 2  | role\_id   | string                                                                                             | ❌        |             |
| 3  | name       | string                                                                                             | ❌        |             |
| 4  | role\_type | <ul><li>NONE</li><li>SYSTEM</li><li>DOMAIN</li><li>PROJECT</li></ul>                               | ❌        |             |
| 5  | domain\_id | string                                                                                             | ✅        |             |

### RoleRequest

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

### RoleStatQuery

| 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                                                                                                           | ✅        |             |

### RolesInfo

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

### UpdateRoleRequest

| No | Field      | Type                                                                                                               | Required | Description |
| -- | ---------- | ------------------------------------------------------------------------------------------------------------------ | -------- | ----------- |
| 1  | role\_id   | string                                                                                                             | ✅        |             |
| 2  | name       | string                                                                                                             | ❌        |             |
| 3  | policies   | [list of RolePolicy](#rolepolicy)                                                                                  | ❌        |             |
| 4  | tags       | [google.protobuf.Struct](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/struct.proto) | ❌        |             |
| 5  | domain\_id | string                                                                                                             | ✅        |             |
