> For the complete documentation index, see [llms.txt](https://spaceone-dev.gitbook.io/spaceone-apis/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://spaceone-dev.gitbook.io/spaceone-apis/repository/v1/policy.md).

# Policy

A Policy is a resource managing page access permissions. This resource can be used in all domains if it is defined in the \`repository\` microservice.

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

## Policy

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

| Method                | Request                                                   | Response                                                                                                           |
| --------------------- | --------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| [**create**](#create) | [CreatePolicyRequest](#createpolicyrequest)               | [PolicyInfo](#policyinfo)                                                                                          |
| [**update**](#update) | [UpdatePolicyRequest](#updatepolicyrequest)               | [PolicyInfo](#policyinfo)                                                                                          |
| [**delete**](#delete) | [PolicyRequest](#policyrequest)                           | [google.protobuf.Empty](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/empty.proto)   |
| [**get**](#get)       | [GetRepositoryPolicyRequest](#getrepositorypolicyrequest) | [PolicyInfo](#policyinfo)                                                                                          |
| [**list**](#list)     | [PolicyQuery](#policyquery)                               | [PoliciesInfo](#policiesinfo)                                                                                      |
| [**stat**](#stat)     | [PolicyStatQuery](#policystatquery)                       | [google.protobuf.Struct](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/struct.proto) |

### create

> **POST** /repository/v1/policies

> Creates a new Policy. The parameter `policy_id`, an identifier of Policy resources, can only include lowercase alphabets, numbers, and hyphens(-). The parameter `permissions` is a list type data describing page access permissions.

| Type     | Message                                     |
| -------- | ------------------------------------------- |
| Request  | [CreatePolicyRequest](#createpolicyrequest) |
| Response | [PolicyInfo](#policyinfo)                   |

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

```
{
    "policy_id": "policy-custom-full-acess",
    "name": "Full Access",
    "permissions": [
        "*"
    ],
    "labels": [],
    "tags": {},
    "domain_id": "domain-123456789012"
}
```

{% endtab %}

{% tab title="Response Example" %}

```
{
    "policy_id": "policy-custom-full-acess",
    "name": "Full Access",
    "state": "ENABLED",
    "permissions": [
        "*"
    ],
    "labels": [],
    "tags": {},
    "repository_info": {
        "repository_id": "repo-123456789012",
        "name": "Local",
        "repository_type": "local"
    },
    "domain_id": "domain-123456789012",
    "created_at": "2022-01-01T06:45:04.582Z",
    "updated_at": "2022-01-01T06:45:04.582Z"
}
```

{% endtab %}
{% endtabs %}

### update

> **PUT** /repository/v1/policy/{policy}

> Updates a specific Policy. You can make changes in Policy settings, including `name`, `labels`, `tags`, and `permissions`. The parameter `policy_id` cannot be updated.

| Type     | Message                                     |
| -------- | ------------------------------------------- |
| Request  | [UpdatePolicyRequest](#updatepolicyrequest) |
| Response | [PolicyInfo](#policyinfo)                   |

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

```
{
    "policy_id": "policy-custom-full-acess",
    "name": "Full Access",
    "permissions": [
        "*"
    ],
    "labels": [],
    "tags": {},
    "domain_id": "domain-123456789012"
}
```

{% endtab %}

{% tab title="Response Example" %}

```
{
    "policy_id": "policy-custom-full-acess",
    "name": "Full Access",
    "state": "ENABLED",
    "permissions": [
        "*"
    ],
    "labels": [],
    "tags": {},
    "repository_info": {
        "repository_id": "repo-123456789012",
        "name": "Local",
        "repository_type": "local"
    },
    "domain_id": "domain-123456789012",
    "created_at": "2022-01-01T06:45:04.582Z",
    "updated_at": "2022-01-01T06:45:04.582Z"
}
```

{% endtab %}
{% endtabs %}

### delete

> **DELETE** /repository/v1/policy/{policy}

> Deletes a specific Policy. You must specify the `policy_id` of the Policy to delete, as the `policy_id` is an identifier of Policy resources.

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

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

```
{
    "policy_id": "policy-123456789012"
}
```

{% endtab %}
{% endtabs %}

### get

> **GET** /repository/v1/policies/{policy}

> Gets a specific Policy. You must specify the `policy_id` of the Policy to get, as the `policy_id` is an identifier of Policy resources. You can use the parameter `repository_id` to limit the scope of the method to a specific Repository.

| Type     | Message                                                   |
| -------- | --------------------------------------------------------- |
| Request  | [GetRepositoryPolicyRequest](#getrepositorypolicyrequest) |
| Response | [PolicyInfo](#policyinfo)                                 |

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

```
{
    "policy_id": "policy-123456789012",
    "repository_id": "repo-123456789012"
}
```

{% endtab %}

{% tab title="Response Example" %}

```
{
    "policy_id": "policy-123456789012",
    "name": "Full Access",
    "state": "ENABLED",
    "permissions": [
        "*"
    ],
    "labels": [],
    "tags": {},
    "repository_info": {
        "repository_id": "repo-123456789012",
        "name": "Local",
        "repository_type": "local"
    },
    "domain_id": "domain-123456789012",
    "created_at": "2022-01-01T15:42:50.943Z",
    "updated_at": "2022-01-01T15:42:50.943Z"
}
```

{% endtab %}
{% endtabs %}

### list

> **GET** /repository/v1/policies
>
> **POST** /repository/v1/policies/search

> Gets a list of all Policies in a specific Repository. The parameter `repository_id` is used as an identifier of a Repository to get its list of Policies. You can use a query to get a filtered list of Policies.

| Type     | Message                       |
| -------- | ----------------------------- |
| Request  | [PolicyQuery](#policyquery)   |
| Response | [PoliciesInfo](#policiesinfo) |

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

```
{
    "query": {},
    "repository_id": "repo-123456789012"
}
```

{% endtab %}

{% tab title="Response Example" %}

```
{
    "results": [
        {
            "policy_id": "policy-123456789012",
            "name": "Full Access",
            "state": "ENABLED",
            "permissions": [
                "*"
            ],
            "labels": [],
            "tags": {},
            "repository_info": {
                "repository_id": "repo-123456789012",
                "name": "Local",
                "repository_type": "local"
            },
            "domain_id": "domain-123456789012",
            "created_at": "2022-01-01T15:42:50.943Z",
            "updated_at": "2022-01-01T15:42:50.943Z"
        },
        {
            "policy_id": "policy-987654321098",
            "name": "Identity Admin",
            "state": "ENABLED",
            "permissions": [
                "identity.*"
            ],
            "labels": [],
            "tags": {},
            "repository_info": {
                "repository_id": "repo-123456789012",
                "name": "Local",
                "repository_type": "local"
            },
            "domain_id": "domain-123456789012",
            "created_at": "2022-01-01T08:08:14.756Z",
            "updated_at": "2022-01-01T08:08:14.756Z"
        }
    ],
    "total_count": 2
}
```

{% endtab %}
{% endtabs %}

### stat

> **POST** /repository/v1/policies/stat

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

##

## Message

### CreatePolicyRequest

| Field       | Type                                                                                                               | Required | Description |
| ----------- | ------------------------------------------------------------------------------------------------------------------ | :------: | ----------- |
| name        | string                                                                                                             |     ✔    |             |
| permissions | list of string                                                                                                     |     ✔    |             |
| policy\_id  | string                                                                                                             |     ✔    |             |
| labels      | [google.protobuf.ListValue](https://developers.google.com/protocol-buffers/docs/reference/overview)                |     ✘    |             |
| tags        | [google.protobuf.Struct](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/struct.proto) |     ✘    |             |
| project\_id | string                                                                                                             |     ✘    |             |
| domain\_id  | string                                                                                                             |     ✔    |             |

### GetRepositoryPolicyRequest

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

### PoliciesInfo

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

### PolicyInfo

| Field            | Type                                                                                                               | Description         |
| ---------------- | ------------------------------------------------------------------------------------------------------------------ | ------------------- |
| policy\_id       | string                                                                                                             |                     |
| name             | string                                                                                                             |                     |
| state            | <ul><li>NONE</li><li>ENABLED</li><li>DISABLED</li></ul>                                                            |                     |
| permissions      | list of string                                                                                                     | list of permissions |
| labels           | [google.protobuf.ListValue](https://developers.google.com/protocol-buffers/docs/reference/overview)                | list of labels      |
| tags             | [google.protobuf.Struct](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/struct.proto) |                     |
| repository\_info | [RepositoryInfo](#repositoryinfo)                                                                                  |                     |
| project\_id      | string                                                                                                             |                     |
| domain\_id       | string                                                                                                             |                     |
| created\_at      | string                                                                                                             |                     |
| updated\_at      | string                                                                                                             |                     |

### PolicyQuery

| Field          | Type                                                                                               | Required | Description |
| -------------- | -------------------------------------------------------------------------------------------------- | -------- | ----------- |
| query          | [spaceone.api.core.v1.Query](https://spaceone-dev.gitbook.io/api-reference/common-v1/search-query) | ✘        |             |
| policy\_id     | string                                                                                             | ✘        |             |
| name           | string                                                                                             | ✘        |             |
| project\_id    | string                                                                                             | ✘        |             |
| repository\_id | string                                                                                             | ✔        |             |
| domain\_id     | string                                                                                             | ✔        |             |
| state          | <ul><li>NONE</li><li>ENABLED</li><li>DISABLED</li></ul>                                            | ✘        |             |

### PolicyRequest

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

### PolicyStatQuery

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

### UpdatePolicyRequest

| Field       | Type                                                                                                               | Required | Description |
| ----------- | ------------------------------------------------------------------------------------------------------------------ | :------: | ----------- |
| policy\_id  | string                                                                                                             |     ✔    |             |
| name        | string                                                                                                             |     ✘    |             |
| permissions | list of string                                                                                                     |     ✘    |             |
| labels      | [google.protobuf.ListValue](https://developers.google.com/protocol-buffers/docs/reference/overview)                |     ✘    |             |
| tags        | [google.protobuf.Struct](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/struct.proto) |     ✘    |             |
| domain\_id  | string                                                                                                             |     ✔    |             |
