From c8c7a34f836fa990ea3a09dea7f66b380858b71c Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Fri, 24 May 2024 17:02:18 +0400 Subject: [PATCH] Auto-generated API code (#38) * Auto-generated API code * Try older qaf image * Revert "Try older qaf image" This reverts commit 30fdabe9aafc966c1bb26c8bf2518195f4abaad6. --- .../_async/client/cluster.py | 20 ++++--- .../_async/client/indices.py | 58 ++++++++++++++++--- .../_async/client/inference.py | 45 +++++++------- .../_async/client/security.py | 2 +- .../_sync/client/cluster.py | 20 ++++--- .../_sync/client/indices.py | 58 ++++++++++++++++--- .../_sync/client/inference.py | 45 +++++++------- .../_sync/client/security.py | 2 +- 8 files changed, 170 insertions(+), 80 deletions(-) diff --git a/elasticsearch_serverless/_async/client/cluster.py b/elasticsearch_serverless/_async/client/cluster.py index 5f76b09..1675534 100644 --- a/elasticsearch_serverless/_async/client/cluster.py +++ b/elasticsearch_serverless/_async/client/cluster.py @@ -225,7 +225,7 @@ async def info( ) @_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( @@ -233,8 +233,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, @@ -262,13 +263,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. @@ -287,6 +287,8 @@ async def put_component_template( __path = f"/_component_template/{_quote(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: @@ -302,8 +304,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_serverless/_async/client/indices.py b/elasticsearch_serverless/_async/client/indices.py index c85830a..e93f016 100644 --- a/elasticsearch_serverless/_async/client/indices.py +++ b/elasticsearch_serverless/_async/client/indices.py @@ -1638,8 +1638,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", @@ -1652,13 +1655,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, @@ -1672,6 +1682,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. @@ -1680,7 +1697,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 @@ -1698,6 +1724,8 @@ async def put_index_template( __path = f"/_index_template/{_quote(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: @@ -1706,13 +1734,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: @@ -1997,10 +2035,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, @@ -2010,7 +2048,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]: @@ -2021,9 +2058,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. @@ -2035,8 +2072,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. """ @@ -2045,22 +2080,20 @@ async def put_template( __path = f"/_template/{_quote(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 @@ -2345,6 +2378,7 @@ async def simulate_index_template( "allow_auto_create", "composed_of", "data_stream", + "deprecated", "ignore_missing_component_templates", "index_patterns", "meta", @@ -2362,6 +2396,7 @@ async def simulate_template( 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, @@ -2402,6 +2437,9 @@ async def simulate_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 @@ -2451,6 +2489,8 @@ async def simulate_template( __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 diff --git a/elasticsearch_serverless/_async/client/inference.py b/elasticsearch_serverless/_async/client/inference.py index 8519771..454fb3e 100644 --- a/elasticsearch_serverless/_async/client/inference.py +++ b/elasticsearch_serverless/_async/client/inference.py @@ -26,7 +26,7 @@ class InferenceClient(NamespacedClient): @_rewrite_parameters() - async def delete_model( + async def delete( self, *, inference_id: str, @@ -42,7 +42,7 @@ async def delete_model( pretty: t.Optional[bool] = None, ) -> ObjectApiResponse[t.Any]: """ - Delete model in the Inference API + Delete an inference endpoint ``_ @@ -72,37 +72,35 @@ async def delete_model( ) @_rewrite_parameters() - async def get_model( + async def get( 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, pretty: t.Optional[bool] = None, ) -> ObjectApiResponse[t.Any]: """ - Get a model in the Inference API + Get an inference endpoint ``_ - :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'") if task_type not in SKIP_IN_PATH and inference_id not in SKIP_IN_PATH: __path = f"/_inference/{_quote(task_type)}/{_quote(inference_id)}" elif inference_id not in SKIP_IN_PATH: __path = f"/_inference/{_quote(inference_id)}" else: - raise ValueError("Couldn't find a path for the given parameters") + __path = "/_inference" __query: t.Dict[str, t.Any] = {} if error_trace is not None: __query["error_trace"] = error_trace @@ -137,18 +135,21 @@ 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]: """ - Perform inference on a model + Perform inference ``_ :param inference_id: The inference Id - :param input: Text input to the model. Either a string or an array of strings. + :param input: Inference input. Either a string or an array of strings. :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'") @@ -170,6 +171,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 @@ -187,13 +190,13 @@ async def inference( ) @_rewrite_parameters( - body_name="model_config", + body_name="inference_config", ) - async def put_model( + async def put( self, *, inference_id: str, - model_config: t.Optional[t.Mapping[str, t.Any]] = None, + inference_config: t.Optional[t.Mapping[str, t.Any]] = None, body: t.Optional[t.Mapping[str, t.Any]] = None, task_type: t.Optional[ t.Union[ @@ -207,22 +210,22 @@ async def put_model( pretty: t.Optional[bool] = None, ) -> ObjectApiResponse[t.Any]: """ - Configure a model for use in the Inference API + Configure an inference endpoint for use in the Inference API ``_ :param inference_id: The inference Id - :param model_config: + :param inference_config: :param task_type: The task type """ if inference_id in SKIP_IN_PATH: raise ValueError("Empty value passed for parameter 'inference_id'") - if model_config is None and body is None: + if inference_config is None and body is None: raise ValueError( - "Empty value passed for parameters 'model_config' and 'body', one of them should be set." + "Empty value passed for parameters 'inference_config' and 'body', one of them should be set." ) - elif model_config is not None and body is not None: - raise ValueError("Cannot set both 'model_config' and 'body'") + elif inference_config is not None and body is not None: + raise ValueError("Cannot set both 'inference_config' and 'body'") if task_type not in SKIP_IN_PATH and inference_id not in SKIP_IN_PATH: __path = f"/_inference/{_quote(task_type)}/{_quote(inference_id)}" elif inference_id not in SKIP_IN_PATH: @@ -238,7 +241,7 @@ async def put_model( __query["human"] = human if pretty is not None: __query["pretty"] = pretty - __body = model_config if model_config is not None else body + __body = inference_config if inference_config is not None else body __headers = {"accept": "application/json", "content-type": "application/json"} return await self.perform_request( # type: ignore[return-value] "PUT", __path, params=__query, headers=__headers, body=__body diff --git a/elasticsearch_serverless/_async/client/security.py b/elasticsearch_serverless/_async/client/security.py index a8a4c2b..295bebd 100644 --- a/elasticsearch_serverless/_async/client/security.py +++ b/elasticsearch_serverless/_async/client/security.py @@ -211,7 +211,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, ] ] diff --git a/elasticsearch_serverless/_sync/client/cluster.py b/elasticsearch_serverless/_sync/client/cluster.py index 0174508..22c2e11 100644 --- a/elasticsearch_serverless/_sync/client/cluster.py +++ b/elasticsearch_serverless/_sync/client/cluster.py @@ -225,7 +225,7 @@ def info( ) @_rewrite_parameters( - body_fields=("template", "allow_auto_create", "meta", "version"), + body_fields=("template", "deprecated", "meta", "version"), parameter_aliases={"_meta": "meta"}, ) def put_component_template( @@ -233,8 +233,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, @@ -262,13 +263,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. @@ -287,6 +287,8 @@ def put_component_template( __path = f"/_component_template/{_quote(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: @@ -302,8 +304,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_serverless/_sync/client/indices.py b/elasticsearch_serverless/_sync/client/indices.py index f3f24c4..812aee1 100644 --- a/elasticsearch_serverless/_sync/client/indices.py +++ b/elasticsearch_serverless/_sync/client/indices.py @@ -1638,8 +1638,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", @@ -1652,13 +1655,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, @@ -1672,6 +1682,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. @@ -1680,7 +1697,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 @@ -1698,6 +1724,8 @@ def put_index_template( __path = f"/_index_template/{_quote(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: @@ -1706,13 +1734,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: @@ -1997,10 +2035,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, @@ -2010,7 +2048,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]: @@ -2021,9 +2058,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. @@ -2035,8 +2072,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. """ @@ -2045,22 +2080,20 @@ def put_template( __path = f"/_template/{_quote(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 @@ -2345,6 +2378,7 @@ def simulate_index_template( "allow_auto_create", "composed_of", "data_stream", + "deprecated", "ignore_missing_component_templates", "index_patterns", "meta", @@ -2362,6 +2396,7 @@ def simulate_template( 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, @@ -2402,6 +2437,9 @@ def simulate_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 @@ -2451,6 +2489,8 @@ def simulate_template( __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 diff --git a/elasticsearch_serverless/_sync/client/inference.py b/elasticsearch_serverless/_sync/client/inference.py index d84cca7..3cb0d1a 100644 --- a/elasticsearch_serverless/_sync/client/inference.py +++ b/elasticsearch_serverless/_sync/client/inference.py @@ -26,7 +26,7 @@ class InferenceClient(NamespacedClient): @_rewrite_parameters() - def delete_model( + def delete( self, *, inference_id: str, @@ -42,7 +42,7 @@ def delete_model( pretty: t.Optional[bool] = None, ) -> ObjectApiResponse[t.Any]: """ - Delete model in the Inference API + Delete an inference endpoint ``_ @@ -72,37 +72,35 @@ def delete_model( ) @_rewrite_parameters() - def get_model( + def get( 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, pretty: t.Optional[bool] = None, ) -> ObjectApiResponse[t.Any]: """ - Get a model in the Inference API + Get an inference endpoint ``_ - :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'") if task_type not in SKIP_IN_PATH and inference_id not in SKIP_IN_PATH: __path = f"/_inference/{_quote(task_type)}/{_quote(inference_id)}" elif inference_id not in SKIP_IN_PATH: __path = f"/_inference/{_quote(inference_id)}" else: - raise ValueError("Couldn't find a path for the given parameters") + __path = "/_inference" __query: t.Dict[str, t.Any] = {} if error_trace is not None: __query["error_trace"] = error_trace @@ -137,18 +135,21 @@ 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]: """ - Perform inference on a model + Perform inference ``_ :param inference_id: The inference Id - :param input: Text input to the model. Either a string or an array of strings. + :param input: Inference input. Either a string or an array of strings. :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'") @@ -170,6 +171,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 @@ -187,13 +190,13 @@ def inference( ) @_rewrite_parameters( - body_name="model_config", + body_name="inference_config", ) - def put_model( + def put( self, *, inference_id: str, - model_config: t.Optional[t.Mapping[str, t.Any]] = None, + inference_config: t.Optional[t.Mapping[str, t.Any]] = None, body: t.Optional[t.Mapping[str, t.Any]] = None, task_type: t.Optional[ t.Union[ @@ -207,22 +210,22 @@ def put_model( pretty: t.Optional[bool] = None, ) -> ObjectApiResponse[t.Any]: """ - Configure a model for use in the Inference API + Configure an inference endpoint for use in the Inference API ``_ :param inference_id: The inference Id - :param model_config: + :param inference_config: :param task_type: The task type """ if inference_id in SKIP_IN_PATH: raise ValueError("Empty value passed for parameter 'inference_id'") - if model_config is None and body is None: + if inference_config is None and body is None: raise ValueError( - "Empty value passed for parameters 'model_config' and 'body', one of them should be set." + "Empty value passed for parameters 'inference_config' and 'body', one of them should be set." ) - elif model_config is not None and body is not None: - raise ValueError("Cannot set both 'model_config' and 'body'") + elif inference_config is not None and body is not None: + raise ValueError("Cannot set both 'inference_config' and 'body'") if task_type not in SKIP_IN_PATH and inference_id not in SKIP_IN_PATH: __path = f"/_inference/{_quote(task_type)}/{_quote(inference_id)}" elif inference_id not in SKIP_IN_PATH: @@ -238,7 +241,7 @@ def put_model( __query["human"] = human if pretty is not None: __query["pretty"] = pretty - __body = model_config if model_config is not None else body + __body = inference_config if inference_config is not None else body __headers = {"accept": "application/json", "content-type": "application/json"} return self.perform_request( # type: ignore[return-value] "PUT", __path, params=__query, headers=__headers, body=__body diff --git a/elasticsearch_serverless/_sync/client/security.py b/elasticsearch_serverless/_sync/client/security.py index aa8dfcd..ea94c07 100644 --- a/elasticsearch_serverless/_sync/client/security.py +++ b/elasticsearch_serverless/_sync/client/security.py @@ -211,7 +211,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, ] ]