From 0453dbe35080bf31eebac1d75f8022667d019e9f Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Fri, 19 Jul 2024 00:14:07 +1200 Subject: [PATCH] Add variants of indices.put_alias (#434) * Add test for variants of indices.put_alias Signed-off-by: Thomas Farr * Add specs for variants of indices.put_alias Signed-off-by: Thomas Farr * Add CHANGELOG entry Signed-off-by: Thomas Farr --------- Signed-off-by: Thomas Farr Signed-off-by: Daniel (dB.) Doubrovkine Co-authored-by: Daniel (dB.) Doubrovkine --- CHANGELOG.md | 1 + spec/namespaces/indices.yaml | 132 ++++++++++++++++++++++- tests/indices/{ => aliases}/aliases.yaml | 2 +- tests/indices/aliases/put_alias.yaml | 79 ++++++++++++++ 4 files changed, 209 insertions(+), 5 deletions(-) rename tests/indices/{ => aliases}/aliases.yaml (97%) create mode 100644 tests/indices/aliases/put_alias.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index 777129425..ef6e64159 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Added tests against OpenSearch 1.3 ([#424](https://github.com/opensearch-project/opensearch-api-specification/pull/424)) - Added `is_hidden` to `/{index}/_alias/{name}` and `/{index}/_aliases/{name}` ([#429](https://github.com/opensearch-project/opensearch-api-specification/pull/429)) - Added `ignore_unmapped` to `GeoDistanceQuery` ([#427](https://github.com/opensearch-project/opensearch-api-specification/pull/427)) +- Added missing variants of `indices.put_alias` ([#434](https://github.com/opensearch-project/opensearch-api-specification/pull/434)) ### Changed diff --git a/spec/namespaces/indices.yaml b/spec/namespaces/indices.yaml index 99895bbea..f1865f021 100644 --- a/spec/namespaces/indices.yaml +++ b/spec/namespaces/indices.yaml @@ -20,6 +20,22 @@ paths: responses: '200': $ref: '#/components/responses/indices.get_alias@200' + put: + operationId: indices.put_alias.0 + x-operation-group: indices.put_alias + x-version-added: '1.0' + description: Creates or updates an alias. + externalDocs: + url: https://opensearch.org/docs/latest/im-plugin/index-alias/#create-aliases + parameters: + - $ref: '#/components/parameters/indices.put_alias::query.cluster_manager_timeout' + - $ref: '#/components/parameters/indices.put_alias::query.master_timeout' + - $ref: '#/components/parameters/indices.put_alias::query.timeout' + requestBody: + $ref: '#/components/requestBodies/indices.put_alias' + responses: + '200': + $ref: '#/components/responses/indices.put_alias@200' /_alias/{name}: get: operationId: indices.get_alias.1 @@ -53,6 +69,40 @@ paths: responses: '200': $ref: '#/components/responses/indices.exists_alias@200' + post: + operationId: indices.put_alias.1 + x-operation-group: indices.put_alias + x-version-added: '1.0' + description: Creates or updates an alias. + externalDocs: + url: https://opensearch.org/docs/latest/im-plugin/index-alias/#create-aliases + parameters: + - $ref: '#/components/parameters/indices.put_alias::path.name' + - $ref: '#/components/parameters/indices.put_alias::query.cluster_manager_timeout' + - $ref: '#/components/parameters/indices.put_alias::query.master_timeout' + - $ref: '#/components/parameters/indices.put_alias::query.timeout' + requestBody: + $ref: '#/components/requestBodies/indices.put_alias' + responses: + '200': + $ref: '#/components/responses/indices.put_alias@200' + put: + operationId: indices.put_alias.2 + x-operation-group: indices.put_alias + x-version-added: '1.0' + description: Creates or updates an alias. + externalDocs: + url: https://opensearch.org/docs/latest/im-plugin/index-alias/#create-aliases + parameters: + - $ref: '#/components/parameters/indices.put_alias::path.name' + - $ref: '#/components/parameters/indices.put_alias::query.cluster_manager_timeout' + - $ref: '#/components/parameters/indices.put_alias::query.master_timeout' + - $ref: '#/components/parameters/indices.put_alias::query.timeout' + requestBody: + $ref: '#/components/requestBodies/indices.put_alias' + responses: + '200': + $ref: '#/components/responses/indices.put_alias@200' /_aliases: post: operationId: indices.update_aliases.0 @@ -70,6 +120,41 @@ paths: responses: '200': $ref: '#/components/responses/indices.update_aliases@200' + /_aliases/{name}: + post: + operationId: indices.put_alias.3 + x-operation-group: indices.put_alias + x-version-added: '1.0' + description: Creates or updates an alias. + externalDocs: + url: https://opensearch.org/docs/latest/im-plugin/index-alias/#create-aliases + parameters: + - $ref: '#/components/parameters/indices.put_alias::path.name' + - $ref: '#/components/parameters/indices.put_alias::query.cluster_manager_timeout' + - $ref: '#/components/parameters/indices.put_alias::query.master_timeout' + - $ref: '#/components/parameters/indices.put_alias::query.timeout' + requestBody: + $ref: '#/components/requestBodies/indices.put_alias' + responses: + '200': + $ref: '#/components/responses/indices.put_alias@200' + put: + operationId: indices.put_alias.4 + x-operation-group: indices.put_alias + x-version-added: '1.0' + description: Creates or updates an alias. + externalDocs: + url: https://opensearch.org/docs/latest/im-plugin/index-alias/#create-aliases + parameters: + - $ref: '#/components/parameters/indices.put_alias::path.name' + - $ref: '#/components/parameters/indices.put_alias::query.cluster_manager_timeout' + - $ref: '#/components/parameters/indices.put_alias::query.master_timeout' + - $ref: '#/components/parameters/indices.put_alias::query.timeout' + requestBody: + $ref: '#/components/requestBodies/indices.put_alias' + responses: + '200': + $ref: '#/components/responses/indices.put_alias@200' /_analyze: get: operationId: indices.analyze.0 @@ -958,6 +1043,23 @@ paths: responses: '200': $ref: '#/components/responses/indices.get_alias@200' + put: + operationId: indices.put_alias.5 + x-operation-group: indices.put_alias + x-version-added: '1.0' + description: Creates or updates an alias. + externalDocs: + url: https://opensearch.org/docs/latest/im-plugin/index-alias/#create-aliases + parameters: + - $ref: '#/components/parameters/indices.put_alias::path.index' + - $ref: '#/components/parameters/indices.put_alias::query.cluster_manager_timeout' + - $ref: '#/components/parameters/indices.put_alias::query.master_timeout' + - $ref: '#/components/parameters/indices.put_alias::query.timeout' + requestBody: + $ref: '#/components/requestBodies/indices.put_alias' + responses: + '200': + $ref: '#/components/responses/indices.put_alias@200' /{index}/_alias/{name}: get: operationId: indices.get_alias.3 @@ -994,7 +1096,7 @@ paths: '200': $ref: '#/components/responses/indices.exists_alias@200' post: - operationId: indices.put_alias.0 + operationId: indices.put_alias.6 x-operation-group: indices.put_alias x-version-added: '1.0' description: Creates or updates an alias. @@ -1012,7 +1114,7 @@ paths: '200': $ref: '#/components/responses/indices.put_alias@200' put: - operationId: indices.put_alias.1 + operationId: indices.put_alias.7 x-operation-group: indices.put_alias x-version-added: '1.0' description: Creates or updates an alias. @@ -1045,9 +1147,27 @@ paths: responses: '200': $ref: '#/components/responses/indices.delete_alias@200' + /{index}/_aliases: + put: + operationId: indices.put_alias.8 + x-operation-group: indices.put_alias + x-version-added: '1.0' + description: Creates or updates an alias. + externalDocs: + url: https://opensearch.org/docs/latest/im-plugin/index-alias/#create-aliases + parameters: + - $ref: '#/components/parameters/indices.put_alias::path.index' + - $ref: '#/components/parameters/indices.put_alias::query.cluster_manager_timeout' + - $ref: '#/components/parameters/indices.put_alias::query.master_timeout' + - $ref: '#/components/parameters/indices.put_alias::query.timeout' + requestBody: + $ref: '#/components/requestBodies/indices.put_alias' + responses: + '200': + $ref: '#/components/responses/indices.put_alias@200' /{index}/_aliases/{name}: post: - operationId: indices.put_alias.2 + operationId: indices.put_alias.9 x-operation-group: indices.put_alias x-version-added: '1.0' description: Creates or updates an alias. @@ -1065,7 +1185,7 @@ paths: '200': $ref: '#/components/responses/indices.put_alias@200' put: - operationId: indices.put_alias.3 + operationId: indices.put_alias.10 x-operation-group: indices.put_alias x-version-added: '1.0' description: Creates or updates an alias. @@ -1845,8 +1965,12 @@ components: schema: type: object properties: + alias: + type: string filter: $ref: '../schemas/_common.query_dsl.yaml#/components/schemas/QueryContainer' + index: + type: string index_routing: $ref: '../schemas/_common.yaml#/components/schemas/Routing' is_write_index: diff --git a/tests/indices/aliases.yaml b/tests/indices/aliases/aliases.yaml similarity index 97% rename from tests/indices/aliases.yaml rename to tests/indices/aliases/aliases.yaml index 1e28a2638..e68a6a4d6 100644 --- a/tests/indices/aliases.yaml +++ b/tests/indices/aliases/aliases.yaml @@ -1,4 +1,4 @@ -$schema: ../../json_schemas/test_story.schema.yaml +$schema: ../../../json_schemas/test_story.schema.yaml description: Test aliases endpoints. epilogues: diff --git a/tests/indices/aliases/put_alias.yaml b/tests/indices/aliases/put_alias.yaml new file mode 100644 index 000000000..7dd73fe9c --- /dev/null +++ b/tests/indices/aliases/put_alias.yaml @@ -0,0 +1,79 @@ +$schema: ../../../json_schemas/test_story.schema.yaml + +description: Test put_alias variants. +epilogues: + - path: /test_index/_alias/test_alias* + method: DELETE + status: [200, 404] + - path: /test_index + method: DELETE + status: [200, 404] +prologues: + - path: /{index} + method: PUT + parameters: + index: test_index +chapters: + - synopsis: Create an alias - specifying index & alias in path. + path: /{index}/_alias/{name} + method: PUT + parameters: + index: test_index + name: test_alias + response: + status: 200 + payload: + acknowledged: true + + - synopsis: Create an alias - specifying index in path & alias in body. + path: /{index}/_alias + method: PUT + parameters: + index: test_index + request_body: + payload: + alias: test_alias_1 + response: + status: 200 + payload: + acknowledged: true + + - synopsis: Create an alias - specifying index in body & alias in path. + path: /_alias/{name} + method: PUT + parameters: + name: test_alias_2 + request_body: + payload: + index: test_index + response: + status: 200 + payload: + acknowledged: true + + - synopsis: Create an alias - specifying index & alias in body. + path: /_alias + method: PUT + request_body: + payload: + index: test_index + alias: test_alias_3 + response: + status: 200 + payload: + acknowledged: true + + - synopsis: Retrieve aliases + path: /{index}/_alias + method: GET + parameters: + index: test_index + response: + status: 200 + payload: + test_index: + aliases: + test_alias: {} + test_alias_1: {} + test_alias_2: {} + test_alias_3: {} \ No newline at end of file