diff --git a/CHANGELOG.md b/CHANGELOG.md index c34b38a77..e455a6d4f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -152,6 +152,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Changed `cluster.reroute`'s `metric` path param to use an enum of metrics ([#586](https://github.com/opensearch-project/opensearch-api-specification/pull/586)) - Changed `indices.stats`'s `metric` path param to use an enum of metrics ([#586](https://github.com/opensearch-project/opensearch-api-specification/pull/586)) - Changed `CleanupRepositoryResults`' properties to be `int64`s ([#587](https://github.com/opensearch-project/opensearch-api-specification/pull/587)) +- Added `/_list/indices` & `/_list/shards` api specs ([#613](https://github.com/opensearch-project/opensearch-api-specification/pull/613)) ### Deprecated diff --git a/spec/namespaces/list.yaml b/spec/namespaces/list.yaml new file mode 100644 index 000000000..b0dddcd86 --- /dev/null +++ b/spec/namespaces/list.yaml @@ -0,0 +1,487 @@ +openapi: 3.1.0 +info: + title: OpenSearch List API + description: OpenSearch List API. + version: 1.0.0 +paths: + /_list: + get: + operationId: list.help.0 + x-operation-group: list.help + x-version-added: '2.18' + description: Returns help for the List APIs. + externalDocs: + url: https://opensearch.org/docs/latest/api-reference/list/index/ + responses: + '200': + $ref: '#/components/responses/list.help@200' + /_list/indices: + get: + operationId: list.indices.0 + x-operation-group: list.indices + x-version-added: '2.18' + description: Returns paginated information about indexes including number of primaries and replicas, document counts, disk size. + externalDocs: + url: https://opensearch.org/docs/latest/api-reference/list/list-indices/ + parameters: + - $ref: '#/components/parameters/list.indices::query.bytes' + - $ref: '#/components/parameters/list.indices::query.cluster_manager_timeout' + - $ref: '#/components/parameters/list.indices::query.expand_wildcards' + - $ref: '#/components/parameters/list.indices::query.format' + - $ref: '#/components/parameters/list.indices::query.h' + - $ref: '#/components/parameters/list.indices::query.health' + - $ref: '#/components/parameters/list.indices::query.help' + - $ref: '#/components/parameters/list.indices::query.include_unloaded_segments' + - $ref: '#/components/parameters/list.indices::query.local' + - $ref: '#/components/parameters/list.indices::query.master_timeout' + - $ref: '#/components/parameters/list.indices::query.next_token' + - $ref: '#/components/parameters/list.indices::query.pri' + - $ref: '#/components/parameters/list.indices::query.s' + - $ref: '#/components/parameters/list.indices::query.size' + - $ref: '#/components/parameters/list.indices::query.sort' + - $ref: '#/components/parameters/list.indices::query.time' + - $ref: '#/components/parameters/list.indices::query.v' + responses: + '200': + $ref: '#/components/responses/list.indices@200' + /_list/indices/{index}: + get: + operationId: list.indices.1 + x-operation-group: list.indices + x-version-added: '2.18' + description: Returns paginated information about indexes including number of primaries and replicas, document counts, disk size. + externalDocs: + url: https://opensearch.org/docs/latest/api-reference/list/list-indices/ + parameters: + - $ref: '#/components/parameters/list.indices::path.index' + - $ref: '#/components/parameters/list.indices::query.bytes' + - $ref: '#/components/parameters/list.indices::query.cluster_manager_timeout' + - $ref: '#/components/parameters/list.indices::query.expand_wildcards' + - $ref: '#/components/parameters/list.indices::query.format' + - $ref: '#/components/parameters/list.indices::query.h' + - $ref: '#/components/parameters/list.indices::query.health' + - $ref: '#/components/parameters/list.indices::query.help' + - $ref: '#/components/parameters/list.indices::query.include_unloaded_segments' + - $ref: '#/components/parameters/list.indices::query.local' + - $ref: '#/components/parameters/list.indices::query.master_timeout' + - $ref: '#/components/parameters/list.indices::query.next_token' + - $ref: '#/components/parameters/list.indices::query.pri' + - $ref: '#/components/parameters/list.indices::query.s' + - $ref: '#/components/parameters/list.indices::query.size' + - $ref: '#/components/parameters/list.indices::query.sort' + - $ref: '#/components/parameters/list.indices::query.time' + - $ref: '#/components/parameters/list.indices::query.v' + responses: + '200': + $ref: '#/components/responses/list.indices@200' + /_list/shards: + get: + operationId: list.shards.0 + x-operation-group: list.shards + x-version-added: '2.18' + description: Returns paginated details of shard allocation on nodes. + externalDocs: + url: https://opensearch.org/docs/latest/api-reference/list/list-shards/ + parameters: + - $ref: '#/components/parameters/list.shards::query.bytes' + - $ref: '#/components/parameters/list.shards::query.cluster_manager_timeout' + - $ref: '#/components/parameters/list.shards::query.format' + - $ref: '#/components/parameters/list.shards::query.h' + - $ref: '#/components/parameters/list.shards::query.help' + - $ref: '#/components/parameters/list.shards::query.local' + - $ref: '#/components/parameters/list.shards::query.master_timeout' + - $ref: '#/components/parameters/list.shards::query.next_token' + - $ref: '#/components/parameters/list.shards::query.s' + - $ref: '#/components/parameters/list.shards::query.size' + - $ref: '#/components/parameters/list.shards::query.sort' + - $ref: '#/components/parameters/list.shards::query.time' + - $ref: '#/components/parameters/list.shards::query.v' + responses: + '200': + $ref: '#/components/responses/list.shards@200' + /_list/shards/{index}: + get: + operationId: list.shards.1 + x-operation-group: list.shards + x-version-added: '2.18' + description: Returns paginated details of shard allocation on nodes. + externalDocs: + url: https://opensearch.org/docs/latest/api-reference/list/list-shards/ + parameters: + - $ref: '#/components/parameters/list.shards::path.index' + - $ref: '#/components/parameters/list.shards::query.bytes' + - $ref: '#/components/parameters/list.shards::query.cluster_manager_timeout' + - $ref: '#/components/parameters/list.shards::query.format' + - $ref: '#/components/parameters/list.shards::query.h' + - $ref: '#/components/parameters/list.shards::query.help' + - $ref: '#/components/parameters/list.shards::query.local' + - $ref: '#/components/parameters/list.shards::query.master_timeout' + - $ref: '#/components/parameters/list.shards::query.next_token' + - $ref: '#/components/parameters/list.shards::query.s' + - $ref: '#/components/parameters/list.shards::query.size' + - $ref: '#/components/parameters/list.shards::query.sort' + - $ref: '#/components/parameters/list.shards::query.time' + - $ref: '#/components/parameters/list.shards::query.v' + responses: + '200': + $ref: '#/components/responses/list.shards@200' +components: + responses: + list.help@200: + content: + text/plain: + schema: + type: string + list.indices@200: + content: + text/plain: + schema: + type: string + application/json: + schema: + type: object + properties: + next_token: + type: ['null', string] + indices: + type: array + items: + $ref: '../schemas/cat.indices.yaml#/components/schemas/IndicesRecord' + application/yaml: + schema: + type: object + properties: + next_token: + type: ['null', string] + indices: + type: array + items: + $ref: '../schemas/cat.indices.yaml#/components/schemas/IndicesRecord' + application/cbor: + schema: + type: object + properties: + next_token: + type: ['null', string] + indices: + type: array + items: + $ref: '../schemas/cat.indices.yaml#/components/schemas/IndicesRecord' + application/smile: + schema: + type: object + properties: + next_token: + type: ['null', string] + indices: + type: array + items: + $ref: '../schemas/cat.indices.yaml#/components/schemas/IndicesRecord' + list.shards@200: + content: + text/plain: + schema: + type: string + application/json: + schema: + type: object + properties: + next_token: + type: ['null', string] + shards: + type: array + items: + $ref: '../schemas/cat.shards.yaml#/components/schemas/ShardsRecord' + application/yaml: + schema: + type: object + properties: + next_token: + type: ['null', string] + shards: + type: array + items: + $ref: '../schemas/cat.shards.yaml#/components/schemas/ShardsRecord' + application/cbor: + schema: + type: object + properties: + next_token: + type: ['null', string] + shards: + type: array + items: + $ref: '../schemas/cat.shards.yaml#/components/schemas/ShardsRecord' + application/smile: + schema: + type: object + properties: + next_token: + type: ['null', string] + shards: + type: array + items: + $ref: '../schemas/cat.shards.yaml#/components/schemas/ShardsRecord' + parameters: + list.indices::path.index: + in: path + name: index + description: |- + Comma-separated list of data streams, indexes, and aliases used to limit the request. + Supports wildcards (`*`). To target all data streams and indexes, omit this parameter or use `*` or `_all`. + required: true + schema: + $ref: '../schemas/_common.yaml#/components/schemas/Indices' + style: simple + list.indices::query.bytes: + in: query + name: bytes + description: The unit used to display byte values. + schema: + $ref: '../schemas/_common.yaml#/components/schemas/ByteUnit' + style: form + list.indices::query.cluster_manager_timeout: + name: cluster_manager_timeout + in: query + description: Operation timeout for connection to cluster-manager node. + schema: + $ref: '../schemas/_common.yaml#/components/schemas/Duration' + x-version-added: '2.0' + list.indices::query.expand_wildcards: + in: query + name: expand_wildcards + description: The type of index that wildcard patterns can match. + schema: + $ref: '../schemas/_common.yaml#/components/schemas/ExpandWildcards' + style: form + list.indices::query.format: + name: format + in: query + description: A short version of the Accept header, such as `JSON`, `YAML`. + schema: + type: string + description: A short version of the Accept header, such as `JSON`, `YAML`. + list.indices::query.h: + name: h + in: query + description: Comma-separated list of column names to display. + style: form + schema: + type: array + items: + type: string + description: Comma-separated list of column names to display. + explode: true + list.indices::query.health: + in: query + name: health + description: The health status used to limit returned indexes. By default, the response includes indexes of any health status. + schema: + $ref: '../schemas/_common.yaml#/components/schemas/HealthStatus' + style: form + list.indices::query.help: + name: help + in: query + description: Return help information. + schema: + type: boolean + default: false + description: Return help information. + list.indices::query.include_unloaded_segments: + in: query + name: include_unloaded_segments + description: If true, the response includes information from segments that are not loaded into memory. + schema: + type: boolean + default: false + style: form + list.indices::query.local: + name: local + in: query + description: Return local information, do not retrieve the state from cluster-manager node. + schema: + type: boolean + default: false + description: Return local information, do not retrieve the state from cluster-manager node. + list.indices::query.master_timeout: + name: master_timeout + in: query + description: Operation timeout for connection to cluster manager node. + schema: + $ref: '../schemas/_common.yaml#/components/schemas/Duration' + x-version-deprecated: '2.0' + x-deprecation-message: To promote inclusive language, use `cluster_manager_timeout` instead. + deprecated: true + list.indices::query.pri: + in: query + name: pri + description: If true, the response only includes information from primary shards. + schema: + type: boolean + default: false + style: form + list.indices::query.s: + name: s + in: query + description: Comma-separated list of column names or column aliases to sort by. + style: form + schema: + type: array + items: + type: string + description: Comma-separated list of column names or column aliases to sort by. + explode: true + list.indices::query.time: + in: query + name: time + description: The unit used to display time values. + schema: + $ref: '../schemas/_common.yaml#/components/schemas/TimeUnit' + style: form + list.indices::query.v: + name: v + in: query + description: Verbose mode. Display column headers. + schema: + type: boolean + default: false + description: Verbose mode. Display column headers. + list.indices::query.next_token: + name: next_token + in: query + description: Token to retrieve next page of indexes. + schema: + type: ['null', string] + description: Token to retrieve next page of indexes. + list.indices::query.size: + name: size + in: query + description: Maximum number of indexes to be displayed in a page. + schema: + type: integer + format: int32 + list.indices::query.sort: + name: sort + in: query + description: Defines order in which indexes will be displayed. Accepted values are `asc` and `desc`. If `desc`, most recently created indexes would be displayed first. + schema: + type: string + enum: + - asc + - desc + list.shards::path.index: + in: path + name: index + description: |- + A comma-separated list of data streams, indexes, and aliases used to limit the request. + Supports wildcards (`*`). + To target all data streams and indexes, omit this parameter or use `*` or `_all`. + required: true + schema: + $ref: '../schemas/_common.yaml#/components/schemas/Indices' + style: simple + list.shards::query.bytes: + in: query + name: bytes + description: The unit used to display byte values. + schema: + $ref: '../schemas/_common.yaml#/components/schemas/ByteUnit' + style: form + list.shards::query.cluster_manager_timeout: + name: cluster_manager_timeout + in: query + description: Operation timeout for connection to cluster-manager node. + schema: + $ref: '../schemas/_common.yaml#/components/schemas/Duration' + x-version-added: '2.0' + list.shards::query.format: + name: format + in: query + description: A short version of the Accept header, such as `JSON`, `YAML`. + schema: + type: string + description: A short version of the Accept header, such as `JSON`, `YAML`. + list.shards::query.h: + name: h + in: query + description: Comma-separated list of column names to display. + style: form + schema: + type: array + items: + type: string + description: Comma-separated list of column names to display. + explode: true + list.shards::query.help: + name: help + in: query + description: Return help information. + schema: + type: boolean + default: false + description: Return help information. + list.shards::query.local: + name: local + in: query + description: Return local information, do not retrieve the state from cluster-manager node. + schema: + type: boolean + default: false + description: Return local information, do not retrieve the state from cluster-manager node. + list.shards::query.master_timeout: + name: master_timeout + in: query + description: Operation timeout for connection to cluster manager node. + schema: + $ref: '../schemas/_common.yaml#/components/schemas/Duration' + x-version-deprecated: '2.0' + x-deprecation-message: To promote inclusive language, use 'cluster_manager_timeout' instead. + deprecated: true + list.shards::query.s: + name: s + in: query + description: Comma-separated list of column names or column aliases to sort by. + style: form + schema: + type: array + items: + type: string + description: Comma-separated list of column names or column aliases to sort by. + explode: true + list.shards::query.time: + name: time + in: query + description: The unit in which to display time values. + schema: + $ref: '../schemas/_common.yaml#/components/schemas/TimeUnit' + list.shards::query.v: + name: v + in: query + description: Verbose mode. Display column headers. + schema: + type: boolean + default: false + description: Verbose mode. Display column headers. + list.shards::query.next_token: + name: next_token + in: query + description: Token to retrieve next page of shards. + schema: + type: ['null', string] + description: Token to retrieve next page of shards. + list.shards::query.size: + name: size + in: query + description: Maximum number of shards to be displayed in a page. + schema: + type: integer + format: int32 + list.shards::query.sort: + name: sort + in: query + description: Defines order in which shards will be displayed. Accepted values are `asc` and `desc`. If `desc`, most recently created shards would be displayed first. + schema: + type: string + enum: + - asc + - desc \ No newline at end of file diff --git a/tests/default/list/indices.yaml b/tests/default/list/indices.yaml new file mode 100644 index 000000000..a1407f211 --- /dev/null +++ b/tests/default/list/indices.yaml @@ -0,0 +1,141 @@ +$schema: ../../../json_schemas/test_story.schema.yaml + +description: Test _list/indices endpoints. +# TODO: Re-enable in 3.0, see https://github.com/opensearch-project/opensearch-api-specification/pull/613 +version: '>= 2.18 < 3' +prologues: + - path: /{index} + method: PUT + parameters: + index: books + request: + payload: {} + - path: /{index} + method: PUT + parameters: + index: unassigned + wait_for_active_shards: 0 + request: + payload: + settings: + routing: + allocation: + require: + test: test +epilogues: + - path: /books + method: DELETE + status: [200, 404] + - path: /unassigned + method: DELETE + status: [200, 404] +chapters: + - synopsis: List information related to indexes (text/plain). + method: GET + path: /_list/indices + response: + status: 200 + content_type: text/plain + - synopsis: List information related to one index (text/plain). + method: GET + path: /_list/indices/{index} + parameters: + index: books + response: + status: 200 + content_type: text/plain + - synopsis: List information related to indexes with verbose output (v=true). + method: GET + path: /_list/indices + parameters: + v: true + response: + status: 200 + content_type: text/plain + - synopsis: List information related to indexes with headers (h=header1,header2). + method: GET + path: /_list/indices + parameters: + h: + - health + - status + response: + status: 200 + content_type: text/plain + - synopsis: List information related to indexes displaying all available headers (help=true). + method: GET + path: /_list/indices + parameters: + help: true + response: + status: 200 + content_type: text/plain + - synopsis: List information related to indexes with sorted results. + method: GET + path: /_list/indices + parameters: + s: + - status + response: + status: 200 + content_type: text/plain + - synopsis: List information related to indexes with bytes, time and all fields. + method: GET + path: /_list/indices + parameters: + format: json + bytes: b + time: s + h: + - '*' + response: + status: 200 + content_type: application/json + - synopsis: List information related to indexes with all fields. + method: GET + path: /_list/indices + parameters: + format: json + response: + status: 200 + content_type: application/json + - synopsis: List information related to indexes in different formats (format=json). + method: GET + path: /_list/indices + parameters: + format: json + response: + status: 200 + content_type: application/json + - synopsis: List information related to indexes in different formats (format=yaml). + method: GET + path: /_list/indices + parameters: + format: yaml + response: + status: 200 + content_type: application/yaml + - synopsis: List information related to indexes in different formats (format=cbor). + distributions: + excluded: + - amazon-managed + - amazon-serverless + method: GET + path: /_list/indices + parameters: + format: cbor + response: + status: 200 + content_type: application/cbor + - synopsis: List information related to indexes in different formats (format=smile). + distributions: + excluded: + - amazon-managed + - amazon-serverless + method: GET + path: /_list/indices + parameters: + format: smile + response: + status: 200 + content_type: application/smile diff --git a/tests/default/list/shards.yaml b/tests/default/list/shards.yaml new file mode 100644 index 000000000..768804c8a --- /dev/null +++ b/tests/default/list/shards.yaml @@ -0,0 +1,51 @@ +$schema: ../../../json_schemas/test_story.schema.yaml + +description: Test list/shards endpoints. +# TODO: Re-enable in 3.0, see https://github.com/opensearch-project/opensearch-api-specification/pull/613 +version: '>= 2.18 < 3' +prologues: + - path: /{index} + method: PUT + parameters: + index: games + - path: /{index} + method: PUT + parameters: + index: unassigned + wait_for_active_shards: 0 + request: + payload: + settings: + routing: + allocation: + require: + test: test +epilogues: + - path: /games + method: DELETE + status: [200, 404] + - path: /unassigned + method: DELETE + status: [200, 404] +chapters: + - synopsis: List the state of all primary and replica shards and how they are distributed. + path: /_list/shards + method: GET + parameters: + format: json + h: + - '*' + - synopsis: List the state of all primary and replica shards and how they are distributed for an index. + path: /_list/shards/{index} + method: GET + parameters: + format: json + index: + - games + bytes: kb + local: true + time: s + h: + - '*' + response: + status: 200