From 99ff862f73f4e96ab04659d63898ba39924ca6b3 Mon Sep 17 00:00:00 2001 From: Elastic Machine Date: Mon, 11 Nov 2024 06:03:54 +0000 Subject: [PATCH] Auto-generated API code --- elasticsearch/_async/client/__init__.py | 73 ++++++---- elasticsearch/_async/client/async_search.py | 8 +- elasticsearch/_async/client/autoscaling.py | 25 +++- elasticsearch/_async/client/security.py | 152 ++++++++++++++++++++ elasticsearch/_sync/client/__init__.py | 73 ++++++---- elasticsearch/_sync/client/async_search.py | 8 +- elasticsearch/_sync/client/autoscaling.py | 25 +++- elasticsearch/_sync/client/security.py | 152 ++++++++++++++++++++ 8 files changed, 442 insertions(+), 74 deletions(-) diff --git a/elasticsearch/_async/client/__init__.py b/elasticsearch/_async/client/__init__.py index 3086538e2..d5985ca05 100644 --- a/elasticsearch/_async/client/__init__.py +++ b/elasticsearch/_async/client/__init__.py @@ -743,7 +743,8 @@ async def clear_scroll( body: t.Optional[t.Dict[str, t.Any]] = None, ) -> ObjectApiResponse[t.Any]: """ - Clears the search context and results for a scrolling search. + Clear a scrolling search. Clear the search context and results for a scrolling + search. ``_ @@ -793,7 +794,11 @@ async def close_point_in_time( body: t.Optional[t.Dict[str, t.Any]] = None, ) -> ObjectApiResponse[t.Any]: """ - Closes a point-in-time. + Close a point in time. A point in time must be opened explicitly before being + used in search requests. The `keep_alive` parameter tells Elasticsearch how long + it should persist. A point in time is automatically closed when the `keep_alive` + period has elapsed. However, keeping points in time has a cost; close them as + soon as they are no longer required for search requests. ``_ @@ -1844,10 +1849,11 @@ async def field_caps( body: t.Optional[t.Dict[str, t.Any]] = None, ) -> ObjectApiResponse[t.Any]: """ - The field capabilities API returns the information about the capabilities of - fields among multiple indices. The field capabilities API returns runtime fields - like any other field. For example, a runtime field with a type of keyword is - returned as any other field that belongs to the `keyword` family. + Get the field capabilities. Get information about the capabilities of fields + among multiple indices. For data streams, the API returns field capabilities + among the stream’s backing indices. It returns runtime fields like any other + field. For example, a runtime field with a type of keyword is returned the same + as any other field that belongs to the `keyword` family. ``_ @@ -2490,6 +2496,7 @@ async def info( ), parameter_aliases={"_source": "source"}, ) + @_stability_warning(Stability.EXPERIMENTAL) async def knn_search( self, *, @@ -2510,7 +2517,15 @@ async def knn_search( body: t.Optional[t.Dict[str, t.Any]] = None, ) -> ObjectApiResponse[t.Any]: """ - Performs a kNN search. + Run a knn search. NOTE: The kNN search API has been replaced by the `knn` option + in the search API. Perform a k-nearest neighbor (kNN) search on a dense_vector + field and return the matching documents. Given a query vector, the API finds + the k closest vectors and returns those documents as search hits. Elasticsearch + uses the HNSW algorithm to support efficient kNN search. Like most kNN algorithms, + HNSW is an approximate method that sacrifices result accuracy for improved search + speed. This means the results returned are not always the true k closest neighbors. + The kNN search API supports restricting the search using a filter. The search + will return the top k documents that also match the filter query. ``_ @@ -2873,7 +2888,7 @@ async def msearch_template( typed_keys: t.Optional[bool] = None, ) -> ObjectApiResponse[t.Any]: """ - Runs multiple templated searches with a single request. + Run multiple templated searches. ``_ @@ -3083,13 +3098,15 @@ async def open_point_in_time( body: t.Optional[t.Dict[str, t.Any]] = None, ) -> ObjectApiResponse[t.Any]: """ - A search request by default executes against the most recent visible data of - the target indices, which is called point in time. Elasticsearch pit (point in - time) is a lightweight view into the state of the data as it existed when initiated. - In some cases, it’s preferred to perform multiple search requests using the same - point in time. For example, if refreshes happen between `search_after` requests, - then the results of those requests might not be consistent as changes happening - between searches are only visible to the more recent point in time. + Open a point in time. A search request by default runs against the most recent + visible data of the target indices, which is called point in time. Elasticsearch + pit (point in time) is a lightweight view into the state of the data as it existed + when initiated. In some cases, it’s preferred to perform multiple search requests + using the same point in time. For example, if refreshes happen between `search_after` + requests, then the results of those requests might not be consistent as changes + happening between searches are only visible to the more recent point in time. + A point in time must be opened explicitly before being used in search requests. + The `keep_alive` parameter tells Elasticsearch how long it should persist. ``_ @@ -3256,8 +3273,8 @@ async def rank_eval( body: t.Optional[t.Dict[str, t.Any]] = None, ) -> ObjectApiResponse[t.Any]: """ - Enables you to evaluate the quality of ranked search results over a set of typical - search queries. + Evaluate ranked search results. Evaluate the quality of ranked search results + over a set of typical search queries. ``_ @@ -3501,7 +3518,7 @@ async def render_search_template( body: t.Optional[t.Dict[str, t.Any]] = None, ) -> ObjectApiResponse[t.Any]: """ - Renders a search template as a search request body. + Render a search template. Render a search template as a search request body. ``_ @@ -3833,9 +3850,9 @@ async def search( body: t.Optional[t.Dict[str, t.Any]] = None, ) -> ObjectApiResponse[t.Any]: """ - Returns search hits that match the query defined in the request. You can provide - search queries using the `q` query string parameter or the request body. If both - are specified, only the query parameter is used. + Run a search. Get search hits that match the query defined in the request. You + can provide search queries using the `q` query string parameter or the request + body. If both are specified, only the query parameter is used. ``_ @@ -4265,7 +4282,7 @@ async def search_mvt( body: t.Optional[t.Dict[str, t.Any]] = None, ) -> BinaryApiResponse: """ - Search a vector tile. Searches a vector tile for geospatial values. + Search a vector tile. Search a vector tile for geospatial values. ``_ @@ -4419,8 +4436,10 @@ async def search_shards( routing: t.Optional[str] = None, ) -> ObjectApiResponse[t.Any]: """ - Returns information about the indices and shards that a search request would - be executed against. + Get the search shards. Get the indices and shards that a search request would + be run against. This information can be useful for working out issues or planning + optimizations with routing and shard preferences. When filtered aliases are used, + the filter is returned as part of the indices section. ``_ @@ -4521,7 +4540,7 @@ async def search_template( body: t.Optional[t.Dict[str, t.Any]] = None, ) -> ObjectApiResponse[t.Any]: """ - Runs a search with a search template. + Run a search with a search template. ``_ @@ -4759,8 +4778,8 @@ async def termvectors( body: t.Optional[t.Dict[str, t.Any]] = None, ) -> ObjectApiResponse[t.Any]: """ - Get term vector information. Returns information and statistics about terms in - the fields of a particular document. + Get term vector information. Get information and statistics about terms in the + fields of a particular document. ``_ diff --git a/elasticsearch/_async/client/async_search.py b/elasticsearch/_async/client/async_search.py index d5f4e78b8..0093273ca 100644 --- a/elasticsearch/_async/client/async_search.py +++ b/elasticsearch/_async/client/async_search.py @@ -148,10 +148,10 @@ async def status( pretty: t.Optional[bool] = None, ) -> ObjectApiResponse[t.Any]: """ - Get async search status. Retrieve the status of a previously submitted async - search request given its identifier, without retrieving search results. If the - Elasticsearch security features are enabled, use of this API is restricted to - the `monitoring_user` role. + Get the async search status. Get the status of a previously submitted async search + request given its identifier, without retrieving search results. If the Elasticsearch + security features are enabled, use of this API is restricted to the `monitoring_user` + role. ``_ diff --git a/elasticsearch/_async/client/autoscaling.py b/elasticsearch/_async/client/autoscaling.py index f4bdd444e..cb2eccabf 100644 --- a/elasticsearch/_async/client/autoscaling.py +++ b/elasticsearch/_async/client/autoscaling.py @@ -36,7 +36,8 @@ async def delete_autoscaling_policy( pretty: t.Optional[bool] = None, ) -> ObjectApiResponse[t.Any]: """ - Deletes an autoscaling policy. Designed for indirect use by ECE/ESS and ECK. + Delete an autoscaling policy. NOTE: This feature is designed for indirect use + by Elasticsearch Service, Elastic Cloud Enterprise, and Elastic Cloud on Kubernetes. Direct use is not supported. ``_ @@ -76,8 +77,18 @@ async def get_autoscaling_capacity( pretty: t.Optional[bool] = None, ) -> ObjectApiResponse[t.Any]: """ - Gets the current autoscaling capacity based on the configured autoscaling policy. - Designed for indirect use by ECE/ESS and ECK. Direct use is not supported. + Get the autoscaling capacity. NOTE: This feature is designed for indirect use + by Elasticsearch Service, Elastic Cloud Enterprise, and Elastic Cloud on Kubernetes. + Direct use is not supported. This API gets the current autoscaling capacity based + on the configured autoscaling policy. It will return information to size the + cluster appropriately to the current workload. The `required_capacity` is calculated + as the maximum of the `required_capacity` result of all individual deciders that + are enabled for the policy. The operator should verify that the `current_nodes` + match the operator’s knowledge of the cluster to avoid making autoscaling decisions + based on stale or incomplete information. The response contains decider-specific + information you can use to diagnose how and why autoscaling determined a certain + capacity was required. This information is provided for diagnosis only. Do not + use this information to make autoscaling decisions. ``_ """ @@ -113,7 +124,8 @@ async def get_autoscaling_policy( pretty: t.Optional[bool] = None, ) -> ObjectApiResponse[t.Any]: """ - Retrieves an autoscaling policy. Designed for indirect use by ECE/ESS and ECK. + Get an autoscaling policy. NOTE: This feature is designed for indirect use by + Elasticsearch Service, Elastic Cloud Enterprise, and Elastic Cloud on Kubernetes. Direct use is not supported. ``_ @@ -158,8 +170,9 @@ async def put_autoscaling_policy( pretty: t.Optional[bool] = None, ) -> ObjectApiResponse[t.Any]: """ - Creates a new autoscaling policy. Designed for indirect use by ECE/ESS and ECK. - Direct use is not supported. + Create or update an autoscaling policy. NOTE: This feature is designed for indirect + use by Elasticsearch Service, Elastic Cloud Enterprise, and Elastic Cloud on + Kubernetes. Direct use is not supported. ``_ diff --git a/elasticsearch/_async/client/security.py b/elasticsearch/_async/client/security.py index b28da2d6f..f7e3d7ff7 100644 --- a/elasticsearch/_async/client/security.py +++ b/elasticsearch/_async/client/security.py @@ -617,6 +617,90 @@ async def create_api_key( path_parts=__path_parts, ) + @_rewrite_parameters( + body_fields=("access", "name", "expiration", "metadata"), + ) + async def create_cross_cluster_api_key( + self, + *, + access: t.Optional[t.Mapping[str, t.Any]] = None, + name: t.Optional[str] = None, + error_trace: t.Optional[bool] = None, + expiration: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None, + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, + human: t.Optional[bool] = None, + metadata: t.Optional[t.Mapping[str, t.Any]] = None, + pretty: t.Optional[bool] = None, + body: t.Optional[t.Dict[str, t.Any]] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Create a cross-cluster API key. Create an API key of the `cross_cluster` type + for the API key based remote cluster access. A `cross_cluster` API key cannot + be used to authenticate through the REST interface. IMPORTANT: To authenticate + this request you must use a credential that is not an API key. Even if you use + an API key that has the required privilege, the API returns an error. Cross-cluster + API keys are created by the Elasticsearch API key service, which is automatically + enabled. NOTE: Unlike REST API keys, a cross-cluster API key does not capture + permissions of the authenticated user. The API key’s effective permission is + exactly as specified with the `access` property. A successful request returns + a JSON structure that contains the API key, its unique ID, and its name. If applicable, + it also returns expiration information for the API key in milliseconds. By default, + API keys never expire. You can specify expiration information when you create + the API keys. Cross-cluster API keys can only be updated with the update cross-cluster + API key API. Attempting to update them with the update REST API key API or the + bulk update REST API keys API will result in an error. + + ``_ + + :param access: The access to be granted to this API key. The access is composed + of permissions for cross-cluster search and cross-cluster replication. At + least one of them must be specified. NOTE: No explicit privileges should + be specified for either search or replication access. The creation process + automatically converts the access specification to a role descriptor which + has relevant privileges assigned accordingly. + :param name: Specifies the name for this API key. + :param expiration: Expiration time for the API key. By default, API keys never + expire. + :param metadata: Arbitrary metadata that you want to associate with the API key. + It supports nested data structure. Within the metadata object, keys beginning + with `_` are reserved for system usage. + """ + if access is None and body is None: + raise ValueError("Empty value passed for parameter 'access'") + if name is None and body is None: + raise ValueError("Empty value passed for parameter 'name'") + __path_parts: t.Dict[str, str] = {} + __path = "/_security/cross_cluster/api_key" + __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 access is not None: + __body["access"] = access + if name is not None: + __body["name"] = name + if expiration is not None: + __body["expiration"] = expiration + if metadata is not None: + __body["metadata"] = metadata + __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="security.create_cross_cluster_api_key", + path_parts=__path_parts, + ) + @_rewrite_parameters() async def create_service_token( self, @@ -3491,6 +3575,74 @@ async def update_api_key( path_parts=__path_parts, ) + @_rewrite_parameters( + body_fields=("access", "expiration", "metadata"), + ) + async def update_cross_cluster_api_key( + self, + *, + id: str, + access: t.Optional[t.Mapping[str, t.Any]] = None, + error_trace: t.Optional[bool] = None, + expiration: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None, + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, + human: t.Optional[bool] = None, + metadata: t.Optional[t.Mapping[str, t.Any]] = None, + pretty: t.Optional[bool] = None, + body: t.Optional[t.Dict[str, t.Any]] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Update a cross-cluster API key. Update the attributes of an existing cross-cluster + API key, which is used for API key based remote cluster access. + + ``_ + + :param id: The ID of the cross-cluster API key to update. + :param access: The access to be granted to this API key. The access is composed + of permissions for cross cluster search and cross cluster replication. At + least one of them must be specified. When specified, the new access assignment + fully replaces the previously assigned access. + :param expiration: Expiration time for the API key. By default, API keys never + expire. This property can be omitted to leave the value unchanged. + :param metadata: Arbitrary metadata that you want to associate with the API key. + It supports nested data structure. Within the metadata object, keys beginning + with `_` are reserved for system usage. When specified, this information + fully replaces metadata previously associated with the API key. + """ + if id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'id'") + if access is None and body is None: + raise ValueError("Empty value passed for parameter 'access'") + __path_parts: t.Dict[str, str] = {"id": _quote(id)} + __path = f'/_security/cross_cluster/api_key/{__path_parts["id"]}' + __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 access is not None: + __body["access"] = access + if expiration is not None: + __body["expiration"] = expiration + if metadata is not None: + __body["metadata"] = metadata + __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, + endpoint_id="security.update_cross_cluster_api_key", + path_parts=__path_parts, + ) + @_rewrite_parameters( body_fields=("data", "labels"), ) diff --git a/elasticsearch/_sync/client/__init__.py b/elasticsearch/_sync/client/__init__.py index d92347291..adf877523 100644 --- a/elasticsearch/_sync/client/__init__.py +++ b/elasticsearch/_sync/client/__init__.py @@ -741,7 +741,8 @@ def clear_scroll( body: t.Optional[t.Dict[str, t.Any]] = None, ) -> ObjectApiResponse[t.Any]: """ - Clears the search context and results for a scrolling search. + Clear a scrolling search. Clear the search context and results for a scrolling + search. ``_ @@ -791,7 +792,11 @@ def close_point_in_time( body: t.Optional[t.Dict[str, t.Any]] = None, ) -> ObjectApiResponse[t.Any]: """ - Closes a point-in-time. + Close a point in time. A point in time must be opened explicitly before being + used in search requests. The `keep_alive` parameter tells Elasticsearch how long + it should persist. A point in time is automatically closed when the `keep_alive` + period has elapsed. However, keeping points in time has a cost; close them as + soon as they are no longer required for search requests. ``_ @@ -1842,10 +1847,11 @@ def field_caps( body: t.Optional[t.Dict[str, t.Any]] = None, ) -> ObjectApiResponse[t.Any]: """ - The field capabilities API returns the information about the capabilities of - fields among multiple indices. The field capabilities API returns runtime fields - like any other field. For example, a runtime field with a type of keyword is - returned as any other field that belongs to the `keyword` family. + Get the field capabilities. Get information about the capabilities of fields + among multiple indices. For data streams, the API returns field capabilities + among the stream’s backing indices. It returns runtime fields like any other + field. For example, a runtime field with a type of keyword is returned the same + as any other field that belongs to the `keyword` family. ``_ @@ -2488,6 +2494,7 @@ def info( ), parameter_aliases={"_source": "source"}, ) + @_stability_warning(Stability.EXPERIMENTAL) def knn_search( self, *, @@ -2508,7 +2515,15 @@ def knn_search( body: t.Optional[t.Dict[str, t.Any]] = None, ) -> ObjectApiResponse[t.Any]: """ - Performs a kNN search. + Run a knn search. NOTE: The kNN search API has been replaced by the `knn` option + in the search API. Perform a k-nearest neighbor (kNN) search on a dense_vector + field and return the matching documents. Given a query vector, the API finds + the k closest vectors and returns those documents as search hits. Elasticsearch + uses the HNSW algorithm to support efficient kNN search. Like most kNN algorithms, + HNSW is an approximate method that sacrifices result accuracy for improved search + speed. This means the results returned are not always the true k closest neighbors. + The kNN search API supports restricting the search using a filter. The search + will return the top k documents that also match the filter query. ``_ @@ -2871,7 +2886,7 @@ def msearch_template( typed_keys: t.Optional[bool] = None, ) -> ObjectApiResponse[t.Any]: """ - Runs multiple templated searches with a single request. + Run multiple templated searches. ``_ @@ -3081,13 +3096,15 @@ def open_point_in_time( body: t.Optional[t.Dict[str, t.Any]] = None, ) -> ObjectApiResponse[t.Any]: """ - A search request by default executes against the most recent visible data of - the target indices, which is called point in time. Elasticsearch pit (point in - time) is a lightweight view into the state of the data as it existed when initiated. - In some cases, it’s preferred to perform multiple search requests using the same - point in time. For example, if refreshes happen between `search_after` requests, - then the results of those requests might not be consistent as changes happening - between searches are only visible to the more recent point in time. + Open a point in time. A search request by default runs against the most recent + visible data of the target indices, which is called point in time. Elasticsearch + pit (point in time) is a lightweight view into the state of the data as it existed + when initiated. In some cases, it’s preferred to perform multiple search requests + using the same point in time. For example, if refreshes happen between `search_after` + requests, then the results of those requests might not be consistent as changes + happening between searches are only visible to the more recent point in time. + A point in time must be opened explicitly before being used in search requests. + The `keep_alive` parameter tells Elasticsearch how long it should persist. ``_ @@ -3254,8 +3271,8 @@ def rank_eval( body: t.Optional[t.Dict[str, t.Any]] = None, ) -> ObjectApiResponse[t.Any]: """ - Enables you to evaluate the quality of ranked search results over a set of typical - search queries. + Evaluate ranked search results. Evaluate the quality of ranked search results + over a set of typical search queries. ``_ @@ -3499,7 +3516,7 @@ def render_search_template( body: t.Optional[t.Dict[str, t.Any]] = None, ) -> ObjectApiResponse[t.Any]: """ - Renders a search template as a search request body. + Render a search template. Render a search template as a search request body. ``_ @@ -3831,9 +3848,9 @@ def search( body: t.Optional[t.Dict[str, t.Any]] = None, ) -> ObjectApiResponse[t.Any]: """ - Returns search hits that match the query defined in the request. You can provide - search queries using the `q` query string parameter or the request body. If both - are specified, only the query parameter is used. + Run a search. Get search hits that match the query defined in the request. You + can provide search queries using the `q` query string parameter or the request + body. If both are specified, only the query parameter is used. ``_ @@ -4263,7 +4280,7 @@ def search_mvt( body: t.Optional[t.Dict[str, t.Any]] = None, ) -> BinaryApiResponse: """ - Search a vector tile. Searches a vector tile for geospatial values. + Search a vector tile. Search a vector tile for geospatial values. ``_ @@ -4417,8 +4434,10 @@ def search_shards( routing: t.Optional[str] = None, ) -> ObjectApiResponse[t.Any]: """ - Returns information about the indices and shards that a search request would - be executed against. + Get the search shards. Get the indices and shards that a search request would + be run against. This information can be useful for working out issues or planning + optimizations with routing and shard preferences. When filtered aliases are used, + the filter is returned as part of the indices section. ``_ @@ -4519,7 +4538,7 @@ def search_template( body: t.Optional[t.Dict[str, t.Any]] = None, ) -> ObjectApiResponse[t.Any]: """ - Runs a search with a search template. + Run a search with a search template. ``_ @@ -4757,8 +4776,8 @@ def termvectors( body: t.Optional[t.Dict[str, t.Any]] = None, ) -> ObjectApiResponse[t.Any]: """ - Get term vector information. Returns information and statistics about terms in - the fields of a particular document. + Get term vector information. Get information and statistics about terms in the + fields of a particular document. ``_ diff --git a/elasticsearch/_sync/client/async_search.py b/elasticsearch/_sync/client/async_search.py index b0b2bdaf9..147553dc3 100644 --- a/elasticsearch/_sync/client/async_search.py +++ b/elasticsearch/_sync/client/async_search.py @@ -148,10 +148,10 @@ def status( pretty: t.Optional[bool] = None, ) -> ObjectApiResponse[t.Any]: """ - Get async search status. Retrieve the status of a previously submitted async - search request given its identifier, without retrieving search results. If the - Elasticsearch security features are enabled, use of this API is restricted to - the `monitoring_user` role. + Get the async search status. Get the status of a previously submitted async search + request given its identifier, without retrieving search results. If the Elasticsearch + security features are enabled, use of this API is restricted to the `monitoring_user` + role. ``_ diff --git a/elasticsearch/_sync/client/autoscaling.py b/elasticsearch/_sync/client/autoscaling.py index a39e1ba35..6dc45d2a5 100644 --- a/elasticsearch/_sync/client/autoscaling.py +++ b/elasticsearch/_sync/client/autoscaling.py @@ -36,7 +36,8 @@ def delete_autoscaling_policy( pretty: t.Optional[bool] = None, ) -> ObjectApiResponse[t.Any]: """ - Deletes an autoscaling policy. Designed for indirect use by ECE/ESS and ECK. + Delete an autoscaling policy. NOTE: This feature is designed for indirect use + by Elasticsearch Service, Elastic Cloud Enterprise, and Elastic Cloud on Kubernetes. Direct use is not supported. ``_ @@ -76,8 +77,18 @@ def get_autoscaling_capacity( pretty: t.Optional[bool] = None, ) -> ObjectApiResponse[t.Any]: """ - Gets the current autoscaling capacity based on the configured autoscaling policy. - Designed for indirect use by ECE/ESS and ECK. Direct use is not supported. + Get the autoscaling capacity. NOTE: This feature is designed for indirect use + by Elasticsearch Service, Elastic Cloud Enterprise, and Elastic Cloud on Kubernetes. + Direct use is not supported. This API gets the current autoscaling capacity based + on the configured autoscaling policy. It will return information to size the + cluster appropriately to the current workload. The `required_capacity` is calculated + as the maximum of the `required_capacity` result of all individual deciders that + are enabled for the policy. The operator should verify that the `current_nodes` + match the operator’s knowledge of the cluster to avoid making autoscaling decisions + based on stale or incomplete information. The response contains decider-specific + information you can use to diagnose how and why autoscaling determined a certain + capacity was required. This information is provided for diagnosis only. Do not + use this information to make autoscaling decisions. ``_ """ @@ -113,7 +124,8 @@ def get_autoscaling_policy( pretty: t.Optional[bool] = None, ) -> ObjectApiResponse[t.Any]: """ - Retrieves an autoscaling policy. Designed for indirect use by ECE/ESS and ECK. + Get an autoscaling policy. NOTE: This feature is designed for indirect use by + Elasticsearch Service, Elastic Cloud Enterprise, and Elastic Cloud on Kubernetes. Direct use is not supported. ``_ @@ -158,8 +170,9 @@ def put_autoscaling_policy( pretty: t.Optional[bool] = None, ) -> ObjectApiResponse[t.Any]: """ - Creates a new autoscaling policy. Designed for indirect use by ECE/ESS and ECK. - Direct use is not supported. + Create or update an autoscaling policy. NOTE: This feature is designed for indirect + use by Elasticsearch Service, Elastic Cloud Enterprise, and Elastic Cloud on + Kubernetes. Direct use is not supported. ``_ diff --git a/elasticsearch/_sync/client/security.py b/elasticsearch/_sync/client/security.py index fd4b1cac9..35d35a8db 100644 --- a/elasticsearch/_sync/client/security.py +++ b/elasticsearch/_sync/client/security.py @@ -617,6 +617,90 @@ def create_api_key( path_parts=__path_parts, ) + @_rewrite_parameters( + body_fields=("access", "name", "expiration", "metadata"), + ) + def create_cross_cluster_api_key( + self, + *, + access: t.Optional[t.Mapping[str, t.Any]] = None, + name: t.Optional[str] = None, + error_trace: t.Optional[bool] = None, + expiration: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None, + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, + human: t.Optional[bool] = None, + metadata: t.Optional[t.Mapping[str, t.Any]] = None, + pretty: t.Optional[bool] = None, + body: t.Optional[t.Dict[str, t.Any]] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Create a cross-cluster API key. Create an API key of the `cross_cluster` type + for the API key based remote cluster access. A `cross_cluster` API key cannot + be used to authenticate through the REST interface. IMPORTANT: To authenticate + this request you must use a credential that is not an API key. Even if you use + an API key that has the required privilege, the API returns an error. Cross-cluster + API keys are created by the Elasticsearch API key service, which is automatically + enabled. NOTE: Unlike REST API keys, a cross-cluster API key does not capture + permissions of the authenticated user. The API key’s effective permission is + exactly as specified with the `access` property. A successful request returns + a JSON structure that contains the API key, its unique ID, and its name. If applicable, + it also returns expiration information for the API key in milliseconds. By default, + API keys never expire. You can specify expiration information when you create + the API keys. Cross-cluster API keys can only be updated with the update cross-cluster + API key API. Attempting to update them with the update REST API key API or the + bulk update REST API keys API will result in an error. + + ``_ + + :param access: The access to be granted to this API key. The access is composed + of permissions for cross-cluster search and cross-cluster replication. At + least one of them must be specified. NOTE: No explicit privileges should + be specified for either search or replication access. The creation process + automatically converts the access specification to a role descriptor which + has relevant privileges assigned accordingly. + :param name: Specifies the name for this API key. + :param expiration: Expiration time for the API key. By default, API keys never + expire. + :param metadata: Arbitrary metadata that you want to associate with the API key. + It supports nested data structure. Within the metadata object, keys beginning + with `_` are reserved for system usage. + """ + if access is None and body is None: + raise ValueError("Empty value passed for parameter 'access'") + if name is None and body is None: + raise ValueError("Empty value passed for parameter 'name'") + __path_parts: t.Dict[str, str] = {} + __path = "/_security/cross_cluster/api_key" + __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 access is not None: + __body["access"] = access + if name is not None: + __body["name"] = name + if expiration is not None: + __body["expiration"] = expiration + if metadata is not None: + __body["metadata"] = metadata + __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="security.create_cross_cluster_api_key", + path_parts=__path_parts, + ) + @_rewrite_parameters() def create_service_token( self, @@ -3491,6 +3575,74 @@ def update_api_key( path_parts=__path_parts, ) + @_rewrite_parameters( + body_fields=("access", "expiration", "metadata"), + ) + def update_cross_cluster_api_key( + self, + *, + id: str, + access: t.Optional[t.Mapping[str, t.Any]] = None, + error_trace: t.Optional[bool] = None, + expiration: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None, + filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, + human: t.Optional[bool] = None, + metadata: t.Optional[t.Mapping[str, t.Any]] = None, + pretty: t.Optional[bool] = None, + body: t.Optional[t.Dict[str, t.Any]] = None, + ) -> ObjectApiResponse[t.Any]: + """ + Update a cross-cluster API key. Update the attributes of an existing cross-cluster + API key, which is used for API key based remote cluster access. + + ``_ + + :param id: The ID of the cross-cluster API key to update. + :param access: The access to be granted to this API key. The access is composed + of permissions for cross cluster search and cross cluster replication. At + least one of them must be specified. When specified, the new access assignment + fully replaces the previously assigned access. + :param expiration: Expiration time for the API key. By default, API keys never + expire. This property can be omitted to leave the value unchanged. + :param metadata: Arbitrary metadata that you want to associate with the API key. + It supports nested data structure. Within the metadata object, keys beginning + with `_` are reserved for system usage. When specified, this information + fully replaces metadata previously associated with the API key. + """ + if id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'id'") + if access is None and body is None: + raise ValueError("Empty value passed for parameter 'access'") + __path_parts: t.Dict[str, str] = {"id": _quote(id)} + __path = f'/_security/cross_cluster/api_key/{__path_parts["id"]}' + __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 access is not None: + __body["access"] = access + if expiration is not None: + __body["expiration"] = expiration + if metadata is not None: + __body["metadata"] = metadata + __headers = {"accept": "application/json", "content-type": "application/json"} + return self.perform_request( # type: ignore[return-value] + "PUT", + __path, + params=__query, + headers=__headers, + body=__body, + endpoint_id="security.update_cross_cluster_api_key", + path_parts=__path_parts, + ) + @_rewrite_parameters( body_fields=("data", "labels"), )