diff --git a/elasticsearch/_async/client/cluster.py b/elasticsearch/_async/client/cluster.py index db807d710..990653d27 100644 --- a/elasticsearch/_async/client/cluster.py +++ b/elasticsearch/_async/client/cluster.py @@ -661,7 +661,7 @@ async def post_voting_config_exclusions( ) @_rewrite_parameters( - body_fields=("template", "allow_auto_create", "meta", "version"), + body_fields=("template", "deprecated", "meta", "version"), parameter_aliases={"_meta": "meta"}, ) async def put_component_template( @@ -669,8 +669,9 @@ async def put_component_template( *, name: str, template: t.Optional[t.Mapping[str, t.Any]] = None, - allow_auto_create: t.Optional[bool] = None, + cause: t.Optional[str] = None, create: t.Optional[bool] = None, + deprecated: t.Optional[bool] = None, error_trace: t.Optional[bool] = None, filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, human: t.Optional[bool] = None, @@ -698,13 +699,12 @@ async def put_component_template( update settings API. :param template: The template to be applied which includes mappings, settings, or aliases configuration. - :param allow_auto_create: This setting overrides the value of the `action.auto_create_index` - cluster setting. If set to `true` in a template, then indices can be automatically - created using that template even if auto-creation of indices is disabled - via `actions.auto_create_index`. If set to `false` then data streams matching - the template must always be explicitly created. + :param cause: :param create: If `true`, this request cannot replace or update existing component templates. + :param deprecated: Marks this index template as deprecated. When creating or + updating a non-deprecated index template that uses deprecated components, + Elasticsearch will emit a deprecation warning. :param master_timeout: Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. @@ -724,6 +724,8 @@ async def put_component_template( __path = f'/_component_template/{__path_parts["name"]}' __query: t.Dict[str, t.Any] = {} __body: t.Dict[str, t.Any] = body if body is not None else {} + if cause is not None: + __query["cause"] = cause if create is not None: __query["create"] = create if error_trace is not None: @@ -739,8 +741,8 @@ async def put_component_template( if not __body: if template is not None: __body["template"] = template - if allow_auto_create is not None: - __body["allow_auto_create"] = allow_auto_create + if deprecated is not None: + __body["deprecated"] = deprecated if meta is not None: __body["_meta"] = meta if version is not None: diff --git a/elasticsearch/_async/client/connector.py b/elasticsearch/_async/client/connector.py index 8cdebdb19..c2b7c069e 100644 --- a/elasticsearch/_async/client/connector.py +++ b/elasticsearch/_async/client/connector.py @@ -486,6 +486,262 @@ async def put( path_parts=__path_parts, ) + @_rewrite_parameters() + async def sync_job_cancel( + self, + *, + connector_sync_job_id: str, + error_trace: t.Optional[bool] = None, + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, + human: t.Optional[bool] = None, + pretty: t.Optional[bool] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Cancels a connector sync job. + + ``_ + + :param connector_sync_job_id: The unique identifier of the connector sync job + """ + if connector_sync_job_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'connector_sync_job_id'") + __path_parts: t.Dict[str, str] = { + "connector_sync_job_id": _quote(connector_sync_job_id) + } + __path = ( + f'/_connector/_sync_job/{__path_parts["connector_sync_job_id"]}/_cancel' + ) + __query: t.Dict[str, t.Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + __headers = {"accept": "application/json"} + return await self.perform_request( # type: ignore[return-value] + "PUT", + __path, + params=__query, + headers=__headers, + endpoint_id="connector.sync_job_cancel", + path_parts=__path_parts, + ) + + @_rewrite_parameters() + async def sync_job_delete( + self, + *, + connector_sync_job_id: str, + error_trace: t.Optional[bool] = None, + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, + human: t.Optional[bool] = None, + pretty: t.Optional[bool] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Deletes a connector sync job. + + ``_ + + :param connector_sync_job_id: The unique identifier of the connector sync job + to be deleted + """ + if connector_sync_job_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'connector_sync_job_id'") + __path_parts: t.Dict[str, str] = { + "connector_sync_job_id": _quote(connector_sync_job_id) + } + __path = f'/_connector/_sync_job/{__path_parts["connector_sync_job_id"]}' + __query: t.Dict[str, t.Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + __headers = {"accept": "application/json"} + return await self.perform_request( # type: ignore[return-value] + "DELETE", + __path, + params=__query, + headers=__headers, + endpoint_id="connector.sync_job_delete", + path_parts=__path_parts, + ) + + @_rewrite_parameters() + async def sync_job_get( + self, + *, + connector_sync_job_id: str, + error_trace: t.Optional[bool] = None, + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, + human: t.Optional[bool] = None, + pretty: t.Optional[bool] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Returns the details about a connector sync job. + + ``_ + + :param connector_sync_job_id: The unique identifier of the connector sync job + """ + if connector_sync_job_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'connector_sync_job_id'") + __path_parts: t.Dict[str, str] = { + "connector_sync_job_id": _quote(connector_sync_job_id) + } + __path = f'/_connector/_sync_job/{__path_parts["connector_sync_job_id"]}' + __query: t.Dict[str, t.Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + __headers = {"accept": "application/json"} + return await self.perform_request( # type: ignore[return-value] + "GET", + __path, + params=__query, + headers=__headers, + endpoint_id="connector.sync_job_get", + path_parts=__path_parts, + ) + + @_rewrite_parameters( + parameter_aliases={"from": "from_"}, + ) + async def sync_job_list( + self, + *, + connector_id: t.Optional[str] = None, + error_trace: t.Optional[bool] = None, + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, + from_: t.Optional[int] = None, + human: t.Optional[bool] = None, + job_type: t.Optional[ + t.Sequence[ + t.Union["t.Literal['access_control', 'full', 'incremental']", str] + ] + ] = None, + pretty: t.Optional[bool] = None, + size: t.Optional[int] = None, + status: t.Optional[ + t.Union[ + "t.Literal['canceled', 'canceling', 'completed', 'error', 'in_progress', 'pending', 'suspended']", + str, + ] + ] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Lists all connector sync jobs. + + ``_ + + :param connector_id: A connector id to fetch connector sync jobs for + :param from_: Starting offset (default: 0) + :param job_type: A comma-separated list of job types to fetch the sync jobs for + :param size: Specifies a max number of results to get + :param status: A sync job status to fetch connector sync jobs for + """ + __path_parts: t.Dict[str, str] = {} + __path = "/_connector/_sync_job" + __query: t.Dict[str, t.Any] = {} + if connector_id is not None: + __query["connector_id"] = connector_id + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if from_ is not None: + __query["from"] = from_ + if human is not None: + __query["human"] = human + if job_type is not None: + __query["job_type"] = job_type + if pretty is not None: + __query["pretty"] = pretty + if size is not None: + __query["size"] = size + if status is not None: + __query["status"] = status + __headers = {"accept": "application/json"} + return await self.perform_request( # type: ignore[return-value] + "GET", + __path, + params=__query, + headers=__headers, + endpoint_id="connector.sync_job_list", + path_parts=__path_parts, + ) + + @_rewrite_parameters( + body_fields=("id", "job_type", "trigger_method"), + ) + async def sync_job_post( + self, + *, + id: t.Optional[str] = None, + error_trace: t.Optional[bool] = None, + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, + human: t.Optional[bool] = None, + job_type: t.Optional[ + t.Union["t.Literal['access_control', 'full', 'incremental']", str] + ] = None, + pretty: t.Optional[bool] = None, + trigger_method: t.Optional[ + t.Union["t.Literal['on_demand', 'scheduled']", str] + ] = None, + body: t.Optional[t.Dict[str, t.Any]] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Creates a connector sync job. + + ``_ + + :param id: The id of the associated connector + :param job_type: + :param trigger_method: + """ + if id is None and body is None: + raise ValueError("Empty value passed for parameter 'id'") + __path_parts: t.Dict[str, str] = {} + __path = "/_connector/_sync_job" + __query: t.Dict[str, t.Any] = {} + __body: t.Dict[str, t.Any] = body if body is not None else {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if not __body: + if id is not None: + __body["id"] = id + if job_type is not None: + __body["job_type"] = job_type + if trigger_method is not None: + __body["trigger_method"] = trigger_method + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self.perform_request( # type: ignore[return-value] + "POST", + __path, + params=__query, + headers=__headers, + body=__body, + endpoint_id="connector.sync_job_post", + path_parts=__path_parts, + ) + @_rewrite_parameters( body_fields=("api_key_id", "api_key_secret_id"), ) diff --git a/elasticsearch/_async/client/esql.py b/elasticsearch/_async/client/esql.py index d39a86f28..072bedbc1 100644 --- a/elasticsearch/_async/client/esql.py +++ b/elasticsearch/_async/client/esql.py @@ -26,13 +26,14 @@ class EsqlClient(NamespacedClient): @_rewrite_parameters( - body_fields=("query", "columnar", "filter", "locale", "params"), + body_fields=("query", "version", "columnar", "filter", "locale", "params"), ignore_deprecated_options={"params"}, ) async def query( self, *, query: t.Optional[str] = None, + version: t.Optional[t.Union["t.Literal['2024.04.01']", str]] = None, columnar: t.Optional[bool] = None, delimiter: t.Optional[str] = None, error_trace: t.Optional[bool] = None, @@ -52,6 +53,8 @@ async def query( :param query: The ES|QL query API accepts an ES|QL query string in the query parameter, runs it, and returns the results. + :param version: The version of the ES|QL language in which the "query" field + was written. :param columnar: By default, ES|QL returns results as rows. For example, FROM returns each individual document as one row. For the JSON, YAML, CBOR and smile formats, ES|QL can return the results in a columnar fashion where one @@ -68,6 +71,8 @@ async def query( """ if query is None and body is None: raise ValueError("Empty value passed for parameter 'query'") + if version is None and body is None: + raise ValueError("Empty value passed for parameter 'version'") __path_parts: t.Dict[str, str] = {} __path = "/_query" __query: t.Dict[str, t.Any] = {} @@ -87,6 +92,8 @@ async def query( if not __body: if query is not None: __body["query"] = query + if version is not None: + __body["version"] = version if columnar is not None: __body["columnar"] = columnar if filter is not None: diff --git a/elasticsearch/_async/client/indices.py b/elasticsearch/_async/client/indices.py index 31ffc82f6..b73b03dff 100644 --- a/elasticsearch/_async/client/indices.py +++ b/elasticsearch/_async/client/indices.py @@ -2868,8 +2868,11 @@ async def put_data_lifecycle( @_rewrite_parameters( body_fields=( + "allow_auto_create", "composed_of", "data_stream", + "deprecated", + "ignore_missing_component_templates", "index_patterns", "meta", "priority", @@ -2882,13 +2885,20 @@ async def put_index_template( self, *, name: str, + allow_auto_create: t.Optional[bool] = None, + cause: t.Optional[str] = None, composed_of: t.Optional[t.Sequence[str]] = None, create: t.Optional[bool] = None, data_stream: t.Optional[t.Mapping[str, t.Any]] = None, + deprecated: t.Optional[bool] = None, error_trace: t.Optional[bool] = None, filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, human: t.Optional[bool] = None, + ignore_missing_component_templates: t.Optional[t.Sequence[str]] = None, index_patterns: t.Optional[t.Union[str, t.Sequence[str]]] = None, + master_timeout: t.Optional[ + t.Union["t.Literal[-1]", "t.Literal[0]", str] + ] = None, meta: t.Optional[t.Mapping[str, t.Any]] = None, pretty: t.Optional[bool] = None, priority: t.Optional[int] = None, @@ -2902,6 +2912,13 @@ async def put_index_template( ``_ :param name: Index or template name + :param allow_auto_create: This setting overrides the value of the `action.auto_create_index` + cluster setting. If set to `true` in a template, then indices can be automatically + created using that template even if auto-creation of indices is disabled + via `actions.auto_create_index`. If set to `false`, then indices or data + streams matching the template must always be explicitly created, and may + never be automatically created. + :param cause: User defined reason for creating/updating the index template :param composed_of: An ordered list of component template names. Component templates are merged in the order specified, meaning that the last component template specified has the highest precedence. @@ -2910,7 +2927,16 @@ async def put_index_template( :param data_stream: If this object is included, the template is used to create data streams and their backing indices. Supports an empty object. Data streams require a matching index template with a `data_stream` object. + :param deprecated: Marks this index template as deprecated. When creating or + updating a non-deprecated index template that uses deprecated components, + Elasticsearch will emit a deprecation warning. + :param ignore_missing_component_templates: The configuration option ignore_missing_component_templates + can be used when an index template references a component template that might + not exist :param index_patterns: Name of the index template to create. + :param master_timeout: Period to wait for a connection to the master node. If + no response is received before the timeout expires, the request fails and + returns an error. :param meta: Optional user metadata about the index template. May have any contents. This map is not automatically generated by Elasticsearch. :param priority: Priority to determine index template precedence when a new data @@ -2929,6 +2955,8 @@ async def put_index_template( __path = f'/_index_template/{__path_parts["name"]}' __query: t.Dict[str, t.Any] = {} __body: t.Dict[str, t.Any] = body if body is not None else {} + if cause is not None: + __query["cause"] = cause if create is not None: __query["create"] = create if error_trace is not None: @@ -2937,13 +2965,23 @@ async def put_index_template( __query["filter_path"] = filter_path if human is not None: __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout if pretty is not None: __query["pretty"] = pretty if not __body: + if allow_auto_create is not None: + __body["allow_auto_create"] = allow_auto_create if composed_of is not None: __body["composed_of"] = composed_of if data_stream is not None: __body["data_stream"] = data_stream + if deprecated is not None: + __body["deprecated"] = deprecated + if ignore_missing_component_templates is not None: + __body["ignore_missing_component_templates"] = ( + ignore_missing_component_templates + ) if index_patterns is not None: __body["index_patterns"] = index_patterns if meta is not None: @@ -3250,10 +3288,10 @@ async def put_template( *, name: str, aliases: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None, + cause: t.Optional[str] = None, create: t.Optional[bool] = None, error_trace: t.Optional[bool] = None, filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, - flat_settings: t.Optional[bool] = None, human: t.Optional[bool] = None, index_patterns: t.Optional[t.Union[str, t.Sequence[str]]] = None, mappings: t.Optional[t.Mapping[str, t.Any]] = None, @@ -3263,7 +3301,6 @@ async def put_template( order: t.Optional[int] = None, pretty: t.Optional[bool] = None, settings: t.Optional[t.Mapping[str, t.Any]] = None, - timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, version: t.Optional[int] = None, body: t.Optional[t.Dict[str, t.Any]] = None, ) -> ObjectApiResponse[t.Any]: @@ -3274,9 +3311,9 @@ async def put_template( :param name: The name of the template :param aliases: Aliases for the index. + :param cause: :param create: If true, this request cannot replace or update existing index templates. - :param flat_settings: If `true`, returns settings in flat format. :param index_patterns: Array of wildcard expressions used to match the names of indices during creation. :param mappings: Mapping for fields in the index. @@ -3288,8 +3325,6 @@ async def put_template( Templates with higher 'order' values are merged later, overriding templates with lower values. :param settings: Configuration options for the index. - :param timeout: Period to wait for a response. If no response is received before - the timeout expires, the request fails and returns an error. :param version: Version number used to manage index templates externally. This number is not automatically generated by Elasticsearch. """ @@ -3299,22 +3334,20 @@ async def put_template( __path = f'/_template/{__path_parts["name"]}' __query: t.Dict[str, t.Any] = {} __body: t.Dict[str, t.Any] = body if body is not None else {} + if cause is not None: + __query["cause"] = cause if create is not None: __query["create"] = create if error_trace is not None: __query["error_trace"] = error_trace if filter_path is not None: __query["filter_path"] = filter_path - if flat_settings is not None: - __query["flat_settings"] = flat_settings if human is not None: __query["human"] = human if master_timeout is not None: __query["master_timeout"] = master_timeout if pretty is not None: __query["pretty"] = pretty - if timeout is not None: - __query["timeout"] = timeout if not __body: if aliases is not None: __body["aliases"] = aliases @@ -4004,91 +4037,37 @@ async def shrink( path_parts=__path_parts, ) - @_rewrite_parameters( - body_fields=( - "allow_auto_create", - "composed_of", - "data_stream", - "index_patterns", - "meta", - "priority", - "template", - "version", - ), - parameter_aliases={"_meta": "meta"}, - ) + @_rewrite_parameters() async def simulate_index_template( self, *, name: str, - allow_auto_create: t.Optional[bool] = None, - composed_of: t.Optional[t.Sequence[str]] = None, - create: t.Optional[bool] = None, - data_stream: t.Optional[t.Mapping[str, t.Any]] = None, error_trace: t.Optional[bool] = None, filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, human: t.Optional[bool] = None, include_defaults: t.Optional[bool] = None, - index_patterns: t.Optional[t.Union[str, t.Sequence[str]]] = None, master_timeout: t.Optional[ t.Union["t.Literal[-1]", "t.Literal[0]", str] ] = None, - meta: t.Optional[t.Mapping[str, t.Any]] = None, pretty: t.Optional[bool] = None, - priority: t.Optional[int] = None, - template: t.Optional[t.Mapping[str, t.Any]] = None, - version: t.Optional[int] = None, - body: t.Optional[t.Dict[str, t.Any]] = None, ) -> ObjectApiResponse[t.Any]: """ Simulate matching the given index name against the index templates in the system ``_ - :param name: Index or template name to simulate - :param allow_auto_create: This setting overrides the value of the `action.auto_create_index` - cluster setting. If set to `true` in a template, then indices can be automatically - created using that template even if auto-creation of indices is disabled - via `actions.auto_create_index`. If set to `false`, then indices or data - streams matching the template must always be explicitly created, and may - never be automatically created. - :param composed_of: An ordered list of component template names. Component templates - are merged in the order specified, meaning that the last component template - specified has the highest precedence. - :param create: If `true`, the template passed in the body is only used if no - existing templates match the same index patterns. If `false`, the simulation - uses the template with the highest priority. Note that the template is not - permanently added or updated in either case; it is only used for the simulation. - :param data_stream: If this object is included, the template is used to create - data streams and their backing indices. Supports an empty object. Data streams - require a matching index template with a `data_stream` object. + :param name: Name of the index to simulate :param include_defaults: If true, returns all relevant default configurations for the index template. - :param index_patterns: Array of wildcard (`*`) expressions used to match the - names of data streams and indices during creation. :param master_timeout: Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. - :param meta: Optional user metadata about the index template. May have any contents. - This map is not automatically generated by Elasticsearch. - :param priority: Priority to determine index template precedence when a new data - stream or index is created. The index template with the highest priority - is chosen. If no priority is specified the template is treated as though - it is of priority 0 (lowest priority). This number is not automatically generated - by Elasticsearch. - :param template: Template to be applied. It may optionally include an `aliases`, - `mappings`, or `settings` configuration. - :param version: Version number used to manage index templates externally. This - number is not automatically generated by Elasticsearch. """ if name in SKIP_IN_PATH: raise ValueError("Empty value passed for parameter 'name'") __path_parts: t.Dict[str, str] = {"name": _quote(name)} __path = f'/_index_template/_simulate_index/{__path_parts["name"]}' __query: t.Dict[str, t.Any] = {} - __body: t.Dict[str, t.Any] = body if body is not None else {} - if create is not None: - __query["create"] = create if error_trace is not None: __query["error_trace"] = error_trace if filter_path is not None: @@ -4101,56 +4080,55 @@ async def simulate_index_template( __query["master_timeout"] = master_timeout if pretty is not None: __query["pretty"] = pretty - if not __body: - if allow_auto_create is not None: - __body["allow_auto_create"] = allow_auto_create - if composed_of is not None: - __body["composed_of"] = composed_of - if data_stream is not None: - __body["data_stream"] = data_stream - if index_patterns is not None: - __body["index_patterns"] = index_patterns - if meta is not None: - __body["_meta"] = meta - if priority is not None: - __body["priority"] = priority - if template is not None: - __body["template"] = template - if version is not None: - __body["version"] = version - if not __body: - __body = None # type: ignore[assignment] __headers = {"accept": "application/json"} - if __body is not None: - __headers["content-type"] = "application/json" return await self.perform_request( # type: ignore[return-value] "POST", __path, params=__query, headers=__headers, - body=__body, endpoint_id="indices.simulate_index_template", path_parts=__path_parts, ) @_rewrite_parameters( - body_name="template", + body_fields=( + "allow_auto_create", + "composed_of", + "data_stream", + "deprecated", + "ignore_missing_component_templates", + "index_patterns", + "meta", + "priority", + "template", + "version", + ), + parameter_aliases={"_meta": "meta"}, ) async def simulate_template( self, *, name: t.Optional[str] = None, + allow_auto_create: t.Optional[bool] = None, + composed_of: t.Optional[t.Sequence[str]] = None, create: t.Optional[bool] = None, + data_stream: t.Optional[t.Mapping[str, t.Any]] = None, + deprecated: t.Optional[bool] = None, error_trace: t.Optional[bool] = None, filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, human: t.Optional[bool] = None, + ignore_missing_component_templates: t.Optional[t.Sequence[str]] = None, include_defaults: t.Optional[bool] = None, + index_patterns: t.Optional[t.Union[str, t.Sequence[str]]] = None, master_timeout: t.Optional[ t.Union["t.Literal[-1]", "t.Literal[0]", str] ] = None, + meta: t.Optional[t.Mapping[str, t.Any]] = None, pretty: t.Optional[bool] = None, + priority: t.Optional[int] = None, template: t.Optional[t.Mapping[str, t.Any]] = None, - body: t.Optional[t.Mapping[str, t.Any]] = None, + version: t.Optional[int] = None, + body: t.Optional[t.Dict[str, t.Any]] = None, ) -> ObjectApiResponse[t.Any]: """ Simulate resolving the given template name or body @@ -4160,23 +4138,47 @@ async def simulate_template( :param name: Name of the index template to simulate. To test a template configuration before you add it to the cluster, omit this parameter and specify the template configuration in the request body. + :param allow_auto_create: This setting overrides the value of the `action.auto_create_index` + cluster setting. If set to `true` in a template, then indices can be automatically + created using that template even if auto-creation of indices is disabled + via `actions.auto_create_index`. If set to `false`, then indices or data + streams matching the template must always be explicitly created, and may + never be automatically created. + :param composed_of: An ordered list of component template names. Component templates + are merged in the order specified, meaning that the last component template + specified has the highest precedence. :param create: If true, the template passed in the body is only used if no existing templates match the same index patterns. If false, the simulation uses the template with the highest priority. Note that the template is not permanently added or updated in either case; it is only used for the simulation. + :param data_stream: If this object is included, the template is used to create + data streams and their backing indices. Supports an empty object. Data streams + require a matching index template with a `data_stream` object. + :param deprecated: Marks this index template as deprecated. When creating or + updating a non-deprecated index template that uses deprecated components, + Elasticsearch will emit a deprecation warning. + :param ignore_missing_component_templates: The configuration option ignore_missing_component_templates + can be used when an index template references a component template that might + not exist :param include_defaults: If true, returns all relevant default configurations for the index template. + :param index_patterns: Array of wildcard (`*`) expressions used to match the + names of data streams and indices during creation. :param master_timeout: Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. - :param template: + :param meta: Optional user metadata about the index template. May have any contents. + This map is not automatically generated by Elasticsearch. + :param priority: Priority to determine index template precedence when a new data + stream or index is created. The index template with the highest priority + is chosen. If no priority is specified the template is treated as though + it is of priority 0 (lowest priority). This number is not automatically generated + by Elasticsearch. + :param template: Template to be applied. It may optionally include an `aliases`, + `mappings`, or `settings` configuration. + :param version: Version number used to manage index templates externally. This + number is not automatically generated by Elasticsearch. """ - if template is None and body is None: - raise ValueError( - "Empty value passed for parameters 'template' and 'body', one of them should be set." - ) - elif template is not None and body is not None: - raise ValueError("Cannot set both 'template' and 'body'") __path_parts: t.Dict[str, str] if name not in SKIP_IN_PATH: __path_parts = {"name": _quote(name)} @@ -4185,6 +4187,7 @@ async def simulate_template( __path_parts = {} __path = "/_index_template/_simulate" __query: t.Dict[str, t.Any] = {} + __body: t.Dict[str, t.Any] = body if body is not None else {} if create is not None: __query["create"] = create if error_trace is not None: @@ -4199,9 +4202,31 @@ async def simulate_template( __query["master_timeout"] = master_timeout if pretty is not None: __query["pretty"] = pretty - __body = template if template is not None else body if not __body: - __body = None + if allow_auto_create is not None: + __body["allow_auto_create"] = allow_auto_create + if composed_of is not None: + __body["composed_of"] = composed_of + if data_stream is not None: + __body["data_stream"] = data_stream + if deprecated is not None: + __body["deprecated"] = deprecated + if ignore_missing_component_templates is not None: + __body["ignore_missing_component_templates"] = ( + ignore_missing_component_templates + ) + if index_patterns is not None: + __body["index_patterns"] = index_patterns + if meta is not None: + __body["_meta"] = meta + if priority is not None: + __body["priority"] = priority + if template is not None: + __body["template"] = template + if version is not None: + __body["version"] = version + if not __body: + __body = None # type: ignore[assignment] __headers = {"accept": "application/json"} if __body is not None: __headers["content-type"] = "application/json" diff --git a/elasticsearch/_async/client/inference.py b/elasticsearch/_async/client/inference.py index 07e4953cf..930445616 100644 --- a/elasticsearch/_async/client/inference.py +++ b/elasticsearch/_async/client/inference.py @@ -86,13 +86,13 @@ async def delete_model( async def get_model( self, *, - inference_id: str, task_type: t.Optional[ t.Union[ "t.Literal['completion', 'rerank', 'sparse_embedding', 'text_embedding']", str, ] ] = None, + inference_id: t.Optional[str] = None, error_trace: t.Optional[bool] = None, filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, human: t.Optional[bool] = None, @@ -103,11 +103,9 @@ async def get_model( ``_ - :param inference_id: The inference Id :param task_type: The task type + :param inference_id: The inference Id """ - if inference_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'inference_id'") __path_parts: t.Dict[str, str] if task_type not in SKIP_IN_PATH and inference_id not in SKIP_IN_PATH: __path_parts = { @@ -119,7 +117,8 @@ async def get_model( __path_parts = {"inference_id": _quote(inference_id)} __path = f'/_inference/{__path_parts["inference_id"]}' else: - raise ValueError("Couldn't find a path for the given parameters") + __path_parts = {} + __path = "/_inference" __query: t.Dict[str, t.Any] = {} if error_trace is not None: __query["error_trace"] = error_trace @@ -159,6 +158,7 @@ async def inference( pretty: t.Optional[bool] = None, query: t.Optional[str] = None, task_settings: t.Optional[t.Any] = None, + timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, body: t.Optional[t.Dict[str, t.Any]] = None, ) -> ObjectApiResponse[t.Any]: """ @@ -171,6 +171,8 @@ async def inference( :param task_type: The task type :param query: Query input, required for rerank task. Not required for other tasks. :param task_settings: Optional task settings + :param timeout: Specifies the amount of time to wait for the inference request + to complete. """ if inference_id in SKIP_IN_PATH: raise ValueError("Empty value passed for parameter 'inference_id'") @@ -198,6 +200,8 @@ async def inference( __query["human"] = human if pretty is not None: __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout if not __body: if input is not None: __body["input"] = input diff --git a/elasticsearch/_async/client/security.py b/elasticsearch/_async/client/security.py index 3171ddfc8..1fecf18e8 100644 --- a/elasticsearch/_async/client/security.py +++ b/elasticsearch/_async/client/security.py @@ -1761,7 +1761,7 @@ async def has_privileges( cluster: t.Optional[ t.Sequence[ t.Union[ - "t.Literal['all', 'cancel_task', 'create_snapshot', 'grant_api_key', 'manage', 'manage_api_key', 'manage_ccr', 'manage_enrich', 'manage_ilm', 'manage_index_templates', 'manage_ingest_pipelines', 'manage_logstash_pipelines', 'manage_ml', 'manage_oidc', 'manage_own_api_key', 'manage_pipeline', 'manage_rollup', 'manage_saml', 'manage_security', 'manage_service_account', 'manage_slm', 'manage_token', 'manage_transform', 'manage_user_profile', 'manage_watcher', 'monitor', 'monitor_ml', 'monitor_rollup', 'monitor_snapshot', 'monitor_text_structure', 'monitor_transform', 'monitor_watcher', 'read_ccr', 'read_ilm', 'read_pipeline', 'read_slm', 'transport_client']", + "t.Literal['all', 'cancel_task', 'create_snapshot', 'cross_cluster_replication', 'cross_cluster_search', 'delegate_pki', 'grant_api_key', 'manage', 'manage_api_key', 'manage_autoscaling', 'manage_behavioral_analytics', 'manage_ccr', 'manage_data_frame_transforms', 'manage_data_stream_global_retention', 'manage_enrich', 'manage_ilm', 'manage_index_templates', 'manage_inference', 'manage_ingest_pipelines', 'manage_logstash_pipelines', 'manage_ml', 'manage_oidc', 'manage_own_api_key', 'manage_pipeline', 'manage_rollup', 'manage_saml', 'manage_search_application', 'manage_search_query_rules', 'manage_search_synonyms', 'manage_security', 'manage_service_account', 'manage_slm', 'manage_token', 'manage_transform', 'manage_user_profile', 'manage_watcher', 'monitor', 'monitor_data_frame_transforms', 'monitor_data_stream_global_retention', 'monitor_enrich', 'monitor_inference', 'monitor_ml', 'monitor_rollup', 'monitor_snapshot', 'monitor_text_structure', 'monitor_transform', 'monitor_watcher', 'none', 'post_behavioral_analytics_event', 'read_ccr', 'read_connector_secrets', 'read_fleet_secrets', 'read_ilm', 'read_pipeline', 'read_security', 'read_slm', 'transport_client', 'write_connector_secrets', 'write_fleet_secrets']", str, ] ] @@ -2084,7 +2084,7 @@ async def put_role( cluster: t.Optional[ t.Sequence[ t.Union[ - "t.Literal['all', 'cancel_task', 'create_snapshot', 'grant_api_key', 'manage', 'manage_api_key', 'manage_ccr', 'manage_enrich', 'manage_ilm', 'manage_index_templates', 'manage_ingest_pipelines', 'manage_logstash_pipelines', 'manage_ml', 'manage_oidc', 'manage_own_api_key', 'manage_pipeline', 'manage_rollup', 'manage_saml', 'manage_security', 'manage_service_account', 'manage_slm', 'manage_token', 'manage_transform', 'manage_user_profile', 'manage_watcher', 'monitor', 'monitor_ml', 'monitor_rollup', 'monitor_snapshot', 'monitor_text_structure', 'monitor_transform', 'monitor_watcher', 'read_ccr', 'read_ilm', 'read_pipeline', 'read_slm', 'transport_client']", + "t.Literal['all', 'cancel_task', 'create_snapshot', 'cross_cluster_replication', 'cross_cluster_search', 'delegate_pki', 'grant_api_key', 'manage', 'manage_api_key', 'manage_autoscaling', 'manage_behavioral_analytics', 'manage_ccr', 'manage_data_frame_transforms', 'manage_data_stream_global_retention', 'manage_enrich', 'manage_ilm', 'manage_index_templates', 'manage_inference', 'manage_ingest_pipelines', 'manage_logstash_pipelines', 'manage_ml', 'manage_oidc', 'manage_own_api_key', 'manage_pipeline', 'manage_rollup', 'manage_saml', 'manage_search_application', 'manage_search_query_rules', 'manage_search_synonyms', 'manage_security', 'manage_service_account', 'manage_slm', 'manage_token', 'manage_transform', 'manage_user_profile', 'manage_watcher', 'monitor', 'monitor_data_frame_transforms', 'monitor_data_stream_global_retention', 'monitor_enrich', 'monitor_inference', 'monitor_ml', 'monitor_rollup', 'monitor_snapshot', 'monitor_text_structure', 'monitor_transform', 'monitor_watcher', 'none', 'post_behavioral_analytics_event', 'read_ccr', 'read_connector_secrets', 'read_fleet_secrets', 'read_ilm', 'read_pipeline', 'read_security', 'read_slm', 'transport_client', 'write_connector_secrets', 'write_fleet_secrets']", str, ] ] diff --git a/elasticsearch/_sync/client/cluster.py b/elasticsearch/_sync/client/cluster.py index 722e4eac7..6cc0a3309 100644 --- a/elasticsearch/_sync/client/cluster.py +++ b/elasticsearch/_sync/client/cluster.py @@ -661,7 +661,7 @@ def post_voting_config_exclusions( ) @_rewrite_parameters( - body_fields=("template", "allow_auto_create", "meta", "version"), + body_fields=("template", "deprecated", "meta", "version"), parameter_aliases={"_meta": "meta"}, ) def put_component_template( @@ -669,8 +669,9 @@ def put_component_template( *, name: str, template: t.Optional[t.Mapping[str, t.Any]] = None, - allow_auto_create: t.Optional[bool] = None, + cause: t.Optional[str] = None, create: t.Optional[bool] = None, + deprecated: t.Optional[bool] = None, error_trace: t.Optional[bool] = None, filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, human: t.Optional[bool] = None, @@ -698,13 +699,12 @@ def put_component_template( update settings API. :param template: The template to be applied which includes mappings, settings, or aliases configuration. - :param allow_auto_create: This setting overrides the value of the `action.auto_create_index` - cluster setting. If set to `true` in a template, then indices can be automatically - created using that template even if auto-creation of indices is disabled - via `actions.auto_create_index`. If set to `false` then data streams matching - the template must always be explicitly created. + :param cause: :param create: If `true`, this request cannot replace or update existing component templates. + :param deprecated: Marks this index template as deprecated. When creating or + updating a non-deprecated index template that uses deprecated components, + Elasticsearch will emit a deprecation warning. :param master_timeout: Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. @@ -724,6 +724,8 @@ def put_component_template( __path = f'/_component_template/{__path_parts["name"]}' __query: t.Dict[str, t.Any] = {} __body: t.Dict[str, t.Any] = body if body is not None else {} + if cause is not None: + __query["cause"] = cause if create is not None: __query["create"] = create if error_trace is not None: @@ -739,8 +741,8 @@ def put_component_template( if not __body: if template is not None: __body["template"] = template - if allow_auto_create is not None: - __body["allow_auto_create"] = allow_auto_create + if deprecated is not None: + __body["deprecated"] = deprecated if meta is not None: __body["_meta"] = meta if version is not None: diff --git a/elasticsearch/_sync/client/connector.py b/elasticsearch/_sync/client/connector.py index 93e292e72..e4dc6838b 100644 --- a/elasticsearch/_sync/client/connector.py +++ b/elasticsearch/_sync/client/connector.py @@ -486,6 +486,262 @@ def put( path_parts=__path_parts, ) + @_rewrite_parameters() + def sync_job_cancel( + self, + *, + connector_sync_job_id: str, + error_trace: t.Optional[bool] = None, + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, + human: t.Optional[bool] = None, + pretty: t.Optional[bool] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Cancels a connector sync job. + + ``_ + + :param connector_sync_job_id: The unique identifier of the connector sync job + """ + if connector_sync_job_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'connector_sync_job_id'") + __path_parts: t.Dict[str, str] = { + "connector_sync_job_id": _quote(connector_sync_job_id) + } + __path = ( + f'/_connector/_sync_job/{__path_parts["connector_sync_job_id"]}/_cancel' + ) + __query: t.Dict[str, t.Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + __headers = {"accept": "application/json"} + return self.perform_request( # type: ignore[return-value] + "PUT", + __path, + params=__query, + headers=__headers, + endpoint_id="connector.sync_job_cancel", + path_parts=__path_parts, + ) + + @_rewrite_parameters() + def sync_job_delete( + self, + *, + connector_sync_job_id: str, + error_trace: t.Optional[bool] = None, + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, + human: t.Optional[bool] = None, + pretty: t.Optional[bool] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Deletes a connector sync job. + + ``_ + + :param connector_sync_job_id: The unique identifier of the connector sync job + to be deleted + """ + if connector_sync_job_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'connector_sync_job_id'") + __path_parts: t.Dict[str, str] = { + "connector_sync_job_id": _quote(connector_sync_job_id) + } + __path = f'/_connector/_sync_job/{__path_parts["connector_sync_job_id"]}' + __query: t.Dict[str, t.Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + __headers = {"accept": "application/json"} + return self.perform_request( # type: ignore[return-value] + "DELETE", + __path, + params=__query, + headers=__headers, + endpoint_id="connector.sync_job_delete", + path_parts=__path_parts, + ) + + @_rewrite_parameters() + def sync_job_get( + self, + *, + connector_sync_job_id: str, + error_trace: t.Optional[bool] = None, + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, + human: t.Optional[bool] = None, + pretty: t.Optional[bool] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Returns the details about a connector sync job. + + ``_ + + :param connector_sync_job_id: The unique identifier of the connector sync job + """ + if connector_sync_job_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'connector_sync_job_id'") + __path_parts: t.Dict[str, str] = { + "connector_sync_job_id": _quote(connector_sync_job_id) + } + __path = f'/_connector/_sync_job/{__path_parts["connector_sync_job_id"]}' + __query: t.Dict[str, t.Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + __headers = {"accept": "application/json"} + return self.perform_request( # type: ignore[return-value] + "GET", + __path, + params=__query, + headers=__headers, + endpoint_id="connector.sync_job_get", + path_parts=__path_parts, + ) + + @_rewrite_parameters( + parameter_aliases={"from": "from_"}, + ) + def sync_job_list( + self, + *, + connector_id: t.Optional[str] = None, + error_trace: t.Optional[bool] = None, + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, + from_: t.Optional[int] = None, + human: t.Optional[bool] = None, + job_type: t.Optional[ + t.Sequence[ + t.Union["t.Literal['access_control', 'full', 'incremental']", str] + ] + ] = None, + pretty: t.Optional[bool] = None, + size: t.Optional[int] = None, + status: t.Optional[ + t.Union[ + "t.Literal['canceled', 'canceling', 'completed', 'error', 'in_progress', 'pending', 'suspended']", + str, + ] + ] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Lists all connector sync jobs. + + ``_ + + :param connector_id: A connector id to fetch connector sync jobs for + :param from_: Starting offset (default: 0) + :param job_type: A comma-separated list of job types to fetch the sync jobs for + :param size: Specifies a max number of results to get + :param status: A sync job status to fetch connector sync jobs for + """ + __path_parts: t.Dict[str, str] = {} + __path = "/_connector/_sync_job" + __query: t.Dict[str, t.Any] = {} + if connector_id is not None: + __query["connector_id"] = connector_id + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if from_ is not None: + __query["from"] = from_ + if human is not None: + __query["human"] = human + if job_type is not None: + __query["job_type"] = job_type + if pretty is not None: + __query["pretty"] = pretty + if size is not None: + __query["size"] = size + if status is not None: + __query["status"] = status + __headers = {"accept": "application/json"} + return self.perform_request( # type: ignore[return-value] + "GET", + __path, + params=__query, + headers=__headers, + endpoint_id="connector.sync_job_list", + path_parts=__path_parts, + ) + + @_rewrite_parameters( + body_fields=("id", "job_type", "trigger_method"), + ) + def sync_job_post( + self, + *, + id: t.Optional[str] = None, + error_trace: t.Optional[bool] = None, + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, + human: t.Optional[bool] = None, + job_type: t.Optional[ + t.Union["t.Literal['access_control', 'full', 'incremental']", str] + ] = None, + pretty: t.Optional[bool] = None, + trigger_method: t.Optional[ + t.Union["t.Literal['on_demand', 'scheduled']", str] + ] = None, + body: t.Optional[t.Dict[str, t.Any]] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Creates a connector sync job. + + ``_ + + :param id: The id of the associated connector + :param job_type: + :param trigger_method: + """ + if id is None and body is None: + raise ValueError("Empty value passed for parameter 'id'") + __path_parts: t.Dict[str, str] = {} + __path = "/_connector/_sync_job" + __query: t.Dict[str, t.Any] = {} + __body: t.Dict[str, t.Any] = body if body is not None else {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if not __body: + if id is not None: + __body["id"] = id + if job_type is not None: + __body["job_type"] = job_type + if trigger_method is not None: + __body["trigger_method"] = trigger_method + __headers = {"accept": "application/json", "content-type": "application/json"} + return self.perform_request( # type: ignore[return-value] + "POST", + __path, + params=__query, + headers=__headers, + body=__body, + endpoint_id="connector.sync_job_post", + path_parts=__path_parts, + ) + @_rewrite_parameters( body_fields=("api_key_id", "api_key_secret_id"), ) diff --git a/elasticsearch/_sync/client/esql.py b/elasticsearch/_sync/client/esql.py index 1dee2e934..ee83ec3d2 100644 --- a/elasticsearch/_sync/client/esql.py +++ b/elasticsearch/_sync/client/esql.py @@ -26,13 +26,14 @@ class EsqlClient(NamespacedClient): @_rewrite_parameters( - body_fields=("query", "columnar", "filter", "locale", "params"), + body_fields=("query", "version", "columnar", "filter", "locale", "params"), ignore_deprecated_options={"params"}, ) def query( self, *, query: t.Optional[str] = None, + version: t.Optional[t.Union["t.Literal['2024.04.01']", str]] = None, columnar: t.Optional[bool] = None, delimiter: t.Optional[str] = None, error_trace: t.Optional[bool] = None, @@ -52,6 +53,8 @@ def query( :param query: The ES|QL query API accepts an ES|QL query string in the query parameter, runs it, and returns the results. + :param version: The version of the ES|QL language in which the "query" field + was written. :param columnar: By default, ES|QL returns results as rows. For example, FROM returns each individual document as one row. For the JSON, YAML, CBOR and smile formats, ES|QL can return the results in a columnar fashion where one @@ -68,6 +71,8 @@ def query( """ if query is None and body is None: raise ValueError("Empty value passed for parameter 'query'") + if version is None and body is None: + raise ValueError("Empty value passed for parameter 'version'") __path_parts: t.Dict[str, str] = {} __path = "/_query" __query: t.Dict[str, t.Any] = {} @@ -87,6 +92,8 @@ def query( if not __body: if query is not None: __body["query"] = query + if version is not None: + __body["version"] = version if columnar is not None: __body["columnar"] = columnar if filter is not None: diff --git a/elasticsearch/_sync/client/indices.py b/elasticsearch/_sync/client/indices.py index 773e27322..aeca66804 100644 --- a/elasticsearch/_sync/client/indices.py +++ b/elasticsearch/_sync/client/indices.py @@ -2868,8 +2868,11 @@ def put_data_lifecycle( @_rewrite_parameters( body_fields=( + "allow_auto_create", "composed_of", "data_stream", + "deprecated", + "ignore_missing_component_templates", "index_patterns", "meta", "priority", @@ -2882,13 +2885,20 @@ def put_index_template( self, *, name: str, + allow_auto_create: t.Optional[bool] = None, + cause: t.Optional[str] = None, composed_of: t.Optional[t.Sequence[str]] = None, create: t.Optional[bool] = None, data_stream: t.Optional[t.Mapping[str, t.Any]] = None, + deprecated: t.Optional[bool] = None, error_trace: t.Optional[bool] = None, filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, human: t.Optional[bool] = None, + ignore_missing_component_templates: t.Optional[t.Sequence[str]] = None, index_patterns: t.Optional[t.Union[str, t.Sequence[str]]] = None, + master_timeout: t.Optional[ + t.Union["t.Literal[-1]", "t.Literal[0]", str] + ] = None, meta: t.Optional[t.Mapping[str, t.Any]] = None, pretty: t.Optional[bool] = None, priority: t.Optional[int] = None, @@ -2902,6 +2912,13 @@ def put_index_template( ``_ :param name: Index or template name + :param allow_auto_create: This setting overrides the value of the `action.auto_create_index` + cluster setting. If set to `true` in a template, then indices can be automatically + created using that template even if auto-creation of indices is disabled + via `actions.auto_create_index`. If set to `false`, then indices or data + streams matching the template must always be explicitly created, and may + never be automatically created. + :param cause: User defined reason for creating/updating the index template :param composed_of: An ordered list of component template names. Component templates are merged in the order specified, meaning that the last component template specified has the highest precedence. @@ -2910,7 +2927,16 @@ def put_index_template( :param data_stream: If this object is included, the template is used to create data streams and their backing indices. Supports an empty object. Data streams require a matching index template with a `data_stream` object. + :param deprecated: Marks this index template as deprecated. When creating or + updating a non-deprecated index template that uses deprecated components, + Elasticsearch will emit a deprecation warning. + :param ignore_missing_component_templates: The configuration option ignore_missing_component_templates + can be used when an index template references a component template that might + not exist :param index_patterns: Name of the index template to create. + :param master_timeout: Period to wait for a connection to the master node. If + no response is received before the timeout expires, the request fails and + returns an error. :param meta: Optional user metadata about the index template. May have any contents. This map is not automatically generated by Elasticsearch. :param priority: Priority to determine index template precedence when a new data @@ -2929,6 +2955,8 @@ def put_index_template( __path = f'/_index_template/{__path_parts["name"]}' __query: t.Dict[str, t.Any] = {} __body: t.Dict[str, t.Any] = body if body is not None else {} + if cause is not None: + __query["cause"] = cause if create is not None: __query["create"] = create if error_trace is not None: @@ -2937,13 +2965,23 @@ def put_index_template( __query["filter_path"] = filter_path if human is not None: __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout if pretty is not None: __query["pretty"] = pretty if not __body: + if allow_auto_create is not None: + __body["allow_auto_create"] = allow_auto_create if composed_of is not None: __body["composed_of"] = composed_of if data_stream is not None: __body["data_stream"] = data_stream + if deprecated is not None: + __body["deprecated"] = deprecated + if ignore_missing_component_templates is not None: + __body["ignore_missing_component_templates"] = ( + ignore_missing_component_templates + ) if index_patterns is not None: __body["index_patterns"] = index_patterns if meta is not None: @@ -3250,10 +3288,10 @@ def put_template( *, name: str, aliases: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None, + cause: t.Optional[str] = None, create: t.Optional[bool] = None, error_trace: t.Optional[bool] = None, filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, - flat_settings: t.Optional[bool] = None, human: t.Optional[bool] = None, index_patterns: t.Optional[t.Union[str, t.Sequence[str]]] = None, mappings: t.Optional[t.Mapping[str, t.Any]] = None, @@ -3263,7 +3301,6 @@ def put_template( order: t.Optional[int] = None, pretty: t.Optional[bool] = None, settings: t.Optional[t.Mapping[str, t.Any]] = None, - timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, version: t.Optional[int] = None, body: t.Optional[t.Dict[str, t.Any]] = None, ) -> ObjectApiResponse[t.Any]: @@ -3274,9 +3311,9 @@ def put_template( :param name: The name of the template :param aliases: Aliases for the index. + :param cause: :param create: If true, this request cannot replace or update existing index templates. - :param flat_settings: If `true`, returns settings in flat format. :param index_patterns: Array of wildcard expressions used to match the names of indices during creation. :param mappings: Mapping for fields in the index. @@ -3288,8 +3325,6 @@ def put_template( Templates with higher 'order' values are merged later, overriding templates with lower values. :param settings: Configuration options for the index. - :param timeout: Period to wait for a response. If no response is received before - the timeout expires, the request fails and returns an error. :param version: Version number used to manage index templates externally. This number is not automatically generated by Elasticsearch. """ @@ -3299,22 +3334,20 @@ def put_template( __path = f'/_template/{__path_parts["name"]}' __query: t.Dict[str, t.Any] = {} __body: t.Dict[str, t.Any] = body if body is not None else {} + if cause is not None: + __query["cause"] = cause if create is not None: __query["create"] = create if error_trace is not None: __query["error_trace"] = error_trace if filter_path is not None: __query["filter_path"] = filter_path - if flat_settings is not None: - __query["flat_settings"] = flat_settings if human is not None: __query["human"] = human if master_timeout is not None: __query["master_timeout"] = master_timeout if pretty is not None: __query["pretty"] = pretty - if timeout is not None: - __query["timeout"] = timeout if not __body: if aliases is not None: __body["aliases"] = aliases @@ -4004,91 +4037,37 @@ def shrink( path_parts=__path_parts, ) - @_rewrite_parameters( - body_fields=( - "allow_auto_create", - "composed_of", - "data_stream", - "index_patterns", - "meta", - "priority", - "template", - "version", - ), - parameter_aliases={"_meta": "meta"}, - ) + @_rewrite_parameters() def simulate_index_template( self, *, name: str, - allow_auto_create: t.Optional[bool] = None, - composed_of: t.Optional[t.Sequence[str]] = None, - create: t.Optional[bool] = None, - data_stream: t.Optional[t.Mapping[str, t.Any]] = None, error_trace: t.Optional[bool] = None, filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, human: t.Optional[bool] = None, include_defaults: t.Optional[bool] = None, - index_patterns: t.Optional[t.Union[str, t.Sequence[str]]] = None, master_timeout: t.Optional[ t.Union["t.Literal[-1]", "t.Literal[0]", str] ] = None, - meta: t.Optional[t.Mapping[str, t.Any]] = None, pretty: t.Optional[bool] = None, - priority: t.Optional[int] = None, - template: t.Optional[t.Mapping[str, t.Any]] = None, - version: t.Optional[int] = None, - body: t.Optional[t.Dict[str, t.Any]] = None, ) -> ObjectApiResponse[t.Any]: """ Simulate matching the given index name against the index templates in the system ``_ - :param name: Index or template name to simulate - :param allow_auto_create: This setting overrides the value of the `action.auto_create_index` - cluster setting. If set to `true` in a template, then indices can be automatically - created using that template even if auto-creation of indices is disabled - via `actions.auto_create_index`. If set to `false`, then indices or data - streams matching the template must always be explicitly created, and may - never be automatically created. - :param composed_of: An ordered list of component template names. Component templates - are merged in the order specified, meaning that the last component template - specified has the highest precedence. - :param create: If `true`, the template passed in the body is only used if no - existing templates match the same index patterns. If `false`, the simulation - uses the template with the highest priority. Note that the template is not - permanently added or updated in either case; it is only used for the simulation. - :param data_stream: If this object is included, the template is used to create - data streams and their backing indices. Supports an empty object. Data streams - require a matching index template with a `data_stream` object. + :param name: Name of the index to simulate :param include_defaults: If true, returns all relevant default configurations for the index template. - :param index_patterns: Array of wildcard (`*`) expressions used to match the - names of data streams and indices during creation. :param master_timeout: Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. - :param meta: Optional user metadata about the index template. May have any contents. - This map is not automatically generated by Elasticsearch. - :param priority: Priority to determine index template precedence when a new data - stream or index is created. The index template with the highest priority - is chosen. If no priority is specified the template is treated as though - it is of priority 0 (lowest priority). This number is not automatically generated - by Elasticsearch. - :param template: Template to be applied. It may optionally include an `aliases`, - `mappings`, or `settings` configuration. - :param version: Version number used to manage index templates externally. This - number is not automatically generated by Elasticsearch. """ if name in SKIP_IN_PATH: raise ValueError("Empty value passed for parameter 'name'") __path_parts: t.Dict[str, str] = {"name": _quote(name)} __path = f'/_index_template/_simulate_index/{__path_parts["name"]}' __query: t.Dict[str, t.Any] = {} - __body: t.Dict[str, t.Any] = body if body is not None else {} - if create is not None: - __query["create"] = create if error_trace is not None: __query["error_trace"] = error_trace if filter_path is not None: @@ -4101,56 +4080,55 @@ def simulate_index_template( __query["master_timeout"] = master_timeout if pretty is not None: __query["pretty"] = pretty - if not __body: - if allow_auto_create is not None: - __body["allow_auto_create"] = allow_auto_create - if composed_of is not None: - __body["composed_of"] = composed_of - if data_stream is not None: - __body["data_stream"] = data_stream - if index_patterns is not None: - __body["index_patterns"] = index_patterns - if meta is not None: - __body["_meta"] = meta - if priority is not None: - __body["priority"] = priority - if template is not None: - __body["template"] = template - if version is not None: - __body["version"] = version - if not __body: - __body = None # type: ignore[assignment] __headers = {"accept": "application/json"} - if __body is not None: - __headers["content-type"] = "application/json" return self.perform_request( # type: ignore[return-value] "POST", __path, params=__query, headers=__headers, - body=__body, endpoint_id="indices.simulate_index_template", path_parts=__path_parts, ) @_rewrite_parameters( - body_name="template", + body_fields=( + "allow_auto_create", + "composed_of", + "data_stream", + "deprecated", + "ignore_missing_component_templates", + "index_patterns", + "meta", + "priority", + "template", + "version", + ), + parameter_aliases={"_meta": "meta"}, ) def simulate_template( self, *, name: t.Optional[str] = None, + allow_auto_create: t.Optional[bool] = None, + composed_of: t.Optional[t.Sequence[str]] = None, create: t.Optional[bool] = None, + data_stream: t.Optional[t.Mapping[str, t.Any]] = None, + deprecated: t.Optional[bool] = None, error_trace: t.Optional[bool] = None, filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, human: t.Optional[bool] = None, + ignore_missing_component_templates: t.Optional[t.Sequence[str]] = None, include_defaults: t.Optional[bool] = None, + index_patterns: t.Optional[t.Union[str, t.Sequence[str]]] = None, master_timeout: t.Optional[ t.Union["t.Literal[-1]", "t.Literal[0]", str] ] = None, + meta: t.Optional[t.Mapping[str, t.Any]] = None, pretty: t.Optional[bool] = None, + priority: t.Optional[int] = None, template: t.Optional[t.Mapping[str, t.Any]] = None, - body: t.Optional[t.Mapping[str, t.Any]] = None, + version: t.Optional[int] = None, + body: t.Optional[t.Dict[str, t.Any]] = None, ) -> ObjectApiResponse[t.Any]: """ Simulate resolving the given template name or body @@ -4160,23 +4138,47 @@ def simulate_template( :param name: Name of the index template to simulate. To test a template configuration before you add it to the cluster, omit this parameter and specify the template configuration in the request body. + :param allow_auto_create: This setting overrides the value of the `action.auto_create_index` + cluster setting. If set to `true` in a template, then indices can be automatically + created using that template even if auto-creation of indices is disabled + via `actions.auto_create_index`. If set to `false`, then indices or data + streams matching the template must always be explicitly created, and may + never be automatically created. + :param composed_of: An ordered list of component template names. Component templates + are merged in the order specified, meaning that the last component template + specified has the highest precedence. :param create: If true, the template passed in the body is only used if no existing templates match the same index patterns. If false, the simulation uses the template with the highest priority. Note that the template is not permanently added or updated in either case; it is only used for the simulation. + :param data_stream: If this object is included, the template is used to create + data streams and their backing indices. Supports an empty object. Data streams + require a matching index template with a `data_stream` object. + :param deprecated: Marks this index template as deprecated. When creating or + updating a non-deprecated index template that uses deprecated components, + Elasticsearch will emit a deprecation warning. + :param ignore_missing_component_templates: The configuration option ignore_missing_component_templates + can be used when an index template references a component template that might + not exist :param include_defaults: If true, returns all relevant default configurations for the index template. + :param index_patterns: Array of wildcard (`*`) expressions used to match the + names of data streams and indices during creation. :param master_timeout: Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. - :param template: + :param meta: Optional user metadata about the index template. May have any contents. + This map is not automatically generated by Elasticsearch. + :param priority: Priority to determine index template precedence when a new data + stream or index is created. The index template with the highest priority + is chosen. If no priority is specified the template is treated as though + it is of priority 0 (lowest priority). This number is not automatically generated + by Elasticsearch. + :param template: Template to be applied. It may optionally include an `aliases`, + `mappings`, or `settings` configuration. + :param version: Version number used to manage index templates externally. This + number is not automatically generated by Elasticsearch. """ - if template is None and body is None: - raise ValueError( - "Empty value passed for parameters 'template' and 'body', one of them should be set." - ) - elif template is not None and body is not None: - raise ValueError("Cannot set both 'template' and 'body'") __path_parts: t.Dict[str, str] if name not in SKIP_IN_PATH: __path_parts = {"name": _quote(name)} @@ -4185,6 +4187,7 @@ def simulate_template( __path_parts = {} __path = "/_index_template/_simulate" __query: t.Dict[str, t.Any] = {} + __body: t.Dict[str, t.Any] = body if body is not None else {} if create is not None: __query["create"] = create if error_trace is not None: @@ -4199,9 +4202,31 @@ def simulate_template( __query["master_timeout"] = master_timeout if pretty is not None: __query["pretty"] = pretty - __body = template if template is not None else body if not __body: - __body = None + if allow_auto_create is not None: + __body["allow_auto_create"] = allow_auto_create + if composed_of is not None: + __body["composed_of"] = composed_of + if data_stream is not None: + __body["data_stream"] = data_stream + if deprecated is not None: + __body["deprecated"] = deprecated + if ignore_missing_component_templates is not None: + __body["ignore_missing_component_templates"] = ( + ignore_missing_component_templates + ) + if index_patterns is not None: + __body["index_patterns"] = index_patterns + if meta is not None: + __body["_meta"] = meta + if priority is not None: + __body["priority"] = priority + if template is not None: + __body["template"] = template + if version is not None: + __body["version"] = version + if not __body: + __body = None # type: ignore[assignment] __headers = {"accept": "application/json"} if __body is not None: __headers["content-type"] = "application/json" diff --git a/elasticsearch/_sync/client/inference.py b/elasticsearch/_sync/client/inference.py index 7d4a207ce..59bea76cb 100644 --- a/elasticsearch/_sync/client/inference.py +++ b/elasticsearch/_sync/client/inference.py @@ -86,13 +86,13 @@ def delete_model( def get_model( self, *, - inference_id: str, task_type: t.Optional[ t.Union[ "t.Literal['completion', 'rerank', 'sparse_embedding', 'text_embedding']", str, ] ] = None, + inference_id: t.Optional[str] = None, error_trace: t.Optional[bool] = None, filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, human: t.Optional[bool] = None, @@ -103,11 +103,9 @@ def get_model( ``_ - :param inference_id: The inference Id :param task_type: The task type + :param inference_id: The inference Id """ - if inference_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'inference_id'") __path_parts: t.Dict[str, str] if task_type not in SKIP_IN_PATH and inference_id not in SKIP_IN_PATH: __path_parts = { @@ -119,7 +117,8 @@ def get_model( __path_parts = {"inference_id": _quote(inference_id)} __path = f'/_inference/{__path_parts["inference_id"]}' else: - raise ValueError("Couldn't find a path for the given parameters") + __path_parts = {} + __path = "/_inference" __query: t.Dict[str, t.Any] = {} if error_trace is not None: __query["error_trace"] = error_trace @@ -159,6 +158,7 @@ def inference( pretty: t.Optional[bool] = None, query: t.Optional[str] = None, task_settings: t.Optional[t.Any] = None, + timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, body: t.Optional[t.Dict[str, t.Any]] = None, ) -> ObjectApiResponse[t.Any]: """ @@ -171,6 +171,8 @@ def inference( :param task_type: The task type :param query: Query input, required for rerank task. Not required for other tasks. :param task_settings: Optional task settings + :param timeout: Specifies the amount of time to wait for the inference request + to complete. """ if inference_id in SKIP_IN_PATH: raise ValueError("Empty value passed for parameter 'inference_id'") @@ -198,6 +200,8 @@ def inference( __query["human"] = human if pretty is not None: __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout if not __body: if input is not None: __body["input"] = input diff --git a/elasticsearch/_sync/client/security.py b/elasticsearch/_sync/client/security.py index 2ce01eadb..e4cf338c8 100644 --- a/elasticsearch/_sync/client/security.py +++ b/elasticsearch/_sync/client/security.py @@ -1761,7 +1761,7 @@ def has_privileges( cluster: t.Optional[ t.Sequence[ t.Union[ - "t.Literal['all', 'cancel_task', 'create_snapshot', 'grant_api_key', 'manage', 'manage_api_key', 'manage_ccr', 'manage_enrich', 'manage_ilm', 'manage_index_templates', 'manage_ingest_pipelines', 'manage_logstash_pipelines', 'manage_ml', 'manage_oidc', 'manage_own_api_key', 'manage_pipeline', 'manage_rollup', 'manage_saml', 'manage_security', 'manage_service_account', 'manage_slm', 'manage_token', 'manage_transform', 'manage_user_profile', 'manage_watcher', 'monitor', 'monitor_ml', 'monitor_rollup', 'monitor_snapshot', 'monitor_text_structure', 'monitor_transform', 'monitor_watcher', 'read_ccr', 'read_ilm', 'read_pipeline', 'read_slm', 'transport_client']", + "t.Literal['all', 'cancel_task', 'create_snapshot', 'cross_cluster_replication', 'cross_cluster_search', 'delegate_pki', 'grant_api_key', 'manage', 'manage_api_key', 'manage_autoscaling', 'manage_behavioral_analytics', 'manage_ccr', 'manage_data_frame_transforms', 'manage_data_stream_global_retention', 'manage_enrich', 'manage_ilm', 'manage_index_templates', 'manage_inference', 'manage_ingest_pipelines', 'manage_logstash_pipelines', 'manage_ml', 'manage_oidc', 'manage_own_api_key', 'manage_pipeline', 'manage_rollup', 'manage_saml', 'manage_search_application', 'manage_search_query_rules', 'manage_search_synonyms', 'manage_security', 'manage_service_account', 'manage_slm', 'manage_token', 'manage_transform', 'manage_user_profile', 'manage_watcher', 'monitor', 'monitor_data_frame_transforms', 'monitor_data_stream_global_retention', 'monitor_enrich', 'monitor_inference', 'monitor_ml', 'monitor_rollup', 'monitor_snapshot', 'monitor_text_structure', 'monitor_transform', 'monitor_watcher', 'none', 'post_behavioral_analytics_event', 'read_ccr', 'read_connector_secrets', 'read_fleet_secrets', 'read_ilm', 'read_pipeline', 'read_security', 'read_slm', 'transport_client', 'write_connector_secrets', 'write_fleet_secrets']", str, ] ] @@ -2084,7 +2084,7 @@ def put_role( cluster: t.Optional[ t.Sequence[ t.Union[ - "t.Literal['all', 'cancel_task', 'create_snapshot', 'grant_api_key', 'manage', 'manage_api_key', 'manage_ccr', 'manage_enrich', 'manage_ilm', 'manage_index_templates', 'manage_ingest_pipelines', 'manage_logstash_pipelines', 'manage_ml', 'manage_oidc', 'manage_own_api_key', 'manage_pipeline', 'manage_rollup', 'manage_saml', 'manage_security', 'manage_service_account', 'manage_slm', 'manage_token', 'manage_transform', 'manage_user_profile', 'manage_watcher', 'monitor', 'monitor_ml', 'monitor_rollup', 'monitor_snapshot', 'monitor_text_structure', 'monitor_transform', 'monitor_watcher', 'read_ccr', 'read_ilm', 'read_pipeline', 'read_slm', 'transport_client']", + "t.Literal['all', 'cancel_task', 'create_snapshot', 'cross_cluster_replication', 'cross_cluster_search', 'delegate_pki', 'grant_api_key', 'manage', 'manage_api_key', 'manage_autoscaling', 'manage_behavioral_analytics', 'manage_ccr', 'manage_data_frame_transforms', 'manage_data_stream_global_retention', 'manage_enrich', 'manage_ilm', 'manage_index_templates', 'manage_inference', 'manage_ingest_pipelines', 'manage_logstash_pipelines', 'manage_ml', 'manage_oidc', 'manage_own_api_key', 'manage_pipeline', 'manage_rollup', 'manage_saml', 'manage_search_application', 'manage_search_query_rules', 'manage_search_synonyms', 'manage_security', 'manage_service_account', 'manage_slm', 'manage_token', 'manage_transform', 'manage_user_profile', 'manage_watcher', 'monitor', 'monitor_data_frame_transforms', 'monitor_data_stream_global_retention', 'monitor_enrich', 'monitor_inference', 'monitor_ml', 'monitor_rollup', 'monitor_snapshot', 'monitor_text_structure', 'monitor_transform', 'monitor_watcher', 'none', 'post_behavioral_analytics_event', 'read_ccr', 'read_connector_secrets', 'read_fleet_secrets', 'read_ilm', 'read_pipeline', 'read_security', 'read_slm', 'transport_client', 'write_connector_secrets', 'write_fleet_secrets']", str, ] ]