# Schema

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

## Schema

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

| Method                | Request                                                   | Response                                                                                                           |
| --------------------- | --------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| [**create**](#create) | [CreateSchemaRequest](#createschemarequest)               | [SchemaInfo](#schemainfo)                                                                                          |
| [**update**](#update) | [UpdateSchemaRequest](#updateschemarequest)               | [SchemaInfo](#schemainfo)                                                                                          |
| [**delete**](#delete) | [SchemaRequest](#schemarequest)                           | [google.protobuf.Empty](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/empty.proto)   |
| [**get**](#get)       | [GetRepositorySchemaRequest](#getrepositoryschemarequest) | [SchemaInfo](#schemainfo)                                                                                          |
| [**list**](#list)     | [SchemaQuery](#schemaquery)                               | [SchemasInfo](#schemasinfo)                                                                                        |
| [**stat**](#stat)     | [SchemaStatQuery](#schemastatquery)                       | [google.protobuf.Struct](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/struct.proto) |

### create

> **POST** /repository/v1/schemas

| Type     | Message                                     |
| -------- | ------------------------------------------- |
| Request  | [CreateSchemaRequest](#createschemarequest) |
| Response | [SchemaInfo](#schemainfo)                   |

### update

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

> Updates a specific Schema. You can make changes in Schema settings, including `name`, `schema`, `labels`, and `tags`.

| Type     | Message                                     |
| -------- | ------------------------------------------- |
| Request  | [UpdateSchemaRequest](#updateschemarequest) |
| Response | [SchemaInfo](#schemainfo)                   |

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

```
{
    "name": "slack_webhook_test",
    "schema": {},
    "labels": [],
    "tags": {},
    "domain_id": "domain-987654321098"
}
```

{% endtab %}

{% tab title="Response Example" %}

```
{
    "name": "slack_webhook_test",
    "service_type": "secret.credentials",
    "schema": {},
    "labels": [],
    "tags": {
        "description": "Slack Webhook"
    },
    "repository_info": {
        "repository_id": "repo-123456789012",
        "name": "Local",
        "repository_type": "local"
    },
    "domain_id": "domain-987654321098",
    "created_at": "2022-01-01T05:46:49.929Z",
    "updated_at": "2022-01-01T05:46:49.929Z"
}
```

{% endtab %}
{% endtabs %}

### delete

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

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

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

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

```
{
    "name": "slack_webhook"
}
```

{% endtab %}
{% endtabs %}

### get

> **GET** /repository/v1/schemas/{schema}

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

| Type     | Message                                                   |
| -------- | --------------------------------------------------------- |
| Request  | [GetRepositorySchemaRequest](#getrepositoryschemarequest) |
| Response | [SchemaInfo](#schemainfo)                                 |

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

```
{
    "name": "slack_webhook",
    "repository_id": "repo-123456789012"
}
```

{% endtab %}

{% tab title="Response Example" %}

```
{
    "name": "slack_webhook",
    "service_type": "secret.credentials",
    "schema": {},
    "labels": [],
    "tags": {
        "description": "Slack Webhook"
    },
    "repository_info": {
        "repository_id": "repo-123456789012",
        "name": "Local",
        "repository_type": "local"
    },
    "domain_id": "domain-987654321098",
    "created_at": "2022-01-01T10:20:09.064Z",
    "updated_at": "2022-01-01T10:20:09.064Z"
}
```

{% endtab %}
{% endtabs %}

### list

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

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

| Type     | Message                     |
| -------- | --------------------------- |
| Request  | [SchemaQuery](#schemaquery) |
| Response | [SchemasInfo](#schemasinfo) |

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

```
{
    "query": {},
    "name": "slack_webhook",
    "service_type": "secret.credentials",
    "repository_id": "repo-123456789012"
}
```

{% endtab %}

{% tab title="Response Example" %}

```
{
    "results": [
        {
            "name": "slack_webhook",
            "service_type": "secret.credentials",
            "schema": {},
            "labels": [],
            "tags": {
                "description": "Slack Webhook"
            },
            "repository_info": {
                "repository_id": "repo-123456789012",
                "name": "Local",
                "repository_type": "local"
            },
            "domain_id": "domain-987654321098",
            "created_at": "2022-01-01T10:20:09.064Z",
            "updated_at": "2022-01-01T10:20:09.064Z"
        }
    ],
    "total_count": 1
}
```

{% endtab %}
{% endtabs %}

### stat

> **POST** /repository/v1/schemas/stat

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

##

## Message

### CreateSchemaRequest

| Field         | Type                                                                                                               | Required | Description |
| ------------- | ------------------------------------------------------------------------------------------------------------------ | :------: | ----------- |
| name          | string                                                                                                             |     ✔    |             |
| service\_type | string                                                                                                             |     ✔    |             |
| schema\_id    | string                                                                                                             |     ✔    |             |
| schema        | [google.protobuf.Struct](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/struct.proto) |     ✔    |             |
| 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                                                                                                             |     ✔    |             |

### GetRepositorySchemaRequest

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

### SchemaInfo

| Field            | Type                                                                                                               | Description |
| ---------------- | ------------------------------------------------------------------------------------------------------------------ | ----------- |
| name             | string                                                                                                             |             |
| service\_type    | string                                                                                                             |             |
| schema\_id       | string                                                                                                             |             |
| schema           | [google.protobuf.Struct](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/struct.proto) |             |
| 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) |             |
| repository\_info | [RepositoryInfo](#repositoryinfo)                                                                                  |             |
| project\_id      | string                                                                                                             |             |
| domain\_id       | string                                                                                                             |             |
| created\_at      | string                                                                                                             |             |
| updated\_at      | string                                                                                                             |             |

### SchemaQuery

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

### SchemaRequest

| Field      | Type   | Required | Description |
| ---------- | ------ | :------: | ----------- |
| name       | string |     ✔    |             |
| domain\_id | string |     ✔    |             |
| schema\_id | string |     ✘    |             |

### SchemaStatQuery

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

### SchemasInfo

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

### UpdateSchemaRequest

| Field      | Type                                                                                                               | Required | Description |
| ---------- | ------------------------------------------------------------------------------------------------------------------ | :------: | ----------- |
| name       | string                                                                                                             |     ✔    |             |
| schema     | [google.protobuf.Struct](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/struct.proto) |     ✘    |             |
| 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                                                                                                             |     ✔    |             |
