Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add specification for query rule test API #3029

Merged
merged 4 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 96 additions & 28 deletions output/schema/schema.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions output/schema/validation-errors.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 10 additions & 4 deletions output/typescript/types.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions specification/_json_spec/query_rules.test.json
Original file line number Diff line number Diff line change
@@ -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
}
}
}
44 changes: 44 additions & 0 deletions specification/query_rules/test/QueryRulesetTestRequest.ts
Original file line number Diff line number Diff line change
@@ -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
kderusso marked this conversation as resolved.
Show resolved Hide resolved
* @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<string, UserDefinedValue>
}
}
28 changes: 28 additions & 0 deletions specification/query_rules/test/QueryRulesetTestResponse.ts
Original file line number Diff line number Diff line change
@@ -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'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We recommend keeping classes that are used only once in the same file as the class that uses it - it's allowed as this is not Java!


export class Response {
body: {
total_matched_rules: integer,
matched_rules: QueryRulesetMatchedRule[]
}
}
32 changes: 32 additions & 0 deletions specification/query_rules/test/types.ts
Original file line number Diff line number Diff line change
@@ -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
}
Loading