From c3d4ce5a32b91ffc86c927b143728626eb10f728 Mon Sep 17 00:00:00 2001 From: Kathleen DeRusso Date: Fri, 18 Oct 2024 09:13:51 -0400 Subject: [PATCH 1/4] Add query rules tester spec --- output/schema/schema.json | 124 ++++++++++++++---- output/schema/validation-errors.json | 6 + output/typescript/types.ts | 14 +- .../_json_spec/query_rules.test.json | 32 +++++ .../test/QueryRulesetTestRequest.ts | 44 +++++++ .../test/QueryRulesetTestResponse.ts | 28 ++++ specification/query_rules/test/types.ts | 32 +++++ 7 files changed, 248 insertions(+), 32 deletions(-) create mode 100644 specification/_json_spec/query_rules.test.json create mode 100644 specification/query_rules/test/QueryRulesetTestRequest.ts create mode 100644 specification/query_rules/test/QueryRulesetTestResponse.ts create mode 100644 specification/query_rules/test/types.ts diff --git a/output/schema/schema.json b/output/schema/schema.json index 4cde7b6104..826970629a 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -13721,7 +13721,7 @@ "name": "query_rules.put_ruleset", "request": { "name": "Request", - "namespace": "query_rules.put_ruleset" + "namespace": "query_rules.test" }, "requestBodyRequired": true, "requestMediaType": [ @@ -13729,7 +13729,7 @@ ], "response": { "name": "Response", - "namespace": "query_rules.put_ruleset" + "namespace": "query_rules.test" }, "responseMediaType": [ "application/json" @@ -13743,6 +13743,34 @@ } ] }, + { + "availability": { + "stack": { + "stability": "experimental", + "visibility": "public" + } + }, + "description": "Tests a query ruleset to identify the rules that would match input criteria", + "docUrl": "https://www.elastic.co/guide/en/elasticsearch/reference/master/test-query-ruleset.html", + "name": "query_rules.test", + "request": null, + "requestBodyRequired": true, + "requestMediaType": [ + "application/json" + ], + "response": null, + "responseMediaType": [ + "application/json" + ], + "urls": [ + { + "methods": [ + "POST" + ], + "path": "/_query_rules/{ruleset_id}/_test" + } + ] + }, { "availability": { "serverless": { @@ -182668,6 +182696,40 @@ }, "specLocation": "query_rules/put_rule/QueryRulePutResponse.ts#L22-L26" }, + { + "kind": "interface", + "name": { + "name": "QueryRulesetMatchedRule", + "namespace": "query_rules.test" + }, + "properties": [ + { + "description": "Ruleset unique identifier", + "name": "ruleset_id", + "required": true, + "type": { + "kind": "instance_of", + "type": { + "name": "Id", + "namespace": "_types" + } + } + }, + { + "description": "Rule unique identifier within that ruleset", + "name": "rule_id", + "required": true, + "type": { + "kind": "instance_of", + "type": { + "name": "Id", + "namespace": "_types" + } + } + } + ], + "specLocation": "query_rules/test/types.ts#L23-L32" + }, { "kind": "request", "attachedBehaviors": [ @@ -182677,29 +182739,21 @@ "kind": "properties", "properties": [ { - "name": "rules", + "name": "match_criteria", "required": true, "type": { - "kind": "union_of", - "items": [ - { - "kind": "instance_of", - "type": { - "name": "QueryRule", - "namespace": "query_rules._types" - } - }, - { - "kind": "array_of", - "value": { - "kind": "instance_of", - "type": { - "name": "QueryRule", - "namespace": "query_rules._types" - } - } + "kind": "dictionary_of", + "key": { + "kind": "instance_of", + "type": { + "name": "string", + "namespace": "_builtins" } - ] + }, + "singleKey": false, + "value": { + "kind": "user_defined_value" + } } } ] @@ -182713,7 +182767,7 @@ }, "name": { "name": "Request", - "namespace": "query_rules.put_ruleset" + "namespace": "query_rules.test" }, "path": [ { @@ -182730,7 +182784,7 @@ } ], "query": [], - "specLocation": "query_rules/put_ruleset/QueryRulesetPutRequest.ts#L23-L43" + "specLocation": "query_rules/test/QueryRulesetTestRequest.ts#L24-L44" }, { "kind": "response", @@ -182738,23 +182792,37 @@ "kind": "properties", "properties": [ { - "name": "result", + "name": "total_matched_rules", "required": true, "type": { "kind": "instance_of", "type": { - "name": "Result", + "name": "integer", "namespace": "_types" } } + }, + { + "name": "matched_rules", + "required": true, + "type": { + "kind": "array_of", + "value": { + "kind": "instance_of", + "type": { + "name": "QueryRulesetMatchedRule", + "namespace": "query_rules.test" + } + } + } } ] }, "name": { "name": "Response", - "namespace": "query_rules.put_ruleset" + "namespace": "query_rules.test" }, - "specLocation": "query_rules/put_ruleset/QueryRulesetPutResponse.ts#L22-L26" + "specLocation": "query_rules/test/QueryRulesetTestResponse.ts#L23-L28" }, { "kind": "interface", diff --git a/output/schema/validation-errors.json b/output/schema/validation-errors.json index 6b40b6b077..957951e126 100644 --- a/output/schema/validation-errors.json +++ b/output/schema/validation-errors.json @@ -1023,6 +1023,12 @@ ], "response": [] }, + "query_rules.test": { + "request": [ + "Missing request & response" + ], + "response": [] + }, "reindex": { "request": [ "Request: query parameter 'require_alias' does not exist in the json spec", diff --git a/output/typescript/types.ts b/output/typescript/types.ts index 331bf98a45..2b9384963f 100644 --- a/output/typescript/types.ts +++ b/output/typescript/types.ts @@ -17191,15 +17191,21 @@ export interface QueryRulesPutRuleResponse { result: Result } -export interface QueryRulesPutRulesetRequest extends RequestBase { +export interface QueryRulesTestQueryRulesetMatchedRule { + ruleset_id: Id + rule_id: Id +} + +export interface QueryRulesTestRequest extends RequestBase { ruleset_id: Id body?: { - rules: QueryRulesQueryRule | QueryRulesQueryRule[] + match_criteria: Record } } -export interface QueryRulesPutRulesetResponse { - result: Result +export interface QueryRulesTestResponse { + total_matched_rules: integer + matched_rules: QueryRulesTestQueryRulesetMatchedRule[] } export interface RollupDateHistogramGrouping { diff --git a/specification/_json_spec/query_rules.test.json b/specification/_json_spec/query_rules.test.json new file mode 100644 index 0000000000..43167c765b --- /dev/null +++ b/specification/_json_spec/query_rules.test.json @@ -0,0 +1,32 @@ +{ + "query_rules.test": { + "documentation": { + "url": "https://www.elastic.co/guide/en/elasticsearch/reference/master/test-query-ruleset.html", + "description": "Tests a query ruleset to identify the rules that would match input criteria" + }, + "stability": "experimental", + "visibility": "public", + "headers": { + "accept": ["application/json"], + "content_type": ["application/json"] + }, + "url": { + "paths": [ + { + "path": "/_query_rules/{ruleset_id}/_test", + "methods": ["POST"], + "parts": { + "ruleset_id": { + "type": "string", + "description": "The unique identifier of the ruleset to test." + } + } + } + ] + }, + "body": { + "description": "The match criteria to test against the ruleset", + "required": true + } + } +} diff --git a/specification/query_rules/test/QueryRulesetTestRequest.ts b/specification/query_rules/test/QueryRulesetTestRequest.ts new file mode 100644 index 0000000000..b13ae03cb8 --- /dev/null +++ b/specification/query_rules/test/QueryRulesetTestRequest.ts @@ -0,0 +1,44 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +import { RequestBase } from '@_types/Base' +import { Id } from '@_types/common' +import { Dictionary } from '@spec_utils/Dictionary' +import { UserDefinedValue } from '@spec_utils/UserDefinedValue' + +/** + * Creates or updates a query ruleset. + * @rest_spec_name query_rules.put_ruleset + * @availability stack since=8.10.0 stability=stable + * @availability serverless stability=stable visibility=public + */ +export interface Request extends RequestBase { + path_parts: { + /** + * The unique identifier of the query ruleset to be created or updated + */ + ruleset_id: Id + } + /** + * The criteria we're testing for + */ + /** @codegen_name match_criteria */ + body: { + match_criteria: Dictionary + } +} diff --git a/specification/query_rules/test/QueryRulesetTestResponse.ts b/specification/query_rules/test/QueryRulesetTestResponse.ts new file mode 100644 index 0000000000..7bc7df6ced --- /dev/null +++ b/specification/query_rules/test/QueryRulesetTestResponse.ts @@ -0,0 +1,28 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { integer } from '@_types/Numeric' +import { QueryRulesetMatchedRule } from './types' + +export class Response { + body: { + total_matched_rules: integer, + matched_rules: QueryRulesetMatchedRule[] + } +} diff --git a/specification/query_rules/test/types.ts b/specification/query_rules/test/types.ts new file mode 100644 index 0000000000..0394c95fa0 --- /dev/null +++ b/specification/query_rules/test/types.ts @@ -0,0 +1,32 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +import { Dictionary } from '@spec_utils/Dictionary' +import { Id } from '@_types/common' +import { integer } from '@_types/Numeric' + +export class QueryRulesetMatchedRule { + /** + * Ruleset unique identifier + */ + ruleset_id: Id + /** + * Rule unique identifier within that ruleset + */ + rule_id: Id +} From 3e94d2b37ef11f8a4973bbc9b64385ced6cbb5ea Mon Sep 17 00:00:00 2001 From: Laura Trotta Date: Fri, 18 Oct 2024 15:58:59 +0200 Subject: [PATCH 2/4] code style + output --- output/openapi/elasticsearch-openapi.json | 47 +++++---- .../elasticsearch-serverless-openapi.json | 47 +++++---- output/schema/schema-serverless.json | 96 +++++++++++++------ output/schema/schema.json | 2 +- .../test/QueryRulesetTestRequest.ts | 4 +- .../test/QueryRulesetTestResponse.ts | 2 +- specification/query_rules/test/types.ts | 2 - 7 files changed, 134 insertions(+), 66 deletions(-) diff --git a/output/openapi/elasticsearch-openapi.json b/output/openapi/elasticsearch-openapi.json index 6a8fc58e20..aa31bfd388 100644 --- a/output/openapi/elasticsearch-openapi.json +++ b/output/openapi/elasticsearch-openapi.json @@ -24049,22 +24049,15 @@ "schema": { "type": "object", "properties": { - "rules": { - "oneOf": [ - { - "$ref": "#/components/schemas/query_rules._types:QueryRule" - }, - { - "type": "array", - "items": { - "$ref": "#/components/schemas/query_rules._types:QueryRule" - } - } - ] + "match_criteria": { + "type": "object", + "additionalProperties": { + "type": "object" + } } }, "required": [ - "rules" + "match_criteria" ] } } @@ -24079,12 +24072,19 @@ "schema": { "type": "object", "properties": { - "result": { - "$ref": "#/components/schemas/_types:Result" + "total_matched_rules": { + "type": "number" + }, + "matched_rules": { + "type": "array", + "items": { + "$ref": "#/components/schemas/query_rules.test:QueryRulesetMatchedRule" + } } }, "required": [ - "result" + "total_matched_rules", + "matched_rules" ] } } @@ -79731,6 +79731,21 @@ "rule_criteria_types_counts" ] }, + "query_rules.test:QueryRulesetMatchedRule": { + "type": "object", + "properties": { + "ruleset_id": { + "$ref": "#/components/schemas/_types:Id" + }, + "rule_id": { + "$ref": "#/components/schemas/_types:Id" + } + }, + "required": [ + "ruleset_id", + "rule_id" + ] + }, "_global.rank_eval:RankEvalRequestItem": { "type": "object", "properties": { diff --git a/output/openapi/elasticsearch-serverless-openapi.json b/output/openapi/elasticsearch-serverless-openapi.json index cf6a85e3b5..5417115b9e 100644 --- a/output/openapi/elasticsearch-serverless-openapi.json +++ b/output/openapi/elasticsearch-serverless-openapi.json @@ -14665,22 +14665,15 @@ "schema": { "type": "object", "properties": { - "rules": { - "oneOf": [ - { - "$ref": "#/components/schemas/query_rules._types:QueryRule" - }, - { - "type": "array", - "items": { - "$ref": "#/components/schemas/query_rules._types:QueryRule" - } - } - ] + "match_criteria": { + "type": "object", + "additionalProperties": { + "type": "object" + } } }, "required": [ - "rules" + "match_criteria" ] } } @@ -14695,12 +14688,19 @@ "schema": { "type": "object", "properties": { - "result": { - "$ref": "#/components/schemas/_types:Result" + "total_matched_rules": { + "type": "number" + }, + "matched_rules": { + "type": "array", + "items": { + "$ref": "#/components/schemas/query_rules.test:QueryRulesetMatchedRule" + } } }, "required": [ - "result" + "total_matched_rules", + "matched_rules" ] } } @@ -52749,6 +52749,21 @@ "rule_criteria_types_counts" ] }, + "query_rules.test:QueryRulesetMatchedRule": { + "type": "object", + "properties": { + "ruleset_id": { + "$ref": "#/components/schemas/_types:Id" + }, + "rule_id": { + "$ref": "#/components/schemas/_types:Id" + } + }, + "required": [ + "ruleset_id", + "rule_id" + ] + }, "_global.rank_eval:RankEvalRequestItem": { "type": "object", "properties": { diff --git a/output/schema/schema-serverless.json b/output/schema/schema-serverless.json index 547bcd2fc0..c8c8965220 100644 --- a/output/schema/schema-serverless.json +++ b/output/schema/schema-serverless.json @@ -7609,7 +7609,7 @@ "name": "query_rules.put_ruleset", "request": { "name": "Request", - "namespace": "query_rules.put_ruleset" + "namespace": "query_rules.test" }, "requestBodyRequired": true, "requestMediaType": [ @@ -7617,7 +7617,7 @@ ], "response": { "name": "Response", - "namespace": "query_rules.put_ruleset" + "namespace": "query_rules.test" }, "responseMediaType": [ "application/json" @@ -34737,29 +34737,21 @@ "kind": "properties", "properties": [ { - "name": "rules", + "name": "match_criteria", "required": true, "type": { - "items": [ - { - "kind": "instance_of", - "type": { - "name": "QueryRule", - "namespace": "query_rules._types" - } - }, - { - "kind": "array_of", - "value": { - "kind": "instance_of", - "type": { - "name": "QueryRule", - "namespace": "query_rules._types" - } - } + "key": { + "kind": "instance_of", + "type": { + "name": "string", + "namespace": "_builtins" } - ], - "kind": "union_of" + }, + "kind": "dictionary_of", + "singleKey": false, + "value": { + "kind": "user_defined_value" + } } } ] @@ -34774,7 +34766,7 @@ "kind": "request", "name": { "name": "Request", - "namespace": "query_rules.put_ruleset" + "namespace": "query_rules.test" }, "path": [ { @@ -34791,31 +34783,45 @@ } ], "query": [], - "specLocation": "query_rules/put_ruleset/QueryRulesetPutRequest.ts#L23-L43" + "specLocation": "query_rules/test/QueryRulesetTestRequest.ts#L24-L44" }, { "body": { "kind": "properties", "properties": [ { - "name": "result", + "name": "total_matched_rules", "required": true, "type": { "kind": "instance_of", "type": { - "name": "Result", + "name": "integer", "namespace": "_types" } } + }, + { + "name": "matched_rules", + "required": true, + "type": { + "kind": "array_of", + "value": { + "kind": "instance_of", + "type": { + "name": "QueryRulesetMatchedRule", + "namespace": "query_rules.test" + } + } + } } ] }, "kind": "response", "name": { "name": "Response", - "namespace": "query_rules.put_ruleset" + "namespace": "query_rules.test" }, - "specLocation": "query_rules/put_ruleset/QueryRulesetPutResponse.ts#L22-L26" + "specLocation": "query_rules/test/QueryRulesetTestResponse.ts#L23-L28" }, { "attachedBehaviors": [ @@ -137182,6 +137188,40 @@ ], "specLocation": "query_rules/list_rulesets/types.ts#L23-L37" }, + { + "kind": "interface", + "name": { + "name": "QueryRulesetMatchedRule", + "namespace": "query_rules.test" + }, + "properties": [ + { + "description": "Ruleset unique identifier", + "name": "ruleset_id", + "required": true, + "type": { + "kind": "instance_of", + "type": { + "name": "Id", + "namespace": "_types" + } + } + }, + { + "description": "Rule unique identifier within that ruleset", + "name": "rule_id", + "required": true, + "type": { + "kind": "instance_of", + "type": { + "name": "Id", + "namespace": "_types" + } + } + } + ], + "specLocation": "query_rules/test/types.ts#L21-L30" + }, { "kind": "interface", "name": { diff --git a/output/schema/schema.json b/output/schema/schema.json index 826970629a..1c41e550cf 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -182728,7 +182728,7 @@ } } ], - "specLocation": "query_rules/test/types.ts#L23-L32" + "specLocation": "query_rules/test/types.ts#L21-L30" }, { "kind": "request", diff --git a/specification/query_rules/test/QueryRulesetTestRequest.ts b/specification/query_rules/test/QueryRulesetTestRequest.ts index b13ae03cb8..2c61971d8d 100644 --- a/specification/query_rules/test/QueryRulesetTestRequest.ts +++ b/specification/query_rules/test/QueryRulesetTestRequest.ts @@ -16,10 +16,10 @@ * specific language governing permissions and limitations * under the License. */ -import { RequestBase } from '@_types/Base' -import { Id } from '@_types/common' import { Dictionary } from '@spec_utils/Dictionary' import { UserDefinedValue } from '@spec_utils/UserDefinedValue' +import { RequestBase } from '@_types/Base' +import { Id } from '@_types/common' /** * Creates or updates a query ruleset. diff --git a/specification/query_rules/test/QueryRulesetTestResponse.ts b/specification/query_rules/test/QueryRulesetTestResponse.ts index 7bc7df6ced..bf89b72200 100644 --- a/specification/query_rules/test/QueryRulesetTestResponse.ts +++ b/specification/query_rules/test/QueryRulesetTestResponse.ts @@ -22,7 +22,7 @@ import { QueryRulesetMatchedRule } from './types' export class Response { body: { - total_matched_rules: integer, + total_matched_rules: integer matched_rules: QueryRulesetMatchedRule[] } } diff --git a/specification/query_rules/test/types.ts b/specification/query_rules/test/types.ts index 0394c95fa0..9a230fe339 100644 --- a/specification/query_rules/test/types.ts +++ b/specification/query_rules/test/types.ts @@ -16,9 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { Dictionary } from '@spec_utils/Dictionary' import { Id } from '@_types/common' -import { integer } from '@_types/Numeric' export class QueryRulesetMatchedRule { /** From d80bd2b9533bc8bd14927cd8f6b6c6d4978b8d42 Mon Sep 17 00:00:00 2001 From: Kathleen DeRusso Date: Fri, 18 Oct 2024 10:17:00 -0400 Subject: [PATCH 3/4] Update specification/query_rules/test/QueryRulesetTestRequest.ts Co-authored-by: Quentin Pradet --- specification/query_rules/test/QueryRulesetTestRequest.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specification/query_rules/test/QueryRulesetTestRequest.ts b/specification/query_rules/test/QueryRulesetTestRequest.ts index 2c61971d8d..78f1e493bd 100644 --- a/specification/query_rules/test/QueryRulesetTestRequest.ts +++ b/specification/query_rules/test/QueryRulesetTestRequest.ts @@ -23,7 +23,7 @@ import { Id } from '@_types/common' /** * Creates or updates a query ruleset. - * @rest_spec_name query_rules.put_ruleset + * @rest_spec_name query_rules.test * @availability stack since=8.10.0 stability=stable * @availability serverless stability=stable visibility=public */ From 3cda8d4bed4734dff61570eaba7dd191d0f9ad09 Mon Sep 17 00:00:00 2001 From: Kathleen DeRusso Date: Fri, 18 Oct 2024 10:44:41 -0400 Subject: [PATCH 4/4] PR feedback --- output/schema/schema.json | 114 ++++++++++++++++-- output/schema/validation-errors.json | 6 - output/typescript/types.ts | 11 ++ .../test/QueryRulesetTestResponse.ts | 13 +- specification/query_rules/test/types.ts | 30 ----- 5 files changed, 129 insertions(+), 45 deletions(-) delete mode 100644 specification/query_rules/test/types.ts diff --git a/output/schema/schema.json b/output/schema/schema.json index 1c41e550cf..6b4b364567 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -13721,7 +13721,7 @@ "name": "query_rules.put_ruleset", "request": { "name": "Request", - "namespace": "query_rules.test" + "namespace": "query_rules.put_ruleset" }, "requestBodyRequired": true, "requestMediaType": [ @@ -13729,7 +13729,7 @@ ], "response": { "name": "Response", - "namespace": "query_rules.test" + "namespace": "query_rules.put_ruleset" }, "responseMediaType": [ "application/json" @@ -13745,20 +13745,30 @@ }, { "availability": { - "stack": { - "stability": "experimental", + "serverless": { + "stability": "stable", "visibility": "public" + }, + "stack": { + "since": "8.10.0", + "stability": "stable" } }, - "description": "Tests a query ruleset to identify the rules that would match input criteria", + "description": "Creates or updates a query ruleset.", "docUrl": "https://www.elastic.co/guide/en/elasticsearch/reference/master/test-query-ruleset.html", "name": "query_rules.test", - "request": null, + "request": { + "name": "Request", + "namespace": "query_rules.test" + }, "requestBodyRequired": true, "requestMediaType": [ "application/json" ], - "response": null, + "response": { + "name": "Response", + "namespace": "query_rules.test" + }, "responseMediaType": [ "application/json" ], @@ -182696,6 +182706,94 @@ }, "specLocation": "query_rules/put_rule/QueryRulePutResponse.ts#L22-L26" }, + { + "kind": "request", + "attachedBehaviors": [ + "CommonQueryParameters" + ], + "body": { + "kind": "properties", + "properties": [ + { + "name": "rules", + "required": true, + "type": { + "kind": "union_of", + "items": [ + { + "kind": "instance_of", + "type": { + "name": "QueryRule", + "namespace": "query_rules._types" + } + }, + { + "kind": "array_of", + "value": { + "kind": "instance_of", + "type": { + "name": "QueryRule", + "namespace": "query_rules._types" + } + } + } + ] + } + } + ] + }, + "description": "Creates or updates a query ruleset.", + "inherits": { + "type": { + "name": "RequestBase", + "namespace": "_types" + } + }, + "name": { + "name": "Request", + "namespace": "query_rules.put_ruleset" + }, + "path": [ + { + "description": "The unique identifier of the query ruleset to be created or updated", + "name": "ruleset_id", + "required": true, + "type": { + "kind": "instance_of", + "type": { + "name": "Id", + "namespace": "_types" + } + } + } + ], + "query": [], + "specLocation": "query_rules/put_ruleset/QueryRulesetPutRequest.ts#L23-L43" + }, + { + "kind": "response", + "body": { + "kind": "properties", + "properties": [ + { + "name": "result", + "required": true, + "type": { + "kind": "instance_of", + "type": { + "name": "Result", + "namespace": "_types" + } + } + } + ] + }, + "name": { + "name": "Response", + "namespace": "query_rules.put_ruleset" + }, + "specLocation": "query_rules/put_ruleset/QueryRulesetPutResponse.ts#L22-L26" + }, { "kind": "interface", "name": { @@ -182728,7 +182826,7 @@ } } ], - "specLocation": "query_rules/test/types.ts#L21-L30" + "specLocation": "query_rules/test/QueryRulesetTestResponse.ts#L30-L39" }, { "kind": "request", diff --git a/output/schema/validation-errors.json b/output/schema/validation-errors.json index 957951e126..6b40b6b077 100644 --- a/output/schema/validation-errors.json +++ b/output/schema/validation-errors.json @@ -1023,12 +1023,6 @@ ], "response": [] }, - "query_rules.test": { - "request": [ - "Missing request & response" - ], - "response": [] - }, "reindex": { "request": [ "Request: query parameter 'require_alias' does not exist in the json spec", diff --git a/output/typescript/types.ts b/output/typescript/types.ts index 2b9384963f..32bd61bb12 100644 --- a/output/typescript/types.ts +++ b/output/typescript/types.ts @@ -17191,6 +17191,17 @@ export interface QueryRulesPutRuleResponse { result: Result } +export interface QueryRulesPutRulesetRequest extends RequestBase { + ruleset_id: Id + body?: { + rules: QueryRulesQueryRule | QueryRulesQueryRule[] + } +} + +export interface QueryRulesPutRulesetResponse { + result: Result +} + export interface QueryRulesTestQueryRulesetMatchedRule { ruleset_id: Id rule_id: Id diff --git a/specification/query_rules/test/QueryRulesetTestResponse.ts b/specification/query_rules/test/QueryRulesetTestResponse.ts index bf89b72200..2423da3078 100644 --- a/specification/query_rules/test/QueryRulesetTestResponse.ts +++ b/specification/query_rules/test/QueryRulesetTestResponse.ts @@ -17,8 +17,8 @@ * under the License. */ +import { Id } from '@_types/common' import { integer } from '@_types/Numeric' -import { QueryRulesetMatchedRule } from './types' export class Response { body: { @@ -26,3 +26,14 @@ export class Response { matched_rules: QueryRulesetMatchedRule[] } } + +export class QueryRulesetMatchedRule { + /** + * Ruleset unique identifier + */ + ruleset_id: Id + /** + * Rule unique identifier within that ruleset + */ + rule_id: Id +} diff --git a/specification/query_rules/test/types.ts b/specification/query_rules/test/types.ts deleted file mode 100644 index 9a230fe339..0000000000 --- a/specification/query_rules/test/types.ts +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -import { Id } from '@_types/common' - -export class QueryRulesetMatchedRule { - /** - * Ruleset unique identifier - */ - ruleset_id: Id - /** - * Rule unique identifier within that ruleset - */ - rule_id: Id -}