diff --git a/CHANGELOG.md b/CHANGELOG.md index 453d4697a..9385dbda2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,7 +36,6 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Added JsonSchemaValidator, a wrapper for AJV ([#364](https://github.com/opensearch-project/opensearch-api-specification/issues/364)) - Added support for `application/cbor` responses ([#371](https://github.com/opensearch-project/opensearch-api-specification/pull/371)) - Added `/_plugins/_sql`, `close`, `explain` and `stats` ([#379](https://github.com/opensearch-project/opensearch-api-specification/pull/379)) -- Added tests for SQL namespace ([#379](https://github.com/opensearch-project/opensearch-api-specification/pull/379)) - Added support for `application/smile` responses ([#386](https://github.com/opensearch-project/opensearch-api-specification/pull/386)) - Added `doc_status`, `remote_store`, `segment_replication` and `unreferenced_file_cleanups_performed` to `SegmentStats` ([#395](https://github.com/opensearch-project/opensearch-api-specification/pull/395)) - Added `concurrent_query_*` and `search_idle_reactivate_count_total` fields to `SearchStats` ([#395](https://github.com/opensearch-project/opensearch-api-specification/pull/395)) @@ -58,7 +57,8 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Added `retry` to `tester` to support asynchronous tasks ([453](https://github.com/opensearch-project/opensearch-api-specification/pull/453)) - Added passing OPENSEARCH_JAVA_OPTS into the docker container used for tests ([#454](https://github.com/opensearch-project/opensearch-api-specification/pull/454)) - Added a warning on mulitple paths being tested in the same file ([#452](https://github.com/opensearch-project/opensearch-api-specification/pull/452)) - +- Added `/_plugins/_query/settings` ([#456](https://github.com/opensearch-project/opensearch-api-specification/pull/456)) + ### Changed - Replaced Smithy with a native OpenAPI spec ([#189](https://github.com/opensearch-project/opensearch-api-specification/issues/189)) diff --git a/spec/_superseded_operations.yaml b/spec/_superseded_operations.yaml index 768cb8a4d..2f6693133 100644 --- a/spec/_superseded_operations.yaml +++ b/spec/_superseded_operations.yaml @@ -586,7 +586,7 @@ $schema: ./json_schemas/_superseded_operations.schema.yaml operations: - POST /_opendistro/_sql/settings: - superseded_by: /_plugins/_sql/settings + superseded_by: /_plugins/_query/settings operations: - PUT /_opendistro/_sql/stats: diff --git a/spec/namespaces/sql.yaml b/spec/namespaces/sql.yaml index 0afdde2d8..aeba15e55 100644 --- a/spec/namespaces/sql.yaml +++ b/spec/namespaces/sql.yaml @@ -4,6 +4,21 @@ info: description: OpenSearch SQL API version: 1.0.0 paths: + /_plugins/_query/settings: + put: + operationId: sql.settings.0 + x-operation-group: sql.settings + x-version-added: '1.0' + description: Adds SQL settings to the standard OpenSearch cluster settings. + externalDocs: + url: https://opensearch.org/docs/latest/search-plugins/sql/settings/ + parameters: + - $ref: '#/components/parameters/sql.settings::query.format' + requestBody: + $ref: '#/components/requestBodies/sql.settings' + responses: + '200': + $ref: '#/components/responses/sql.settings@200' /_plugins/_sql: post: operationId: sql.query.0 @@ -83,13 +98,18 @@ paths: $ref: '#/components/responses/sql.post_stats@200' components: parameters: + sql.settings::query.format: + name: format + in: query + description: A short version of the Accept header, e.g. json, yaml. + schema: + type: string sql.query::query.format: name: format in: query description: A short version of the Accept header, e.g. json, yaml. schema: type: string - description: A short version of the Accept header, e.g. json, yaml. sql.query::query.sanitize: name: sanitize in: query @@ -97,14 +117,12 @@ components: schema: type: boolean default: true - description: Specifies whether to escape special characters in the results sql.explain::query.format: name: format in: query description: A short version of the Accept header, e.g. json, yaml. schema: type: string - description: A short version of the Accept header, e.g. json, yaml. sql.explain::query.sanitize: name: sanitize in: query @@ -112,14 +130,12 @@ components: schema: type: boolean default: true - description: Specifies whether to escape special characters in the results sql.close::query.format: name: format in: query description: A short version of the Accept header, e.g. json, yaml. schema: type: string - description: A short version of the Accept header, e.g. json, yaml. sql.close::query.sanitize: name: sanitize in: query @@ -127,14 +143,12 @@ components: schema: type: boolean default: true - description: Specifies whether to escape special characters in the results sql.get_stats::query.format: name: format in: query description: A short version of the Accept header, e.g. json, yaml. schema: type: string - description: A short version of the Accept header, e.g. json, yaml. sql.get_stats::query.sanitize: name: sanitize in: query @@ -142,14 +156,12 @@ components: schema: type: boolean default: true - description: Specifies whether to escape special characters in the results sql.post_stats::query.format: name: format in: query description: A short version of the Accept header, e.g. json, yaml. schema: type: string - description: A short version of the Accept header, e.g. json, yaml. sql.post_stats::query.sanitize: name: sanitize in: query @@ -157,8 +169,15 @@ components: schema: type: boolean default: true - description: Specifies whether to escape special characters in the results requestBodies: + sql.settings: + content: + application/json: + schema: + anyOf: + - $ref: '../schemas/sql._common.yaml#/components/schemas/SqlSettingsPlain' + - $ref: '../schemas/sql._common.yaml#/components/schemas/SqlSettings' + required: true sql.query: content: application/json: @@ -184,8 +203,12 @@ components: $ref: '../schemas/sql._common.yaml#/components/schemas/SqlStats' required: true responses: + sql.settings@200: + content: + application/json: + schema: + $ref: '../schemas/sql._common.yaml#/components/schemas/SqlSettingsResponse' sql.query@200: - description: '' content: application/json: schema: diff --git a/spec/schemas/sql._common.yaml b/spec/schemas/sql._common.yaml index ea1abf9f0..3d1a9600d 100644 --- a/spec/schemas/sql._common.yaml +++ b/spec/schemas/sql._common.yaml @@ -85,4 +85,86 @@ components: user: type: object execution_time: - type: object \ No newline at end of file + type: object + SqlSettings: + type: object + properties: + transient: + $ref: '#/components/schemas/Transient' + SqlSettingsPlain: + type: object + properties: + transient: + $ref: '#/components/schemas/TransientPlain' + SqlSettingsResponse: + type: object + properties: + acknowledged: + type: boolean + persistent: + type: object + transient: + $ref: '#/components/schemas/Transient' + Transient: + type: object + properties: + plugins: + $ref: '#/components/schemas/Plugins' + Plugins: + type: object + properties: + ppl: + $ref: '#/components/schemas/Ppl' + query: + $ref: '#/components/schemas/Query' + sql: + $ref: '#/components/schemas/Sql' + Ppl: + type: object + properties: + enabled: + anyOf: + - type: boolean + - type: string + Query: + type: object + properties: + memory_limit: + type: string + size_limit: + anyOf: + - type: string + - type: integer + Sql: + type: object + properties: + enabled: + anyOf: + - type: boolean + - type: string + slowlog: + anyOf: + - type: integer + - type: string + cursor: + $ref: '#/components/schemas/Cursor' + Cursor: + type: object + properties: + keep_alive: + type: string + TransientPlain: + type: object + properties: + plugins.sql.enabled: + type: boolean + plugins.ppl.enabled: + type: boolean + plugins.sql.slowlog: + type: integer + plugins.sql.cursor.keep_alive: + type: string + plugins.query.memory_limit: + type: string + plugins.query.size_limit: + type: integer \ No newline at end of file diff --git a/tests/sql/query.yaml b/tests/sql/query.yaml index 9dba20594..3111d0d64 100644 --- a/tests/sql/query.yaml +++ b/tests/sql/query.yaml @@ -17,6 +17,8 @@ chapters: - synopsis: Get SQL query path: /_plugins/_sql method: POST + parameters: + sanitize: false request_body: payload: query: 'SELECT * FROM books' diff --git a/tests/sql/settings.yaml b/tests/sql/settings.yaml new file mode 100644 index 000000000..68e5f91c7 --- /dev/null +++ b/tests/sql/settings.yaml @@ -0,0 +1,38 @@ +$schema: ../../json_schemas/test_story.schema.yaml + +description: Test updating SQL settings in OS cluster. + +chapters: + - synopsis: Update SQL settings. + path: /_plugins/_query/settings + method: PUT + request_body: + payload: + transient: + plugins: + sql: + enabled: true + slowlog: '2' + cursor: + keep_alive: 1m + ppl: + enabled: true + query: + memory_limit: '80%' + size_limit: 200 + response: + status: 200 + - synopsis: Update SQL settings with plain request body. + path: /_plugins/_query/settings + method: PUT + request_body: + payload: + transient: + plugins.sql.enabled: true + plugins.ppl.enabled: true + plugins.sql.slowlog: 2 + plugins.sql.cursor.keep_alive: 1m + plugins.query.memory_limit: '80%' + plugins.query.size_limit: 200 + response: + status: 200 \ No newline at end of file