diff --git a/output/openapi/elasticsearch-openapi.json b/output/openapi/elasticsearch-openapi.json index 80fe6c3ad5..c6c7d0c5de 100644 --- a/output/openapi/elasticsearch-openapi.json +++ b/output/openapi/elasticsearch-openapi.json @@ -24087,22 +24087,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" ] } } @@ -24117,12 +24110,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" ] } } @@ -79786,6 +79786,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 76c3ed5f02..fdf497f6dc 100644 --- a/output/openapi/elasticsearch-serverless-openapi.json +++ b/output/openapi/elasticsearch-serverless-openapi.json @@ -14682,22 +14682,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" ] } } @@ -14712,12 +14705,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" ] } } @@ -52689,6 +52689,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 4c1ee7fcbe..e5452146bc 100644 --- a/output/schema/schema-serverless.json +++ b/output/schema/schema-serverless.json @@ -7612,7 +7612,7 @@ "name": "query_rules.put_ruleset", "request": { "name": "Request", - "namespace": "query_rules.put_ruleset" + "namespace": "query_rules.test" }, "requestBodyRequired": true, "requestMediaType": [ @@ -7620,7 +7620,7 @@ ], "response": { "name": "Response", - "namespace": "query_rules.put_ruleset" + "namespace": "query_rules.test" }, "responseMediaType": [ "application/json" @@ -34745,29 +34745,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" + } } } ] @@ -34782,7 +34774,7 @@ "kind": "request", "name": { "name": "Request", - "namespace": "query_rules.put_ruleset" + "namespace": "query_rules.test" }, "path": [ { @@ -34799,31 +34791,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": [ @@ -137467,6 +137473,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 2df7809572..0a17eba331 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -13752,6 +13752,44 @@ } ] }, + { + "availability": { + "serverless": { + "stability": "stable", + "visibility": "public" + }, + "stack": { + "since": "8.10.0", + "stability": "stable" + } + }, + "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": { + "name": "Request", + "namespace": "query_rules.test" + }, + "requestBodyRequired": true, + "requestMediaType": [ + "application/json" + ], + "response": { + "name": "Response", + "namespace": "query_rules.test" + }, + "responseMediaType": [ + "application/json" + ], + "urls": [ + { + "methods": [ + "POST" + ], + "path": "/_query_rules/{ruleset_id}/_test" + } + ] + }, { "availability": { "serverless": { @@ -183119,6 +183157,134 @@ }, "specLocation": "query_rules/put_ruleset/QueryRulesetPutResponse.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/QueryRulesetTestResponse.ts#L30-L39" + }, + { + "kind": "request", + "attachedBehaviors": [ + "CommonQueryParameters" + ], + "body": { + "kind": "properties", + "properties": [ + { + "name": "match_criteria", + "required": true, + "type": { + "kind": "dictionary_of", + "key": { + "kind": "instance_of", + "type": { + "name": "string", + "namespace": "_builtins" + } + }, + "singleKey": false, + "value": { + "kind": "user_defined_value" + } + } + } + ] + }, + "description": "Creates or updates a query ruleset.", + "inherits": { + "type": { + "name": "RequestBase", + "namespace": "_types" + } + }, + "name": { + "name": "Request", + "namespace": "query_rules.test" + }, + "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/test/QueryRulesetTestRequest.ts#L24-L44" + }, + { + "kind": "response", + "body": { + "kind": "properties", + "properties": [ + { + "name": "total_matched_rules", + "required": true, + "type": { + "kind": "instance_of", + "type": { + "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.test" + }, + "specLocation": "query_rules/test/QueryRulesetTestResponse.ts#L23-L28" + }, { "kind": "interface", "name": { diff --git a/output/typescript/types.ts b/output/typescript/types.ts index 586a24ea70..5864413f9a 100644 --- a/output/typescript/types.ts +++ b/output/typescript/types.ts @@ -17201,6 +17201,23 @@ export interface QueryRulesPutRulesetResponse { result: Result } +export interface QueryRulesTestQueryRulesetMatchedRule { + ruleset_id: Id + rule_id: Id +} + +export interface QueryRulesTestRequest extends RequestBase { + ruleset_id: Id + body?: { + match_criteria: Record + } +} + +export interface QueryRulesTestResponse { + total_matched_rules: integer + matched_rules: QueryRulesTestQueryRulesetMatchedRule[] +} + export interface RollupDateHistogramGrouping { delay?: Duration field: Field 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..78f1e493bd --- /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 { 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. + * @rest_spec_name query_rules.test + * @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..2423da3078 --- /dev/null +++ b/specification/query_rules/test/QueryRulesetTestResponse.ts @@ -0,0 +1,39 @@ +/* + * 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' +import { integer } from '@_types/Numeric' + +export class Response { + body: { + total_matched_rules: integer + matched_rules: QueryRulesetMatchedRule[] + } +} + +export class QueryRulesetMatchedRule { + /** + * Ruleset unique identifier + */ + ruleset_id: Id + /** + * Rule unique identifier within that ruleset + */ + rule_id: Id +}