From 112e85d99b9cdafac3e967fb5c605f32e5f13d0c Mon Sep 17 00:00:00 2001 From: Seth Michael Larson Date: Mon, 13 Jul 2020 09:33:33 -0500 Subject: [PATCH] Update APIs on 7.x --- elasticsearch/_async/client/eql.py | 45 ++++++++++++++++++++++++- elasticsearch/_async/client/indices.py | 41 ++++++++++++++++++++-- elasticsearch/_async/client/ml.py | 21 ++++++++++++ elasticsearch/_async/client/security.py | 20 +++++++++++ elasticsearch/_async/client/xpack.py | 4 ++- elasticsearch/client/eql.py | 45 ++++++++++++++++++++++++- elasticsearch/client/indices.py | 41 ++++++++++++++++++++-- elasticsearch/client/ml.py | 21 ++++++++++++ elasticsearch/client/security.py | 20 +++++++++++ elasticsearch/client/xpack.py | 4 ++- 10 files changed, 252 insertions(+), 10 deletions(-) diff --git a/elasticsearch/_async/client/eql.py b/elasticsearch/_async/client/eql.py index 3d0504ac..3f2ff9fe 100644 --- a/elasticsearch/_async/client/eql.py +++ b/elasticsearch/_async/client/eql.py @@ -19,7 +19,7 @@ from .utils import NamespacedClient, SKIP_IN_PATH, query_params, _make_path class EqlClient(NamespacedClient): - @query_params() + @query_params("keep_alive", "keep_on_completion", "wait_for_completion_timeout") async def search(self, index, body, params=None, headers=None): """ Returns results matching a query expressed in Event Query Language (EQL) @@ -28,6 +28,13 @@ class EqlClient(NamespacedClient): :arg index: The name of the index to scope the operation :arg body: Eql request body. Use the `query` to limit the query scope. + :arg keep_alive: Update the time interval in which the results + (partial or final) for this search will be available Default: 5d + :arg keep_on_completion: Control whether the response should be + stored in the cluster if it completed within the provided + [wait_for_completion] time (default: false) + :arg wait_for_completion_timeout: Specify the time that the + request should block waiting for the final response """ for param in (index, body): if param in SKIP_IN_PATH: @@ -40,3 +47,39 @@ class EqlClient(NamespacedClient): headers=headers, body=body, ) + + @query_params() + async def delete(self, id, params=None, headers=None): + """ + Deletes an async EQL search by ID. If the search is still running, the search + request will be cancelled. Otherwise, the saved search results are deleted. + ``_ + + :arg id: The async search ID + """ + if id in SKIP_IN_PATH: + raise ValueError("Empty value passed for a required argument 'id'.") + + return await self.transport.perform_request( + "DELETE", _make_path("_eql", "search", id), params=params, headers=headers + ) + + @query_params("keep_alive", "wait_for_completion_timeout") + async def get(self, id, params=None, headers=None): + """ + Returns async results from previously executed Event Query Language (EQL) + search + ``_ + + :arg id: The async search ID + :arg keep_alive: Update the time interval in which the results + (partial or final) for this search will be available Default: 5d + :arg wait_for_completion_timeout: Specify the time that the + request should block waiting for the final response + """ + if id in SKIP_IN_PATH: + raise ValueError("Empty value passed for a required argument 'id'.") + + return await self.transport.perform_request( + "GET", _make_path("_eql", "search", id), params=params, headers=headers + ) diff --git a/elasticsearch/_async/client/indices.py b/elasticsearch/_async/client/indices.py index b4e8c252..dbd19e41 100644 --- a/elasticsearch/_async/client/indices.py +++ b/elasticsearch/_async/client/indices.py @@ -1314,7 +1314,8 @@ class IndicesClient(NamespacedClient): Deletes a data stream. ``_ - :arg name: The name of the data stream + :arg name: A comma-separated list of data streams to delete; use + `*` to delete all data streams """ if name in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'name'.") @@ -1443,8 +1444,8 @@ class IndicesClient(NamespacedClient): Returns data streams. ``_ - :arg name: The name or wildcard expression of the requested data - streams + :arg name: A comma-separated list of data streams to get; use + `*` to get all data streams """ return await self.transport.perform_request( "GET", _make_path("_data_stream", name), params=params, headers=headers @@ -1492,3 +1493,37 @@ class IndicesClient(NamespacedClient): return await self.transport.perform_request( "GET", _make_path("_resolve", "index", name), params=params, headers=headers ) + + @query_params( + "allow_no_indices", + "expand_wildcards", + "ignore_unavailable", + "master_timeout", + "timeout", + ) + async def add_block(self, index, block, params=None, headers=None): + """ + Adds a block to an index. + ``_ + + :arg index: A comma separated list of indices to add a block to + :arg block: The block to add (one of read, write, read_only or + metadata) + :arg allow_no_indices: Whether to ignore if a wildcard indices + expression resolves into no concrete indices. (This includes `_all` + string or when no indices have been specified) + :arg expand_wildcards: Whether to expand wildcard expression to + concrete indices that are open, closed or both. Valid choices: open, + closed, hidden, none, all Default: open + :arg ignore_unavailable: Whether specified concrete indices + should be ignored when unavailable (missing or closed) + :arg master_timeout: Specify timeout for connection to master + :arg timeout: Explicit operation timeout + """ + for param in (index, block): + if param in SKIP_IN_PATH: + raise ValueError("Empty value passed for a required argument.") + + return await self.transport.perform_request( + "PUT", _make_path(index, "_block", block), params=params, headers=headers + ) diff --git a/elasticsearch/_async/client/ml.py b/elasticsearch/_async/client/ml.py index dd66fee4..ba79bc0b 100644 --- a/elasticsearch/_async/client/ml.py +++ b/elasticsearch/_async/client/ml.py @@ -1529,3 +1529,24 @@ class MlClient(NamespacedClient): headers=headers, body=body, ) + + @query_params() + async def update_data_frame_analytics(self, id, body, params=None, headers=None): + """ + Updates certain properties of a data frame analytics job. + ``_ + + :arg id: The ID of the data frame analytics to update + :arg body: The data frame analytics settings to update + """ + for param in (id, body): + if param in SKIP_IN_PATH: + raise ValueError("Empty value passed for a required argument.") + + return await self.transport.perform_request( + "POST", + _make_path("_ml", "data_frame", "analytics", id, "_update"), + params=params, + headers=headers, + body=body, + ) diff --git a/elasticsearch/_async/client/security.py b/elasticsearch/_async/client/security.py index a59faed7..f805d5c0 100644 --- a/elasticsearch/_async/client/security.py +++ b/elasticsearch/_async/client/security.py @@ -510,3 +510,23 @@ class SecurityClient(NamespacedClient): return await self.transport.perform_request( "GET", "/_security/privilege/_builtin", params=params, headers=headers ) + + @query_params() + async def clear_cached_privileges(self, application, params=None, headers=None): + """ + Evicts application privileges from the native application privileges cache. + ``_ + + :arg application: A comma-separated list of application names + """ + if application in SKIP_IN_PATH: + raise ValueError( + "Empty value passed for a required argument 'application'." + ) + + return await self.transport.perform_request( + "POST", + _make_path("_security", "privilege", application, "_clear_cache"), + params=params, + headers=headers, + ) diff --git a/elasticsearch/_async/client/xpack.py b/elasticsearch/_async/client/xpack.py index 00a18c4e..9cb68bd6 100644 --- a/elasticsearch/_async/client/xpack.py +++ b/elasticsearch/_async/client/xpack.py @@ -23,12 +23,14 @@ class XPackClient(NamespacedClient): return getattr(self.client, attr_name) # AUTO-GENERATED-API-DEFINITIONS # - @query_params("categories") + @query_params("accept_enterprise", "categories") async def info(self, params=None, headers=None): """ Retrieves information about the installed X-Pack features. ``_ + :arg accept_enterprise: If an enterprise license is installed, + return the type and mode as 'enterprise' (default: false) :arg categories: Comma-separated list of info categories. Can be any of: build, license, features """ diff --git a/elasticsearch/client/eql.py b/elasticsearch/client/eql.py index fd218ade..e954f20f 100644 --- a/elasticsearch/client/eql.py +++ b/elasticsearch/client/eql.py @@ -19,7 +19,7 @@ from .utils import NamespacedClient, SKIP_IN_PATH, query_params, _make_path class EqlClient(NamespacedClient): - @query_params() + @query_params("keep_alive", "keep_on_completion", "wait_for_completion_timeout") def search(self, index, body, params=None, headers=None): """ Returns results matching a query expressed in Event Query Language (EQL) @@ -28,6 +28,13 @@ class EqlClient(NamespacedClient): :arg index: The name of the index to scope the operation :arg body: Eql request body. Use the `query` to limit the query scope. + :arg keep_alive: Update the time interval in which the results + (partial or final) for this search will be available Default: 5d + :arg keep_on_completion: Control whether the response should be + stored in the cluster if it completed within the provided + [wait_for_completion] time (default: false) + :arg wait_for_completion_timeout: Specify the time that the + request should block waiting for the final response """ for param in (index, body): if param in SKIP_IN_PATH: @@ -40,3 +47,39 @@ class EqlClient(NamespacedClient): headers=headers, body=body, ) + + @query_params() + def delete(self, id, params=None, headers=None): + """ + Deletes an async EQL search by ID. If the search is still running, the search + request will be cancelled. Otherwise, the saved search results are deleted. + ``_ + + :arg id: The async search ID + """ + if id in SKIP_IN_PATH: + raise ValueError("Empty value passed for a required argument 'id'.") + + return self.transport.perform_request( + "DELETE", _make_path("_eql", "search", id), params=params, headers=headers + ) + + @query_params("keep_alive", "wait_for_completion_timeout") + def get(self, id, params=None, headers=None): + """ + Returns async results from previously executed Event Query Language (EQL) + search + ``_ + + :arg id: The async search ID + :arg keep_alive: Update the time interval in which the results + (partial or final) for this search will be available Default: 5d + :arg wait_for_completion_timeout: Specify the time that the + request should block waiting for the final response + """ + if id in SKIP_IN_PATH: + raise ValueError("Empty value passed for a required argument 'id'.") + + return self.transport.perform_request( + "GET", _make_path("_eql", "search", id), params=params, headers=headers + ) diff --git a/elasticsearch/client/indices.py b/elasticsearch/client/indices.py index c818612f..05f4725b 100644 --- a/elasticsearch/client/indices.py +++ b/elasticsearch/client/indices.py @@ -1310,7 +1310,8 @@ class IndicesClient(NamespacedClient): Deletes a data stream. ``_ - :arg name: The name of the data stream + :arg name: A comma-separated list of data streams to delete; use + `*` to delete all data streams """ if name in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'name'.") @@ -1439,8 +1440,8 @@ class IndicesClient(NamespacedClient): Returns data streams. ``_ - :arg name: The name or wildcard expression of the requested data - streams + :arg name: A comma-separated list of data streams to get; use + `*` to get all data streams """ return self.transport.perform_request( "GET", _make_path("_data_stream", name), params=params, headers=headers @@ -1488,3 +1489,37 @@ class IndicesClient(NamespacedClient): return self.transport.perform_request( "GET", _make_path("_resolve", "index", name), params=params, headers=headers ) + + @query_params( + "allow_no_indices", + "expand_wildcards", + "ignore_unavailable", + "master_timeout", + "timeout", + ) + def add_block(self, index, block, params=None, headers=None): + """ + Adds a block to an index. + ``_ + + :arg index: A comma separated list of indices to add a block to + :arg block: The block to add (one of read, write, read_only or + metadata) + :arg allow_no_indices: Whether to ignore if a wildcard indices + expression resolves into no concrete indices. (This includes `_all` + string or when no indices have been specified) + :arg expand_wildcards: Whether to expand wildcard expression to + concrete indices that are open, closed or both. Valid choices: open, + closed, hidden, none, all Default: open + :arg ignore_unavailable: Whether specified concrete indices + should be ignored when unavailable (missing or closed) + :arg master_timeout: Specify timeout for connection to master + :arg timeout: Explicit operation timeout + """ + for param in (index, block): + if param in SKIP_IN_PATH: + raise ValueError("Empty value passed for a required argument.") + + return self.transport.perform_request( + "PUT", _make_path(index, "_block", block), params=params, headers=headers + ) diff --git a/elasticsearch/client/ml.py b/elasticsearch/client/ml.py index 8a1f142d..705a2bc4 100644 --- a/elasticsearch/client/ml.py +++ b/elasticsearch/client/ml.py @@ -1515,3 +1515,24 @@ class MlClient(NamespacedClient): headers=headers, body=body, ) + + @query_params() + def update_data_frame_analytics(self, id, body, params=None, headers=None): + """ + Updates certain properties of a data frame analytics job. + ``_ + + :arg id: The ID of the data frame analytics to update + :arg body: The data frame analytics settings to update + """ + for param in (id, body): + if param in SKIP_IN_PATH: + raise ValueError("Empty value passed for a required argument.") + + return self.transport.perform_request( + "POST", + _make_path("_ml", "data_frame", "analytics", id, "_update"), + params=params, + headers=headers, + body=body, + ) diff --git a/elasticsearch/client/security.py b/elasticsearch/client/security.py index 455abeea..059cc0d4 100644 --- a/elasticsearch/client/security.py +++ b/elasticsearch/client/security.py @@ -508,3 +508,23 @@ class SecurityClient(NamespacedClient): return self.transport.perform_request( "GET", "/_security/privilege/_builtin", params=params, headers=headers ) + + @query_params() + def clear_cached_privileges(self, application, params=None, headers=None): + """ + Evicts application privileges from the native application privileges cache. + ``_ + + :arg application: A comma-separated list of application names + """ + if application in SKIP_IN_PATH: + raise ValueError( + "Empty value passed for a required argument 'application'." + ) + + return self.transport.perform_request( + "POST", + _make_path("_security", "privilege", application, "_clear_cache"), + params=params, + headers=headers, + ) diff --git a/elasticsearch/client/xpack.py b/elasticsearch/client/xpack.py index db717a5c..76f857fe 100644 --- a/elasticsearch/client/xpack.py +++ b/elasticsearch/client/xpack.py @@ -23,12 +23,14 @@ class XPackClient(NamespacedClient): return getattr(self.client, attr_name) # AUTO-GENERATED-API-DEFINITIONS # - @query_params("categories") + @query_params("accept_enterprise", "categories") def info(self, params=None, headers=None): """ Retrieves information about the installed X-Pack features. ``_ + :arg accept_enterprise: If an enterprise license is installed, + return the type and mode as 'enterprise' (default: false) :arg categories: Comma-separated list of info categories. Can be any of: build, license, features """