From 610557a20e79cc7975a2bbc2acec110e659bf400 Mon Sep 17 00:00:00 2001 From: "Daniel (dB.) Doubrovkine" Date: Tue, 26 Nov 2024 13:12:00 -0500 Subject: [PATCH] Fixed /_index_template/_simulate*. (#691) Signed-off-by: dblock Signed-off-by: Theo N. Truong Co-authored-by: Theo N. Truong --- CHANGELOG.md | 10 +++-- spec/namespaces/indices.yaml | 23 ---------- spec/schemas/indices.simulate_template.yaml | 1 - .../indices/index_template/simulate.yaml | 44 +++++++++++++++++++ .../index_template/simulate_index.yaml | 29 ++++++++++++ 5 files changed, 79 insertions(+), 28 deletions(-) create mode 100644 tests/default/indices/index_template/simulate.yaml create mode 100644 tests/default/indices/index_template/simulate_index.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index 10e6b1d78..b3f230ac3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,23 +19,25 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Added `rename_alias_pattern` and `rename_alias_replacement` to `/_snapshot/{repository}/{snapshot}/_restore` body parameters ([#615](https://github.com/opensearch-project/opensearch-api-specification/pull/615)) - Added `resource_stats` to `TaskInfoBase` ([#692](https://github.com/opensearch-project/opensearch-api-specification/pull/692)) - Added `s` to `/_ingest/processor/grok` ([#689](https://github.com/opensearch-project/opensearch-api-specification/pull/689)) +- Added schema for security API error responses ([#646](https://github.com/opensearch-project/opensearch-api-specification/pull/646)) - Added `aggregations` to `/nodes/_usage/{metric}` requests and responses ([#615](https://github.com/opensearch-project/opensearch-api-specification/pull/615)) ### Removed - Removed unsupported `_common.mapping:SourceField`'s `mode` field and associated `_common.mapping:SourceFieldMode` enum ([#652](https://github.com/opensearch-project/opensearch-api-specification/pull/652)) - Removed unsupported `_common.mapping:DenseVectorProperty`, `_common.mapping:SparseVectorProperty`, and `_common.mapping:FlattenedProperty` ([#666](https://github.com/opensearch-project/opensearch-api-specification/pull/666)) - Removed unsupported time series dimension properties and types ([#666](https://github.com/opensearch-project/opensearch-api-specification/pull/666)) -- Removed unsupported runtime field properties (`script`/`on_script_error`) on `NumberPropertyBase` ([#666](https://github.com/opensearch-project/opensearch-api-specification/pull/666)) +- Removed unsupported `script` and `on_script_error` from `NumberPropertyBase` ([#666](https://github.com/opensearch-project/opensearch-api-specification/pull/666)) +- Removed unsupported `required` from `ppl` responses ([#646](https://github.com/opensearch-project/opensearch-api-specification/pull/646)) +- Removed invalid `externalDocs` from `flow_framework.create/update::query.use_case` ([#646](https://github.com/opensearch-project/opensearch-api-specification/pull/646)) +- Removed unsupported `cause` and `create` from `/_index_template/_simulate_index/{name}` ([#691](https://github.com/opensearch-project/opensearch-api-specification/pull/691)) +- Removed `mappings` from `required` in `indices.simulate_template#Template` ([#691](https://github.com/opensearch-project/opensearch-api-specification/pull/691)) ### Fixed - Spec passes OpenAPI 3.1.0 validations ([#646](https://github.com/opensearch-project/opensearch-api-specification/pull/646)) - Disallowed characters (`::`, `@`, and `:`) in key names are replaced with `___` on merge ([#646](https://github.com/opensearch-project/opensearch-api-specification/pull/646)) - Added missing `required` to `path` parameters ([#646](https://github.com/opensearch-project/opensearch-api-specification/pull/646)) - Added missing `schema` parent to response types ([#646](https://github.com/opensearch-project/opensearch-api-specification/pull/646)) -- Removed invalid `externalDocs` from `flow_framework.create/update::query.use_case` ([#646](https://github.com/opensearch-project/opensearch-api-specification/pull/646)) - Fixed incorrect `style` in `indices.get_mapping::query.index` ([#646](https://github.com/opensearch-project/opensearch-api-specification/pull/646)) -- Removed invalid `required` from `ppl` responses ([#646](https://github.com/opensearch-project/opensearch-api-specification/pull/646)) -- Added schema for security API error responses ([#646](https://github.com/opensearch-project/opensearch-api-specification/pull/646)) - Fixed `/{index}/_create/{id}` returning `201` ([#669](https://github.com/opensearch-project/opensearch-api-specification/pull/669)) - Fixed `ml._common.yaml#SearchModelsResponse` and `SearchModelsHitsHit` ([#672](https://github.com/opensearch-project/opensearch-api-specification/pull/672)) - Fixed `refresh` options to allow `boolean` and `string` ([#673](https://github.com/opensearch-project/opensearch-api-specification/pull/673)) diff --git a/spec/namespaces/indices.yaml b/spec/namespaces/indices.yaml index 5c35abfd8..b2b0e64de 100644 --- a/spec/namespaces/indices.yaml +++ b/spec/namespaces/indices.yaml @@ -409,9 +409,7 @@ paths: url: https://opensearch.org/docs/latest parameters: - $ref: '#/components/parameters/indices.simulate_index_template::path.name' - - $ref: '#/components/parameters/indices.simulate_index_template::query.cause' - $ref: '#/components/parameters/indices.simulate_index_template::query.cluster_manager_timeout' - - $ref: '#/components/parameters/indices.simulate_index_template::query.create' - $ref: '#/components/parameters/indices.simulate_index_template::query.master_timeout' requestBody: $ref: '#/components/requestBodies/indices.simulate_index_template' @@ -4867,14 +4865,6 @@ components: schema: $ref: '../schemas/_common.yaml#/components/schemas/Name' style: simple - indices.simulate_index_template::query.cause: - name: cause - in: query - description: User defined reason for dry-run creating the new template for simulation purposes. - schema: - type: string - default: 'false' - description: User defined reason for dry-run creating the new template for simulation purposes. indices.simulate_index_template::query.cluster_manager_timeout: name: cluster_manager_timeout in: query @@ -4882,19 +4872,6 @@ components: schema: $ref: '../schemas/_common.yaml#/components/schemas/Duration' x-version-added: '2.0' - indices.simulate_index_template::query.create: - in: query - name: create - description: |- - If `true`, the template passed in the body is only used if no existing - templates match the same index patterns. If `false`, the simulation uses - the template with the highest priority. Note that the template is not - permanently added or updated in either case; it is only used for the - simulation. - schema: - type: boolean - default: false - style: form indices.simulate_index_template::query.master_timeout: in: query name: master_timeout diff --git a/spec/schemas/indices.simulate_template.yaml b/spec/schemas/indices.simulate_template.yaml index 33e87f80b..f4d616db1 100644 --- a/spec/schemas/indices.simulate_template.yaml +++ b/spec/schemas/indices.simulate_template.yaml @@ -31,5 +31,4 @@ components: $ref: 'indices._common.yaml#/components/schemas/IndexSettings' required: - aliases - - mappings - settings diff --git a/tests/default/indices/index_template/simulate.yaml b/tests/default/indices/index_template/simulate.yaml new file mode 100644 index 000000000..4ad9c0839 --- /dev/null +++ b/tests/default/indices/index_template/simulate.yaml @@ -0,0 +1,44 @@ +$schema: ../../../../json_schemas/test_story.schema.yaml + +description: Test index configuration that would be applied by a particular index template. +epilogues: + - path: /_index_template/daily_logs + method: DELETE + status: [200, 404] +prologues: + - path: /_index_template/daily_logs + method: POST + request: + payload: + index_patterns: + - 'logs*' + priority: 0 + template: + mappings: + properties: + text: + type: text + settings: + number_of_shards: 2 + number_of_replicas: 2 +chapters: + - synopsis: Simulate a template configuration. + path: /_index_template/_simulate + method: POST + parameters: + cause: Testing. + create: false + request: + payload: + index_patterns: + - 'logs*' + priority: 1 + template: + settings: + number_of_shards: 2 + number_of_replicas: 2 + - synopsis: Get the index configuration that would be applied by the `daily_logs` index template. + path: /_index_template/_simulate/{name} + method: POST + parameters: + name: daily_logs diff --git a/tests/default/indices/index_template/simulate_index.yaml b/tests/default/indices/index_template/simulate_index.yaml new file mode 100644 index 000000000..3619d063a --- /dev/null +++ b/tests/default/indices/index_template/simulate_index.yaml @@ -0,0 +1,29 @@ +$schema: ../../../../json_schemas/test_story.schema.yaml + +description: Test index configuration that would be applied by a particular index template. +prologues: + - path: /_index_template/daily_logs + method: POST + request: + payload: + index_patterns: + - 'logs*' + priority: 0 + template: + mappings: + properties: + text: + type: text + settings: + number_of_shards: 2 + number_of_replicas: 2 +epilogues: + - path: /_index_template/daily_logs + method: DELETE + status: [200, 404] +chapters: + - synopsis: Simulate matching the `logs-today` name against the `logs*` index template. + path: /_index_template/_simulate_index/{name} + method: POST + parameters: + name: logs-today \ No newline at end of file