From 9c437e58ab1098bf2045e2e8eadf7778a588e181 Mon Sep 17 00:00:00 2001 From: Michael Peterson Date: Wed, 21 Feb 2024 14:28:55 -0500 Subject: [PATCH] Add _resolve/cluster API (#2427) --- compiler/run-validations.js | 0 output/schema/schema.json | 281 +++++++++++++++++- output/typescript/types.ts | 25 ++ .../_json_spec/indices.resolve_cluster.json | 47 +++ specification/_types/Base.ts | 10 + .../resolve_cluster/ResolveClusterRequest.ts | 62 ++++ .../resolve_cluster/ResolveClusterResponse.ts | 54 ++++ 7 files changed, 476 insertions(+), 3 deletions(-) mode change 100644 => 100755 compiler/run-validations.js create mode 100644 specification/_json_spec/indices.resolve_cluster.json create mode 100644 specification/indices/resolve_cluster/ResolveClusterRequest.ts create mode 100644 specification/indices/resolve_cluster/ResolveClusterResponse.ts diff --git a/compiler/run-validations.js b/compiler/run-validations.js old mode 100644 new mode 100755 diff --git a/output/schema/schema.json b/output/schema/schema.json index 226757556c..0925fc15e7 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -6991,6 +6991,40 @@ ], "visibility": "public" }, + { + "availability": { + "stack": { + "since": "8.13.0", + "stability": "stable" + } + }, + "description": "Resolves the specified index expressions to return information about each cluster, including the local cluster, if included.", + "docUrl": "https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-resolve-cluster-api.html", + "name": "indices.resolve_cluster", + "request": { + "name": "Request", + "namespace": "indices.resolve_cluster" + }, + "requestBodyRequired": false, + "response": { + "name": "Response", + "namespace": "indices.resolve_cluster" + }, + "responseMediaType": [ + "application/json" + ], + "since": "8.13.0", + "stability": "stable", + "urls": [ + { + "methods": [ + "GET" + ], + "path": "/_resolve/cluster/{name}" + } + ], + "visibility": "public" + }, { "availability": { "serverless": { @@ -41500,6 +41534,61 @@ ], "specLocation": "_types/Base.ts#L54-L64" }, + { + "description": "Reduced (minimal) info ElasticsearchVersion", + "kind": "interface", + "name": { + "name": "ElasticsearchVersionMinInfo", + "namespace": "_types" + }, + "properties": [ + { + "name": "build_flavor", + "required": true, + "type": { + "kind": "instance_of", + "type": { + "name": "string", + "namespace": "_builtins" + } + } + }, + { + "name": "minimum_index_compatibility_version", + "required": true, + "type": { + "kind": "instance_of", + "type": { + "name": "VersionString", + "namespace": "_types" + } + } + }, + { + "name": "minimum_wire_compatibility_version", + "required": true, + "type": { + "kind": "instance_of", + "type": { + "name": "VersionString", + "namespace": "_types" + } + } + }, + { + "name": "number", + "required": true, + "type": { + "kind": "instance_of", + "type": { + "name": "string", + "namespace": "_builtins" + } + } + } + ], + "specLocation": "_types/Base.ts#L66-L74" + }, { "description": "For empty Class assignments", "kind": "interface", @@ -41671,7 +41760,7 @@ } } ], - "specLocation": "_types/Base.ts#L66-L75" + "specLocation": "_types/Base.ts#L76-L85" }, { "kind": "type_alias", @@ -43306,7 +43395,7 @@ } } ], - "specLocation": "_types/Base.ts#L77-L79" + "specLocation": "_types/Base.ts#L87-L89" }, { "attachedBehaviors": [ @@ -46608,7 +46697,7 @@ } } ], - "specLocation": "_types/Base.ts#L81-L83" + "specLocation": "_types/Base.ts#L91-L93" }, { "kind": "interface", @@ -123195,6 +123284,192 @@ }, "specLocation": "indices/reload_search_analyzers/ReloadSearchAnalyzersResponse.ts#L22-L24" }, + { + "attachedBehaviors": [ + "CommonQueryParameters" + ], + "body": { + "kind": "no_body" + }, + "description": "Resolves the specified index expressions to return information about each cluster, including\nthe local cluster, if included.\nMultiple patterns and remote clusters are supported.", + "inherits": { + "type": { + "name": "RequestBase", + "namespace": "_types" + } + }, + "kind": "request", + "name": { + "name": "Request", + "namespace": "indices.resolve_cluster" + }, + "path": [ + { + "description": "Comma-separated name(s) or index pattern(s) of the indices, aliases, and data streams to resolve.\nResources on remote clusters can be specified using the ``:`` syntax.", + "name": "name", + "required": true, + "type": { + "kind": "instance_of", + "type": { + "name": "Names", + "namespace": "_types" + } + } + } + ], + "query": [ + { + "description": "If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing\nor closed indices. This behavior applies even if the request targets other open indices. For example, a request\ntargeting foo*,bar* returns an error if an index starts with foo but no index starts with bar.", + "name": "allow_no_indices", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "boolean", + "namespace": "_builtins" + } + } + }, + { + "description": "Type of index that wildcard patterns can match.\nIf the request can target data streams, this argument determines whether wildcard expressions match hidden data streams.\nSupports comma-separated values, such as `open,hidden`.\nValid values are: `all`, `open`, `closed`, `hidden`, `none`.", + "name": "expand_wildcards", + "required": false, + "serverDefault": "open", + "type": { + "kind": "instance_of", + "type": { + "name": "ExpandWildcards", + "namespace": "_types" + } + } + }, + { + "description": "If true, concrete, expanded or aliased indices are ignored when frozen. Defaults to false.", + "name": "ignore_throttled", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "boolean", + "namespace": "_builtins" + } + } + }, + { + "description": "If false, the request returns an error if it targets a missing or closed index. Defaults to false.", + "name": "ignore_unavailable", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "boolean", + "namespace": "_builtins" + } + } + } + ], + "specLocation": "indices/resolve_cluster/ResolveClusterRequest.ts#L23-L62" + }, + { + "description": "Provides information about each cluster request relevant to doing a cross-cluster search.", + "kind": "interface", + "name": { + "name": "ResolveClusterInfo", + "namespace": "indices.resolve_cluster" + }, + "properties": [ + { + "description": "Whether the remote cluster is connected to the local (querying) cluster.", + "name": "connected", + "required": true, + "type": { + "kind": "instance_of", + "type": { + "name": "boolean", + "namespace": "_builtins" + } + } + }, + { + "description": "The skip_unavailable setting for a remote cluster.", + "name": "skip_unavailable", + "required": true, + "type": { + "kind": "instance_of", + "type": { + "name": "boolean", + "namespace": "_builtins" + } + } + }, + { + "description": "Whether the index expression provided in the request matches any indices, aliases or data streams\non the cluster.", + "name": "matching_indices", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "boolean", + "namespace": "_builtins" + } + } + }, + { + "description": "Provides error messages that are likely to occur if you do a search with this index expression\non the specified cluster (e.g., lack of security privileges to query an index).", + "name": "error", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "string", + "namespace": "_builtins" + } + } + }, + { + "description": "Provides version information about the cluster.", + "name": "version", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "ElasticsearchVersionMinInfo", + "namespace": "_types" + } + } + } + ], + "specLocation": "indices/resolve_cluster/ResolveClusterResponse.ts#L28-L54" + }, + { + "body": { + "kind": "value", + "value": { + "key": { + "kind": "instance_of", + "type": { + "name": "ClusterAlias", + "namespace": "_types" + } + }, + "kind": "dictionary_of", + "singleKey": false, + "value": { + "kind": "instance_of", + "type": { + "name": "ResolveClusterInfo", + "namespace": "indices.resolve_cluster" + } + } + } + }, + "kind": "response", + "name": { + "name": "Response", + "namespace": "indices.resolve_cluster" + }, + "specLocation": "indices/resolve_cluster/ResolveClusterResponse.ts#L24-L26" + }, { "attachedBehaviors": [ "CommonQueryParameters" diff --git a/output/typescript/types.ts b/output/typescript/types.ts index f6d3fc71e7..b029395df2 100644 --- a/output/typescript/types.ts +++ b/output/typescript/types.ts @@ -2141,6 +2141,13 @@ export interface ElasticsearchVersionInfo { number: string } +export interface ElasticsearchVersionMinInfo { + build_flavor: string + minimum_index_compatibility_version: VersionString + minimum_wire_compatibility_version: VersionString + number: string +} + export interface EmptyObject { [key: string]: never } @@ -10983,6 +10990,24 @@ export interface IndicesReloadSearchAnalyzersRequest extends RequestBase { export type IndicesReloadSearchAnalyzersResponse = IndicesReloadSearchAnalyzersReloadResult +export interface IndicesResolveClusterRequest extends RequestBase { + name: Names + allow_no_indices?: boolean + expand_wildcards?: ExpandWildcards + ignore_throttled?: boolean + ignore_unavailable?: boolean +} + +export interface IndicesResolveClusterResolveClusterInfo { + connected: boolean + skip_unavailable: boolean + matching_indices?: boolean + error?: string + version?: ElasticsearchVersionMinInfo +} + +export type IndicesResolveClusterResponse = Record + export interface IndicesResolveIndexRequest extends RequestBase { name: Names expand_wildcards?: ExpandWildcards diff --git a/specification/_json_spec/indices.resolve_cluster.json b/specification/_json_spec/indices.resolve_cluster.json new file mode 100644 index 0000000000..fddbc513a0 --- /dev/null +++ b/specification/_json_spec/indices.resolve_cluster.json @@ -0,0 +1,47 @@ +{ + "indices.resolve_cluster": { + "documentation": { + "url": "https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-resolve-cluster-api.html", + "description": "Resolves the specified index expressions to return information about each cluster, including the local cluster, if included." + }, + "stability": "stable", + "visibility": "public", + "headers": { + "accept": ["application/json"] + }, + "url": { + "paths": [ + { + "path": "/_resolve/cluster/{name}", + "methods": ["GET"], + "parts": { + "name": { + "type": "list", + "description": "A comma-separated list of cluster:index names or wildcard expressions" + } + } + } + ] + }, + "params": { + "ignore_unavailable": { + "type": "boolean", + "description": "Whether specified concrete indices should be ignored when unavailable (missing or closed)" + }, + "ignore_throttled": { + "type": "boolean", + "description": "Whether specified concrete, expanded or aliased indices should be ignored when throttled" + }, + "allow_no_indices": { + "type": "boolean", + "description": "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)" + }, + "expand_wildcards": { + "type": "enum", + "options": ["open", "closed", "hidden", "none", "all"], + "default": "open", + "description": "Whether wildcard expressions should get expanded to open or closed indices (default: open)" + } + } + } +} diff --git a/specification/_types/Base.ts b/specification/_types/Base.ts index c99081087e..8f5c13e4b4 100644 --- a/specification/_types/Base.ts +++ b/specification/_types/Base.ts @@ -63,6 +63,16 @@ export class ElasticsearchVersionInfo { number: string } +/** + * Reduced (minimal) info ElasticsearchVersion + */ +export class ElasticsearchVersionMinInfo { + build_flavor: string + minimum_index_compatibility_version: VersionString + minimum_wire_compatibility_version: VersionString + number: string +} + /** * The response returned by Elasticsearch when request execution did not succeed. */ diff --git a/specification/indices/resolve_cluster/ResolveClusterRequest.ts b/specification/indices/resolve_cluster/ResolveClusterRequest.ts new file mode 100644 index 0000000000..92564cfb86 --- /dev/null +++ b/specification/indices/resolve_cluster/ResolveClusterRequest.ts @@ -0,0 +1,62 @@ +/* + * 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 { ExpandWildcards, Names } from '@_types/common' + +/** + * Resolves the specified index expressions to return information about each cluster, including + * the local cluster, if included. + * Multiple patterns and remote clusters are supported. + * @rest_spec_name indices.resolve_cluster + * @availability stack since=8.13.0 stability=stable + */ +export interface Request extends RequestBase { + path_parts: { + /** + * Comma-separated name(s) or index pattern(s) of the indices, aliases, and data streams to resolve. + * Resources on remote clusters can be specified using the ``:`` syntax. + */ + name: Names + } + query_parameters: { + /** + * If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing + * or closed indices. This behavior applies even if the request targets other open indices. For example, a request + * targeting foo*,bar* returns an error if an index starts with foo but no index starts with bar. + */ + allow_no_indices?: boolean // default: true + /** + * Type of index that wildcard patterns can match. + * If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. + * Supports comma-separated values, such as `open,hidden`. + * Valid values are: `all`, `open`, `closed`, `hidden`, `none`. + * @server_default open + */ + expand_wildcards?: ExpandWildcards + /** + * If true, concrete, expanded or aliased indices are ignored when frozen. Defaults to false. + */ + ignore_throttled?: boolean // default: false + /** + * If false, the request returns an error if it targets a missing or closed index. Defaults to false. + */ + ignore_unavailable?: boolean // default: false + } +} diff --git a/specification/indices/resolve_cluster/ResolveClusterResponse.ts b/specification/indices/resolve_cluster/ResolveClusterResponse.ts new file mode 100644 index 0000000000..02a8d6b5c6 --- /dev/null +++ b/specification/indices/resolve_cluster/ResolveClusterResponse.ts @@ -0,0 +1,54 @@ +/* + * 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 { ClusterAlias } from '@_types/common' +import { Dictionary } from '@spec_utils/Dictionary' +import { ElasticsearchVersionMinInfo } from '@_types/Base' + +export class Response { + body: Dictionary +} + +/** + * Provides information about each cluster request relevant to doing a cross-cluster search. + */ +export class ResolveClusterInfo { + /** + * Whether the remote cluster is connected to the local (querying) cluster. + */ + connected: boolean + /** + * The skip_unavailable setting for a remote cluster. + */ + skip_unavailable: boolean + /** + * Whether the index expression provided in the request matches any indices, aliases or data streams + * on the cluster. + */ + matching_indices?: boolean + /** + * Provides error messages that are likely to occur if you do a search with this index expression + * on the specified cluster (e.g., lack of security privileges to query an index). + */ + error?: string + /** + * Provides version information about the cluster. + */ + version?: ElasticsearchVersionMinInfo +}