diff --git a/elasticsearch/_async/client/__init__.py b/elasticsearch/_async/client/__init__.py index f93281a7..76c9d6f8 100644 --- a/elasticsearch/_async/client/__init__.py +++ b/elasticsearch/_async/client/__init__.py @@ -6,11 +6,7 @@ from __future__ import unicode_literals import logging -from ..transport import Transport -from ..exceptions import TransportError -from ..compat import string_types, urlparse, unquote -from .async_search import AsyncSearchClient -from .autoscaling import AutoscalingClient +from ..transport import AsyncTransport, TransportError from .indices import IndicesClient from .ingest import IngestClient from .cluster import ClusterClient @@ -20,10 +16,14 @@ from .remote import RemoteClient from .snapshot import SnapshotClient from .tasks import TasksClient from .xpack import XPackClient -from .utils import query_params, _make_path, SKIP_IN_PATH, _bulk_body +from .utils import query_params, _make_path, SKIP_IN_PATH, _bulk_body, _normalize_hosts # xpack APIs +from .async_search import AsyncSearchClient +from .autoscaling import AutoscalingClient from .ccr import CcrClient +from .data_frame import Data_FrameClient +from .deprecation import DeprecationClient from .eql import EqlClient from .graph import GraphClient from .ilm import IlmClient @@ -45,52 +45,7 @@ from .transform import TransformClient logger = logging.getLogger("elasticsearch") -def _normalize_hosts(hosts): - """ - Helper function to transform hosts argument to - :class:`~elasticsearch.Elasticsearch` to a list of dicts. - """ - # if hosts are empty, just defer to defaults down the line - if hosts is None: - return [{}] - - # passed in just one string - if isinstance(hosts, string_types): - hosts = [hosts] - - out = [] - # normalize hosts to dicts - for host in hosts: - if isinstance(host, string_types): - if "://" not in host: - host = "//%s" % host - - parsed_url = urlparse(host) - h = {"host": parsed_url.hostname} - - if parsed_url.port: - h["port"] = parsed_url.port - - if parsed_url.scheme == "https": - h["port"] = parsed_url.port or 443 - h["use_ssl"] = True - - if parsed_url.username or parsed_url.password: - h["http_auth"] = "%s:%s" % ( - unquote(parsed_url.username), - unquote(parsed_url.password), - ) - - if parsed_url.path and parsed_url.path != "/": - h["url_prefix"] = parsed_url.path - - out.append(h) - else: - out.append(host) - return out - - -class Elasticsearch(object): +class AsyncElasticsearch(object): """ Elasticsearch low-level client. Provides a straightforward mapping from Python to ES REST endpoints. @@ -215,7 +170,7 @@ class Elasticsearch(object): """ - def __init__(self, hosts=None, transport_class=Transport, **kwargs): + def __init__(self, hosts=None, transport_class=AsyncTransport, **kwargs): """ :arg hosts: list of nodes, or a single node, we should connect to. Node should be a dictionary ({"host": "localhost", "port": 9200}), @@ -233,8 +188,6 @@ class Elasticsearch(object): self.transport = transport_class(_normalize_hosts(hosts), **kwargs) # namespaced clients for compatibility with API names - self.async_search = AsyncSearchClient(self) - self.autoscaling = AutoscalingClient(self) self.indices = IndicesClient(self) self.ingest = IngestClient(self) self.cluster = ClusterClient(self) @@ -245,8 +198,12 @@ class Elasticsearch(object): self.tasks = TasksClient(self) self.xpack = XPackClient(self) - self.eql = EqlClient(self) + self.async_search = AsyncSearchClient(self) + self.autoscaling = AutoscalingClient(self) self.ccr = CcrClient(self) + self.data_frame = Data_FrameClient(self) + self.deprecation = DeprecationClient(self) + self.eql = EqlClient(self) self.graph = GraphClient(self) self.ilm = IlmClient(self) self.indices = IndicesClient(self) @@ -274,29 +231,40 @@ class Elasticsearch(object): return "<{cls}({cons})>".format(cls=self.__class__.__name__, cons=cons) except Exception: # probably operating on custom transport and connection_pool, ignore - return super(Elasticsearch, self).__repr__() + return super(AsyncElasticsearch, self).__repr__() + + async def __aenter__(self): + if hasattr(self.transport, "_async_call"): + await self.transport._async_call() + return self + + async def __aexit__(self, *_): + await self.close() + + async def close(self): + await self.transport.close() # AUTO-GENERATED-API-DEFINITIONS # @query_params() - def ping(self, params=None, headers=None): + async def ping(self, params=None, headers=None): """ Returns whether the cluster is running. - ``_ + ``_ """ try: - return self.transport.perform_request( + return await self.transport.perform_request( "HEAD", "/", params=params, headers=headers ) except TransportError: return False @query_params() - def info(self, params=None, headers=None): + async def info(self, params=None, headers=None): """ Returns basic information about the cluster. - ``_ + ``_ """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", "/", params=params, headers=headers ) @@ -309,11 +277,11 @@ class Elasticsearch(object): "version_type", "wait_for_active_shards", ) - def create(self, index, id, body, doc_type=None, params=None, headers=None): + async def create(self, index, id, body, doc_type=None, params=None, headers=None): """ Creates a new document in the index. Returns a 409 response when a document with a same ID already exists in the index. - ``_ + ``_ :arg index: The name of the index :arg id: Document ID @@ -341,13 +309,11 @@ class Elasticsearch(object): raise ValueError("Empty value passed for a required argument.") if doc_type in SKIP_IN_PATH: - path = _make_path(index, "_create", id) - else: - path = _make_path(index, doc_type, id) + doc_type = "_doc" - return self.transport.perform_request( - "POST" if id in SKIP_IN_PATH else "PUT", - path, + return await self.transport.perform_request( + "PUT", + _make_path(index, doc_type, id, "_create"), params=params, headers=headers, body=body, @@ -365,13 +331,16 @@ class Elasticsearch(object): "version_type", "wait_for_active_shards", ) - def index(self, index, body, id=None, params=None, headers=None): + async def index( + self, index, body, doc_type=None, id=None, params=None, headers=None + ): """ Creates or updates a document in an index. - ``_ + ``_ :arg index: The name of the index :arg body: The document + :arg doc_type: The type of the document :arg id: Document ID :arg if_primary_term: only perform the index operation if the last operation that has changed the document has the specified primary @@ -403,9 +372,12 @@ class Elasticsearch(object): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( + if doc_type is None: + doc_type = "_doc" + + return await self.transport.perform_request( "POST" if id in SKIP_IN_PATH else "PUT", - _make_path(index, "_doc", id), + _make_path(index, doc_type, id), params=params, headers=headers, body=body, @@ -421,10 +393,10 @@ class Elasticsearch(object): "timeout", "wait_for_active_shards", ) - def bulk(self, body, index=None, doc_type=None, params=None, headers=None): + async def bulk(self, body, index=None, doc_type=None, params=None, headers=None): """ Allows to perform multiple index/update/delete operations in a single request. - ``_ + ``_ :arg body: The operation definition and data (action-data pairs), separated by newlines @@ -456,7 +428,7 @@ class Elasticsearch(object): raise ValueError("Empty value passed for a required argument 'body'.") body = _bulk_body(self.transport.serializer, body) - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path(index, doc_type, "_bulk"), params=params, @@ -465,10 +437,10 @@ class Elasticsearch(object): ) @query_params() - def clear_scroll(self, body=None, scroll_id=None, params=None, headers=None): + async def clear_scroll(self, body=None, scroll_id=None, params=None, headers=None): """ Explicitly clears the search context for a scroll. - ``_ + ``_ :arg body: A comma-separated list of scroll IDs to clear if none was specified via the scroll_id parameter @@ -481,7 +453,7 @@ class Elasticsearch(object): elif scroll_id: params["scroll_id"] = scroll_id - return self.transport.perform_request( + return await self.transport.perform_request( "DELETE", "/_search/scroll", params=params, headers=headers, body=body ) @@ -501,15 +473,19 @@ class Elasticsearch(object): "routing", "terminate_after", ) - def count(self, body=None, index=None, params=None, headers=None): + async def count( + self, body=None, index=None, doc_type=None, params=None, headers=None + ): """ Returns number of documents matching a query. - ``_ + ``_ :arg body: A query to restrict the results specified with the Query DSL (optional) :arg index: A comma-separated list of indices to restrict the results + :arg doc_type: A comma-separated list of types to restrict the + results :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) @@ -538,9 +514,9 @@ class Elasticsearch(object): :arg terminate_after: The maximum count for each shard, upon reaching which the query execution will terminate early """ - return self.transport.perform_request( + return await self.transport.perform_request( "POST", - _make_path(index, "_count"), + _make_path(index, doc_type, "_count"), params=params, headers=headers, body=body, @@ -556,10 +532,10 @@ class Elasticsearch(object): "version_type", "wait_for_active_shards", ) - def delete(self, index, id, doc_type=None, params=None, headers=None): + async def delete(self, index, id, doc_type=None, params=None, headers=None): """ Removes a document from the index. - ``_ + ``_ :arg index: The name of the index :arg id: The document ID @@ -578,7 +554,7 @@ class Elasticsearch(object): :arg timeout: Explicit operation timeout :arg version: Explicit version number for concurrency control :arg version_type: Specific version type Valid choices: - internal, external, external_gte + internal, external, external_gte, force :arg wait_for_active_shards: Sets the number of shard copies that must be active before proceeding with the delete operation. Defaults to 1, meaning the primary shard only. Set to `all` for all @@ -592,7 +568,7 @@ class Elasticsearch(object): if doc_type in SKIP_IN_PATH: doc_type = "_doc" - return self.transport.perform_request( + return await self.transport.perform_request( "DELETE", _make_path(index, doc_type, id), params=params, headers=headers ) @@ -621,6 +597,7 @@ class Elasticsearch(object): "scroll_size", "search_timeout", "search_type", + "size", "slices", "sort", "stats", @@ -630,14 +607,18 @@ class Elasticsearch(object): "wait_for_active_shards", "wait_for_completion", ) - def delete_by_query(self, index, body, params=None, headers=None): + async def delete_by_query( + self, index, body, doc_type=None, params=None, headers=None + ): """ Deletes documents matching the provided query. - ``_ + ``_ :arg index: A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices :arg body: The search definition using the Query DSL + :arg doc_type: A comma-separated list of document types to + search; leave empty to perform the operation on all types :arg _source: True or false to return the _source field or not, or a list of fields to return :arg _source_excludes: A list of fields to exclude from the @@ -659,7 +640,7 @@ class Elasticsearch(object): :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 from\\_: Starting offset (default: 0) + :arg from_: Starting offset (default: 0) :arg ignore_unavailable: Whether specified concrete indices should be ignored when unavailable (missing or closed) :arg lenient: Specify whether format-based query failures (such @@ -669,7 +650,7 @@ class Elasticsearch(object): :arg preference: Specify the node or shard the operation should be performed on (default: random) :arg q: Query in the Lucene query string syntax - :arg refresh: Should the affected indexes be refreshed? + :arg refresh: Should the effected indexes be refreshed? :arg request_cache: Specify if request cache should be used for this request or not, defaults to index level setting :arg requests_per_second: The throttle for this request in sub- @@ -683,6 +664,7 @@ class Elasticsearch(object): Defaults to no timeout. :arg search_type: Search operation type Valid choices: query_then_fetch, dfs_query_then_fetch + :arg size: Deprecated, please use `max_docs` instead :arg slices: The number of slices this task should be divided into. Defaults to 1, meaning the task isn't sliced into subtasks. Can be set to `auto`. Default: 1 @@ -713,20 +695,20 @@ class Elasticsearch(object): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", - _make_path(index, "_delete_by_query"), + _make_path(index, doc_type, "_delete_by_query"), params=params, headers=headers, body=body, ) @query_params("requests_per_second") - def delete_by_query_rethrottle(self, task_id, params=None, headers=None): + async def delete_by_query_rethrottle(self, task_id, params=None, headers=None): """ Changes the number of requests per second for a particular Delete By Query operation. - ``_ + ``_ :arg task_id: The task id to rethrottle :arg requests_per_second: The throttle to set on this request in @@ -735,7 +717,7 @@ class Elasticsearch(object): if task_id in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'task_id'.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path("_delete_by_query", task_id, "_rethrottle"), params=params, @@ -743,10 +725,10 @@ class Elasticsearch(object): ) @query_params("master_timeout", "timeout") - def delete_script(self, id, params=None, headers=None): + async def delete_script(self, id, params=None, headers=None): """ Deletes a script. - ``_ + ``_ :arg id: Script ID :arg master_timeout: Specify timeout for connection to master @@ -755,7 +737,7 @@ class Elasticsearch(object): if id in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'id'.") - return self.transport.perform_request( + return await self.transport.perform_request( "DELETE", _make_path("_scripts", id), params=params, headers=headers ) @@ -771,13 +753,15 @@ class Elasticsearch(object): "version", "version_type", ) - def exists(self, index, id, params=None, headers=None): + async def exists(self, index, id, doc_type=None, params=None, headers=None): """ Returns information about whether a document exists in an index. - ``_ + ``_ :arg index: The name of the index :arg id: The document ID + :arg doc_type: The type of the document (use `_all` to fetch the + first document matching the ID across all types) :arg _source: True or false to return the _source field or not, or a list of fields to return :arg _source_excludes: A list of fields to exclude from the @@ -795,14 +779,17 @@ class Elasticsearch(object): return in the response :arg version: Explicit version number for concurrency control :arg version_type: Specific version type Valid choices: - internal, external, external_gte + internal, external, external_gte, force """ for param in (index, id): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( - "HEAD", _make_path(index, "_doc", id), params=params, headers=headers + if doc_type in SKIP_IN_PATH: + doc_type = "_doc" + + return await self.transport.perform_request( + "HEAD", _make_path(index, doc_type, id), params=params, headers=headers ) @query_params( @@ -816,10 +803,10 @@ class Elasticsearch(object): "version", "version_type", ) - def exists_source(self, index, id, doc_type=None, params=None, headers=None): + async def exists_source(self, index, id, doc_type=None, params=None, headers=None): """ Returns information about whether a document source exists in an index. - ``_ + ``_ :arg index: The name of the index :arg id: The document ID @@ -840,13 +827,13 @@ class Elasticsearch(object): :arg routing: Specific routing value :arg version: Explicit version number for concurrency control :arg version_type: Specific version type Valid choices: - internal, external, external_gte + internal, external, external_gte, force """ for param in (index, id): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( + return await self.transport.perform_request( "HEAD", _make_path(index, doc_type, id, "_source"), params=params, @@ -867,14 +854,17 @@ class Elasticsearch(object): "routing", "stored_fields", ) - def explain(self, index, id, body=None, params=None, headers=None): + async def explain( + self, index, id, body=None, doc_type=None, params=None, headers=None + ): """ Returns information about why a specific matches (or doesn't match) a query. - ``_ + ``_ :arg index: The name of the index :arg id: The document ID :arg body: The query definition using the Query DSL + :arg doc_type: The type of the document :arg _source: True or false to return the _source field or not, or a list of fields to return :arg _source_excludes: A list of fields to exclude from the @@ -901,9 +891,12 @@ class Elasticsearch(object): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( + if doc_type in SKIP_IN_PATH: + doc_type = "_doc" + + return await self.transport.perform_request( "POST", - _make_path(index, "_explain", id), + _make_path(index, doc_type, id, "_explain"), params=params, headers=headers, body=body, @@ -916,11 +909,11 @@ class Elasticsearch(object): "ignore_unavailable", "include_unmapped", ) - def field_caps(self, index=None, params=None, headers=None): + async def field_caps(self, index=None, params=None, headers=None): """ Returns the information about the capabilities of fields among multiple indices. - ``_ + ``_ :arg index: A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices @@ -936,7 +929,7 @@ class Elasticsearch(object): :arg include_unmapped: Indicates whether unmapped fields should be included in the response. """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path(index, "_field_caps"), params=params, headers=headers ) @@ -952,13 +945,15 @@ class Elasticsearch(object): "version", "version_type", ) - def get(self, index, id, params=None, headers=None): + async def get(self, index, id, doc_type=None, params=None, headers=None): """ Returns a document. - ``_ + ``_ :arg index: The name of the index :arg id: The document ID + :arg doc_type: The type of the document (use `_all` to fetch the + first document matching the ID across all types) :arg _source: True or false to return the _source field or not, or a list of fields to return :arg _source_excludes: A list of fields to exclude from the @@ -976,21 +971,24 @@ class Elasticsearch(object): return in the response :arg version: Explicit version number for concurrency control :arg version_type: Specific version type Valid choices: - internal, external, external_gte + internal, external, external_gte, force """ for param in (index, id): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( - "GET", _make_path(index, "_doc", id), params=params, headers=headers + if doc_type in SKIP_IN_PATH: + doc_type = "_doc" + + return await self.transport.perform_request( + "GET", _make_path(index, doc_type, id), params=params, headers=headers ) @query_params("master_timeout") - def get_script(self, id, params=None, headers=None): + async def get_script(self, id, params=None, headers=None): """ Returns a script. - ``_ + ``_ :arg id: Script ID :arg master_timeout: Specify timeout for connection to master @@ -998,7 +996,7 @@ class Elasticsearch(object): if id in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'id'.") - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_scripts", id), params=params, headers=headers ) @@ -1013,13 +1011,15 @@ class Elasticsearch(object): "version", "version_type", ) - def get_source(self, index, id, params=None, headers=None): + async def get_source(self, index, id, doc_type=None, params=None, headers=None): """ Returns the source of a document. - ``_ + ``_ :arg index: The name of the index :arg id: The document ID + :arg doc_type: The type of the document; deprecated and optional + starting with 7.0 :arg _source: True or false to return the _source field or not, or a list of fields to return :arg _source_excludes: A list of fields to exclude from the @@ -1035,14 +1035,20 @@ class Elasticsearch(object): :arg routing: Specific routing value :arg version: Explicit version number for concurrency control :arg version_type: Specific version type Valid choices: - internal, external, external_gte + internal, external, external_gte, force """ for param in (index, id): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( - "GET", _make_path(index, "_source", id), params=params, headers=headers + if doc_type in SKIP_IN_PATH: + doc_type = "_doc" + + return await self.transport.perform_request( + "GET", + _make_path(index, doc_type, id, "_source"), + params=params, + headers=headers, ) @query_params( @@ -1055,15 +1061,16 @@ class Elasticsearch(object): "routing", "stored_fields", ) - def mget(self, body, index=None, params=None, headers=None): + async def mget(self, body, index=None, doc_type=None, params=None, headers=None): """ Allows to get multiple documents in one request. - ``_ + ``_ :arg body: Document identifiers; can be either `docs` - (containing full document information) or `ids` (when index is provided - in the URL. + (containing full document information) or `ids` (when index and type is + provided in the URL. :arg index: The name of the index + :arg doc_type: The type of the document :arg _source: True or false to return the _source field or not, or a list of fields to return :arg _source_excludes: A list of fields to exclude from the @@ -1083,9 +1090,9 @@ class Elasticsearch(object): if body in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'body'.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", - _make_path(index, "_mget"), + _make_path(index, doc_type, "_mget"), params=params, headers=headers, body=body, @@ -1100,15 +1107,17 @@ class Elasticsearch(object): "search_type", "typed_keys", ) - def msearch(self, body, index=None, params=None, headers=None): + async def msearch(self, body, index=None, doc_type=None, params=None, headers=None): """ Allows to execute several search operations in one request. - ``_ + ``_ :arg body: The request definitions (metadata-search request definition pairs), separated by newlines :arg index: A comma-separated list of index names to use as default + :arg doc_type: A comma-separated list of document types to use + as default :arg ccs_minimize_roundtrips: Indicates whether network round- trips should be minimized as part of cross-cluster search requests execution Default: true @@ -1137,19 +1146,130 @@ class Elasticsearch(object): raise ValueError("Empty value passed for a required argument 'body'.") body = _bulk_body(self.transport.serializer, body) - return self.transport.perform_request( + return await self.transport.perform_request( "POST", - _make_path(index, "_msearch"), + _make_path(index, doc_type, "_msearch"), + params=params, + headers=headers, + body=body, + ) + + @query_params( + "ccs_minimize_roundtrips", + "max_concurrent_searches", + "rest_total_hits_as_int", + "search_type", + "typed_keys", + ) + async def msearch_template( + self, body, index=None, doc_type=None, params=None, headers=None + ): + """ + Allows to execute several search template operations in one request. + ``_ + + :arg body: The request definitions (metadata-search request + definition pairs), separated by newlines + :arg index: A comma-separated list of index names to use as + default + :arg doc_type: A comma-separated list of document types to use + as default + :arg ccs_minimize_roundtrips: Indicates whether network round- + trips should be minimized as part of cross-cluster search requests + execution Default: true + :arg max_concurrent_searches: Controls the maximum number of + concurrent searches the multi search api will execute + :arg rest_total_hits_as_int: Indicates whether hits.total should + be rendered as an integer or an object in the rest search response + :arg search_type: Search operation type Valid choices: + query_then_fetch, query_and_fetch, dfs_query_then_fetch, + dfs_query_and_fetch + :arg typed_keys: Specify whether aggregation and suggester names + should be prefixed by their respective types in the response + """ + if body in SKIP_IN_PATH: + raise ValueError("Empty value passed for a required argument 'body'.") + + body = _bulk_body(self.transport.serializer, body) + return await self.transport.perform_request( + "POST", + _make_path(index, doc_type, "_msearch", "template"), + params=params, + headers=headers, + body=body, + ) + + @query_params( + "field_statistics", + "fields", + "ids", + "offsets", + "payloads", + "positions", + "preference", + "realtime", + "routing", + "term_statistics", + "version", + "version_type", + ) + async def mtermvectors( + self, body=None, index=None, doc_type=None, params=None, headers=None + ): + """ + Returns multiple termvectors in one request. + ``_ + + :arg body: Define ids, documents, parameters or a list of + parameters per document here. You must at least provide a list of + document ids. See documentation. + :arg index: The index in which the document resides. + :arg doc_type: The type of the document. + :arg field_statistics: Specifies if document count, sum of + document frequencies and sum of total term frequencies should be + returned. Applies to all returned documents unless otherwise specified + in body "params" or "docs". Default: True + :arg fields: A comma-separated list of fields to return. Applies + to all returned documents unless otherwise specified in body "params" or + "docs". + :arg ids: A comma-separated list of documents ids. You must + define ids as parameter or set "ids" or "docs" in the request body + :arg offsets: Specifies if term offsets should be returned. + Applies to all returned documents unless otherwise specified in body + "params" or "docs". Default: True + :arg payloads: Specifies if term payloads should be returned. + Applies to all returned documents unless otherwise specified in body + "params" or "docs". Default: True + :arg positions: Specifies if term positions should be returned. + Applies to all returned documents unless otherwise specified in body + "params" or "docs". Default: True + :arg preference: Specify the node or shard the operation should + be performed on (default: random) .Applies to all returned documents + unless otherwise specified in body "params" or "docs". + :arg realtime: Specifies if requests are real-time as opposed to + near-real-time (default: true). + :arg routing: Specific routing value. Applies to all returned + documents unless otherwise specified in body "params" or "docs". + :arg term_statistics: Specifies if total term frequency and + document frequency should be returned. Applies to all returned documents + unless otherwise specified in body "params" or "docs". + :arg version: Explicit version number for concurrency control + :arg version_type: Specific version type Valid choices: + internal, external, external_gte, force + """ + return await self.transport.perform_request( + "POST", + _make_path(index, doc_type, "_mtermvectors"), params=params, headers=headers, body=body, ) @query_params("master_timeout", "timeout") - def put_script(self, id, body, context=None, params=None, headers=None): + async def put_script(self, id, body, context=None, params=None, headers=None): """ Creates or updates a script. - ``_ + ``_ :arg id: Script ID :arg body: The document @@ -1161,7 +1281,7 @@ class Elasticsearch(object): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( + return await self.transport.perform_request( "PUT", _make_path("_scripts", id, context), params=params, @@ -1172,11 +1292,11 @@ class Elasticsearch(object): @query_params( "allow_no_indices", "expand_wildcards", "ignore_unavailable", "search_type" ) - def rank_eval(self, body, index=None, params=None, headers=None): + async def rank_eval(self, body, index=None, params=None, headers=None): """ Allows to evaluate the quality of ranked search results over a set of typical search queries - ``_ + ``_ :arg body: The ranking evaluation search definition, including search requests, document ratings and ranking metric definition. @@ -1196,7 +1316,7 @@ class Elasticsearch(object): if body in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'body'.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path(index, "_rank_eval"), params=params, @@ -1214,12 +1334,12 @@ class Elasticsearch(object): "wait_for_active_shards", "wait_for_completion", ) - def reindex(self, body, params=None, headers=None): + async def reindex(self, body, params=None, headers=None): """ Allows to copy documents from one index to another, optionally filtering the source documents by a query, changing the destination index settings, or fetching the documents from a remote cluster. - ``_ + ``_ :arg body: The search definition using the Query DSL and the prototype for the index request. @@ -1246,15 +1366,15 @@ class Elasticsearch(object): if body in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'body'.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", "/_reindex", params=params, headers=headers, body=body ) @query_params("requests_per_second") - def reindex_rethrottle(self, task_id, params=None, headers=None): + async def reindex_rethrottle(self, task_id, params=None, headers=None): """ Changes the number of requests per second for a particular Reindex operation. - ``_ + ``_ :arg task_id: The task id to rethrottle :arg requests_per_second: The throttle to set on this request in @@ -1263,7 +1383,7 @@ class Elasticsearch(object): if task_id in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'task_id'.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path("_reindex", task_id, "_rethrottle"), params=params, @@ -1271,15 +1391,17 @@ class Elasticsearch(object): ) @query_params() - def render_search_template(self, body=None, id=None, params=None, headers=None): + async def render_search_template( + self, body=None, id=None, params=None, headers=None + ): """ Allows to use the Mustache language to pre-render a search definition. - ``_ + ``_ :arg body: The search definition template and its params :arg id: The id of the stored search template """ - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path("_render", "template", id), params=params, @@ -1288,14 +1410,14 @@ class Elasticsearch(object): ) @query_params() - def scripts_painless_execute(self, body=None, params=None, headers=None): + async def scripts_painless_execute(self, body=None, params=None, headers=None): """ Allows an arbitrary script to be executed and a result to be returned ``_ :arg body: The script to execute """ - return self.transport.perform_request( + return await self.transport.perform_request( "POST", "/_scripts/painless/_execute", params=params, @@ -1304,10 +1426,10 @@ class Elasticsearch(object): ) @query_params("rest_total_hits_as_int", "scroll") - def scroll(self, body=None, scroll_id=None, params=None, headers=None): + async def scroll(self, body=None, scroll_id=None, params=None, headers=None): """ Allows to retrieve a large numbers of results from a single search request. - ``_ + ``_ :arg body: The scroll ID if not passed by URL or query parameter. @@ -1324,7 +1446,7 @@ class Elasticsearch(object): elif scroll_id: params["scroll_id"] = scroll_id - return self.transport.perform_request( + return await self.transport.perform_request( "POST", "/_search/scroll", params=params, headers=headers, body=body ) @@ -1372,14 +1494,18 @@ class Elasticsearch(object): "typed_keys", "version", ) - def search(self, body=None, index=None, params=None, headers=None): + async def search( + self, body=None, index=None, doc_type=None, params=None, headers=None + ): """ Returns results matching a query. - ``_ + ``_ :arg body: The search definition using the Query DSL :arg index: A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + :arg doc_type: A comma-separated list of document types to + search; leave empty to perform the operation on all types :arg _source: True or false to return the _source field or not, or a list of fields to return :arg _source_excludes: A list of fields to exclude from the @@ -1414,7 +1540,7 @@ class Elasticsearch(object): closed, hidden, none, all Default: open :arg explain: Specify whether to return detailed information about score computation as part of a hit - :arg from\\_: Starting offset (default: 0) + :arg from_: Starting offset (default: 0) :arg ignore_throttled: Whether specified concrete, expanded or aliased indices should be ignored when throttled :arg ignore_unavailable: Whether specified concrete indices @@ -1475,9 +1601,9 @@ class Elasticsearch(object): if "from_" in params: params["from"] = params.pop("from_") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", - _make_path(index, "_search"), + _make_path(index, doc_type, "_search"), params=params, headers=headers, body=body, @@ -1491,11 +1617,11 @@ class Elasticsearch(object): "preference", "routing", ) - def search_shards(self, index=None, params=None, headers=None): + async def search_shards(self, index=None, params=None, headers=None): """ Returns information about the indices and shards that a search request would be executed against. - ``_ + ``_ :arg index: A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices @@ -1513,10 +1639,139 @@ class Elasticsearch(object): be performed on (default: random) :arg routing: Specific routing value """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path(index, "_search_shards"), params=params, headers=headers ) + @query_params( + "allow_no_indices", + "ccs_minimize_roundtrips", + "expand_wildcards", + "explain", + "ignore_throttled", + "ignore_unavailable", + "preference", + "profile", + "rest_total_hits_as_int", + "routing", + "scroll", + "search_type", + "typed_keys", + ) + async def search_template( + self, body, index=None, doc_type=None, params=None, headers=None + ): + """ + Allows to use the Mustache language to pre-render a search definition. + ``_ + + :arg body: The search definition template and its params + :arg index: A comma-separated list of index names to search; use + `_all` or empty string to perform the operation on all indices + :arg doc_type: A comma-separated list of document types to + search; leave empty to perform the operation on all types + :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 ccs_minimize_roundtrips: Indicates whether network round- + trips should be minimized as part of cross-cluster search requests + execution Default: true + :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 explain: Specify whether to return detailed information + about score computation as part of a hit + :arg ignore_throttled: Whether specified concrete, expanded or + aliased indices should be ignored when throttled + :arg ignore_unavailable: Whether specified concrete indices + should be ignored when unavailable (missing or closed) + :arg preference: Specify the node or shard the operation should + be performed on (default: random) + :arg profile: Specify whether to profile the query execution + :arg rest_total_hits_as_int: Indicates whether hits.total should + be rendered as an integer or an object in the rest search response + :arg routing: A comma-separated list of specific routing values + :arg scroll: Specify how long a consistent view of the index + should be maintained for scrolled search + :arg search_type: Search operation type Valid choices: + query_then_fetch, query_and_fetch, dfs_query_then_fetch, + dfs_query_and_fetch + :arg typed_keys: Specify whether aggregation and suggester names + should be prefixed by their respective types in the response + """ + if body in SKIP_IN_PATH: + raise ValueError("Empty value passed for a required argument 'body'.") + + return await self.transport.perform_request( + "POST", + _make_path(index, doc_type, "_search", "template"), + params=params, + headers=headers, + body=body, + ) + + @query_params( + "field_statistics", + "fields", + "offsets", + "payloads", + "positions", + "preference", + "realtime", + "routing", + "term_statistics", + "version", + "version_type", + ) + async def termvectors( + self, index, body=None, doc_type=None, id=None, params=None, headers=None + ): + """ + Returns information and statistics about terms in the fields of a particular + document. + ``_ + + :arg index: The index in which the document resides. + :arg body: Define parameters and or supply a document to get + termvectors for. See documentation. + :arg doc_type: The type of the document. + :arg id: The id of the document, when not specified a doc param + should be supplied. + :arg field_statistics: Specifies if document count, sum of + document frequencies and sum of total term frequencies should be + returned. Default: True + :arg fields: A comma-separated list of fields to return. + :arg offsets: Specifies if term offsets should be returned. + Default: True + :arg payloads: Specifies if term payloads should be returned. + Default: True + :arg positions: Specifies if term positions should be returned. + Default: True + :arg preference: Specify the node or shard the operation should + be performed on (default: random). + :arg realtime: Specifies if request is real-time as opposed to + near-real-time (default: true). + :arg routing: Specific routing value. + :arg term_statistics: Specifies if total term frequency and + document frequency should be returned. + :arg version: Explicit version number for concurrency control + :arg version_type: Specific version type Valid choices: + internal, external, external_gte, force + """ + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for a required argument 'index'.") + + if doc_type in SKIP_IN_PATH: + doc_type = "_doc" + + return await self.transport.perform_request( + "POST", + _make_path(index, doc_type, id, "_termvectors"), + params=params, + headers=headers, + body=body, + ) + @query_params( "_source", "_source_excludes", @@ -1530,10 +1785,10 @@ class Elasticsearch(object): "timeout", "wait_for_active_shards", ) - def update(self, index, id, body, doc_type=None, params=None, headers=None): + async def update(self, index, id, body, doc_type=None, params=None, headers=None): """ Updates a document with a script or partial document. - ``_ + ``_ :arg index: The name of the index :arg id: Document ID @@ -1572,273 +1827,11 @@ class Elasticsearch(object): raise ValueError("Empty value passed for a required argument.") if doc_type in SKIP_IN_PATH: - path = _make_path(index, "_update", id) - else: - path = _make_path(index, doc_type, id, "_update") + doc_type = "_doc" - return self.transport.perform_request( - "POST", path, params=params, headers=headers, body=body - ) - - @query_params("requests_per_second") - def update_by_query_rethrottle(self, task_id, params=None, headers=None): - """ - Changes the number of requests per second for a particular Update By Query - operation. - ``_ - - :arg task_id: The task id to rethrottle - :arg requests_per_second: The throttle to set on this request in - floating sub-requests per second. -1 means set no throttle. - """ - if task_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'task_id'.") - - return self.transport.perform_request( + return await self.transport.perform_request( "POST", - _make_path("_update_by_query", task_id, "_rethrottle"), - params=params, - headers=headers, - ) - - @query_params() - def get_script_context(self, params=None, headers=None): - """ - Returns all script contexts. - ``_ - """ - return self.transport.perform_request( - "GET", "/_script_context", params=params, headers=headers - ) - - @query_params() - def get_script_languages(self, params=None, headers=None): - """ - Returns available script types, languages and contexts - ``_ - """ - return self.transport.perform_request( - "GET", "/_script_language", params=params, headers=headers - ) - - @query_params( - "ccs_minimize_roundtrips", - "max_concurrent_searches", - "rest_total_hits_as_int", - "search_type", - "typed_keys", - ) - def msearch_template(self, body, index=None, params=None, headers=None): - """ - Allows to execute several search template operations in one request. - ``_ - - :arg body: The request definitions (metadata-search request - definition pairs), separated by newlines - :arg index: A comma-separated list of index names to use as - default - :arg ccs_minimize_roundtrips: Indicates whether network round- - trips should be minimized as part of cross-cluster search requests - execution Default: true - :arg max_concurrent_searches: Controls the maximum number of - concurrent searches the multi search api will execute - :arg rest_total_hits_as_int: Indicates whether hits.total should - be rendered as an integer or an object in the rest search response - :arg search_type: Search operation type Valid choices: - query_then_fetch, query_and_fetch, dfs_query_then_fetch, - dfs_query_and_fetch - :arg typed_keys: Specify whether aggregation and suggester names - should be prefixed by their respective types in the response - """ - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - body = _bulk_body(self.transport.serializer, body) - return self.transport.perform_request( - "POST", - _make_path(index, "_msearch", "template"), - params=params, - headers=headers, - body=body, - ) - - @query_params( - "field_statistics", - "fields", - "ids", - "offsets", - "payloads", - "positions", - "preference", - "realtime", - "routing", - "term_statistics", - "version", - "version_type", - ) - def mtermvectors(self, body=None, index=None, params=None, headers=None): - """ - Returns multiple termvectors in one request. - ``_ - - :arg body: Define ids, documents, parameters or a list of - parameters per document here. You must at least provide a list of - document ids. See documentation. - :arg index: The index in which the document resides. - :arg field_statistics: Specifies if document count, sum of - document frequencies and sum of total term frequencies should be - returned. Applies to all returned documents unless otherwise specified - in body "params" or "docs". Default: True - :arg fields: A comma-separated list of fields to return. Applies - to all returned documents unless otherwise specified in body "params" or - "docs". - :arg ids: A comma-separated list of documents ids. You must - define ids as parameter or set "ids" or "docs" in the request body - :arg offsets: Specifies if term offsets should be returned. - Applies to all returned documents unless otherwise specified in body - "params" or "docs". Default: True - :arg payloads: Specifies if term payloads should be returned. - Applies to all returned documents unless otherwise specified in body - "params" or "docs". Default: True - :arg positions: Specifies if term positions should be returned. - Applies to all returned documents unless otherwise specified in body - "params" or "docs". Default: True - :arg preference: Specify the node or shard the operation should - be performed on (default: random) .Applies to all returned documents - unless otherwise specified in body "params" or "docs". - :arg realtime: Specifies if requests are real-time as opposed to - near-real-time (default: true). - :arg routing: Specific routing value. Applies to all returned - documents unless otherwise specified in body "params" or "docs". - :arg term_statistics: Specifies if total term frequency and - document frequency should be returned. Applies to all returned documents - unless otherwise specified in body "params" or "docs". - :arg version: Explicit version number for concurrency control - :arg version_type: Specific version type Valid choices: - internal, external, external_gte - """ - return self.transport.perform_request( - "POST", - _make_path(index, "_mtermvectors"), - params=params, - headers=headers, - body=body, - ) - - @query_params( - "allow_no_indices", - "ccs_minimize_roundtrips", - "expand_wildcards", - "explain", - "ignore_throttled", - "ignore_unavailable", - "preference", - "profile", - "rest_total_hits_as_int", - "routing", - "scroll", - "search_type", - "typed_keys", - ) - def search_template(self, body, index=None, params=None, headers=None): - """ - Allows to use the Mustache language to pre-render a search definition. - ``_ - - :arg body: The search definition template and its params - :arg index: A comma-separated list of index names to search; use - `_all` or empty string to perform the operation on all indices - :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 ccs_minimize_roundtrips: Indicates whether network round- - trips should be minimized as part of cross-cluster search requests - execution Default: true - :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 explain: Specify whether to return detailed information - about score computation as part of a hit - :arg ignore_throttled: Whether specified concrete, expanded or - aliased indices should be ignored when throttled - :arg ignore_unavailable: Whether specified concrete indices - should be ignored when unavailable (missing or closed) - :arg preference: Specify the node or shard the operation should - be performed on (default: random) - :arg profile: Specify whether to profile the query execution - :arg rest_total_hits_as_int: Indicates whether hits.total should - be rendered as an integer or an object in the rest search response - :arg routing: A comma-separated list of specific routing values - :arg scroll: Specify how long a consistent view of the index - should be maintained for scrolled search - :arg search_type: Search operation type Valid choices: - query_then_fetch, query_and_fetch, dfs_query_then_fetch, - dfs_query_and_fetch - :arg typed_keys: Specify whether aggregation and suggester names - should be prefixed by their respective types in the response - """ - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return self.transport.perform_request( - "POST", - _make_path(index, "_search", "template"), - params=params, - headers=headers, - body=body, - ) - - @query_params( - "field_statistics", - "fields", - "offsets", - "payloads", - "positions", - "preference", - "realtime", - "routing", - "term_statistics", - "version", - "version_type", - ) - def termvectors(self, index, body=None, id=None, params=None, headers=None): - """ - Returns information and statistics about terms in the fields of a particular - document. - ``_ - - :arg index: The index in which the document resides. - :arg body: Define parameters and or supply a document to get - termvectors for. See documentation. - :arg id: The id of the document, when not specified a doc param - should be supplied. - :arg field_statistics: Specifies if document count, sum of - document frequencies and sum of total term frequencies should be - returned. Default: True - :arg fields: A comma-separated list of fields to return. - :arg offsets: Specifies if term offsets should be returned. - Default: True - :arg payloads: Specifies if term payloads should be returned. - Default: True - :arg positions: Specifies if term positions should be returned. - Default: True - :arg preference: Specify the node or shard the operation should - be performed on (default: random). - :arg realtime: Specifies if request is real-time as opposed to - near-real-time (default: true). - :arg routing: Specific routing value. - :arg term_statistics: Specifies if total term frequency and - document frequency should be returned. - :arg version: Explicit version number for concurrency control - :arg version_type: Specific version type Valid choices: - internal, external, external_gte - """ - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return self.transport.perform_request( - "POST", - _make_path(index, "_termvectors", id), + _make_path(index, doc_type, id, "_update"), params=params, headers=headers, body=body, @@ -1870,6 +1863,7 @@ class Elasticsearch(object): "scroll_size", "search_timeout", "search_type", + "size", "slices", "sort", "stats", @@ -1880,15 +1874,19 @@ class Elasticsearch(object): "wait_for_active_shards", "wait_for_completion", ) - def update_by_query(self, index, body=None, params=None, headers=None): + async def update_by_query( + self, index, body=None, doc_type=None, params=None, headers=None + ): """ Performs an update on every document in the index without changing the source, for example to pick up a mapping change. - ``_ + ``_ :arg index: A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices :arg body: The search definition using the Query DSL + :arg doc_type: A comma-separated list of document types to + search; leave empty to perform the operation on all types :arg _source: True or false to return the _source field or not, or a list of fields to return :arg _source_excludes: A list of fields to exclude from the @@ -1910,7 +1908,7 @@ class Elasticsearch(object): :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 from\\_: Starting offset (default: 0) + :arg from_: Starting offset (default: 0) :arg ignore_unavailable: Whether specified concrete indices should be ignored when unavailable (missing or closed) :arg lenient: Specify whether format-based query failures (such @@ -1936,6 +1934,7 @@ class Elasticsearch(object): Defaults to no timeout. :arg search_type: Search operation type Valid choices: query_then_fetch, dfs_query_then_fetch + :arg size: Deprecated, please use `max_docs` instead :arg slices: The number of slices this task should be divided into. Defaults to 1, meaning the task isn't sliced into subtasks. Can be set to `auto`. Default: 1 @@ -1967,10 +1966,51 @@ class Elasticsearch(object): if index in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'index'.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", - _make_path(index, "_update_by_query"), + _make_path(index, doc_type, "_update_by_query"), params=params, headers=headers, body=body, ) + + @query_params("requests_per_second") + async def update_by_query_rethrottle(self, task_id, params=None, headers=None): + """ + Changes the number of requests per second for a particular Update By Query + operation. + ``_ + + :arg task_id: The task id to rethrottle + :arg requests_per_second: The throttle to set on this request in + floating sub-requests per second. -1 means set no throttle. + """ + if task_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for a required argument 'task_id'.") + + return await self.transport.perform_request( + "POST", + _make_path("_update_by_query", task_id, "_rethrottle"), + params=params, + headers=headers, + ) + + @query_params() + async def get_script_context(self, params=None, headers=None): + """ + Returns all script contexts. + ``_ + """ + return await self.transport.perform_request( + "GET", "/_script_context", params=params, headers=headers + ) + + @query_params() + async def get_script_languages(self, params=None, headers=None): + """ + Returns available script types, languages and contexts + ``_ + """ + return await self.transport.perform_request( + "GET", "/_script_language", params=params, headers=headers + ) diff --git a/elasticsearch/_async/client/async_search.py b/elasticsearch/_async/client/async_search.py index d6062cbe..3af62e18 100644 --- a/elasticsearch/_async/client/async_search.py +++ b/elasticsearch/_async/client/async_search.py @@ -7,27 +7,27 @@ from .utils import NamespacedClient, SKIP_IN_PATH, query_params, _make_path class AsyncSearchClient(NamespacedClient): @query_params() - def delete(self, id, params=None, headers=None): + async def delete(self, id, params=None, headers=None): """ Deletes an async 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( + return await self.transport.perform_request( "DELETE", _make_path("_async_search", id), params=params, headers=headers ) @query_params("keep_alive", "typed_keys", "wait_for_completion_timeout") - def get(self, id, params=None, headers=None): + async def get(self, id, params=None, headers=None): """ Retrieves the results of a previously submitted async search request given its ID. - ``_ + ``_ :arg id: The async search ID :arg keep_alive: Specify the time interval in which the results @@ -40,7 +40,7 @@ class AsyncSearchClient(NamespacedClient): if id in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'id'.") - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_async_search", id), params=params, headers=headers ) @@ -87,10 +87,10 @@ class AsyncSearchClient(NamespacedClient): "version", "wait_for_completion_timeout", ) - def submit(self, body=None, index=None, params=None, headers=None): + async def submit(self, body=None, index=None, params=None, headers=None): """ Executes a search request asynchronously. - ``_ + ``_ :arg body: The search definition using the Query DSL :arg index: A comma-separated list of index names to search; use @@ -125,7 +125,7 @@ class AsyncSearchClient(NamespacedClient): closed, hidden, none, all Default: open :arg explain: Specify whether to return detailed information about score computation as part of a hit - :arg from\\_: Starting offset (default: 0) + :arg from_: Starting offset (default: 0) :arg ignore_throttled: Whether specified concrete, expanded or aliased indices should be ignored when throttled :arg ignore_unavailable: Whether specified concrete indices @@ -182,7 +182,7 @@ class AsyncSearchClient(NamespacedClient): if "from_" in params: params["from"] = params.pop("from_") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path(index, "_async_search"), params=params, diff --git a/elasticsearch/_async/client/autoscaling.py b/elasticsearch/_async/client/autoscaling.py index a648d79e..cead458c 100644 --- a/elasticsearch/_async/client/autoscaling.py +++ b/elasticsearch/_async/client/autoscaling.py @@ -7,28 +7,28 @@ from .utils import NamespacedClient, query_params, SKIP_IN_PATH, _make_path class AutoscalingClient(NamespacedClient): @query_params() - def get_autoscaling_decision(self, params=None, headers=None): + async def get_autoscaling_decision(self, params=None, headers=None): """ Gets the current autoscaling decision based on the configured autoscaling policy, indicating whether or not autoscaling is needed. - ``_ + ``_ """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", "/_autoscaling/decision", params=params, headers=headers ) @query_params() - def delete_autoscaling_policy(self, name, params=None, headers=None): + async def delete_autoscaling_policy(self, name, params=None, headers=None): """ Deletes an autoscaling policy. - ``_ + ``_ :arg name: the name of the autoscaling policy """ if name in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'name'.") - return self.transport.perform_request( + return await self.transport.perform_request( "DELETE", _make_path("_autoscaling", "policy", name), params=params, @@ -36,10 +36,28 @@ class AutoscalingClient(NamespacedClient): ) @query_params() - def put_autoscaling_policy(self, name, body, params=None, headers=None): + async def get_autoscaling_policy(self, name, params=None, headers=None): + """ + Retrieves an autoscaling policy. + ``_ + + :arg name: the name of the autoscaling policy + """ + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for a required argument 'name'.") + + return await self.transport.perform_request( + "GET", + _make_path("_autoscaling", "policy", name), + params=params, + headers=headers, + ) + + @query_params() + async def put_autoscaling_policy(self, name, body, params=None, headers=None): """ Creates a new autoscaling policy. - ``_ + ``_ :arg name: the name of the autoscaling policy :arg body: the specification of the autoscaling policy @@ -48,28 +66,10 @@ class AutoscalingClient(NamespacedClient): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( + return await self.transport.perform_request( "PUT", _make_path("_autoscaling", "policy", name), params=params, headers=headers, body=body, ) - - @query_params() - def get_autoscaling_policy(self, name, params=None, headers=None): - """ - Retrieves an autoscaling policy. - ``_ - - :arg name: the name of the autoscaling policy - """ - if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'name'.") - - return self.transport.perform_request( - "GET", - _make_path("_autoscaling", "policy", name), - params=params, - headers=headers, - ) diff --git a/elasticsearch/_async/client/cat.py b/elasticsearch/_async/client/cat.py index 84282850..4bf841a0 100644 --- a/elasticsearch/_async/client/cat.py +++ b/elasticsearch/_async/client/cat.py @@ -7,11 +7,11 @@ from .utils import NamespacedClient, query_params, _make_path class CatClient(NamespacedClient): @query_params("expand_wildcards", "format", "h", "help", "local", "s", "v") - def aliases(self, name=None, params=None, headers=None): + async def aliases(self, name=None, params=None, headers=None): """ Shows information about currently configured aliases to indices including filter and routing infos. - ``_ + ``_ :arg name: A comma-separated list of alias names to return :arg expand_wildcards: Whether to expand wildcard expression to @@ -27,16 +27,16 @@ class CatClient(NamespacedClient): to sort by :arg v: Verbose mode. Display column headers """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_cat", "aliases", name), params=params, headers=headers ) @query_params("bytes", "format", "h", "help", "local", "master_timeout", "s", "v") - def allocation(self, node_id=None, params=None, headers=None): + async def allocation(self, node_id=None, params=None, headers=None): """ Provides a snapshot of how many shards are allocated to each data node and how much disk space they are using. - ``_ + ``_ :arg node_id: A comma-separated list of node IDs or names to limit the returned information @@ -54,7 +54,7 @@ class CatClient(NamespacedClient): to sort by :arg v: Verbose mode. Display column headers """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_cat", "allocation", node_id), params=params, @@ -62,11 +62,11 @@ class CatClient(NamespacedClient): ) @query_params("format", "h", "help", "s", "v") - def count(self, index=None, params=None, headers=None): + async def count(self, index=None, params=None, headers=None): """ Provides quick access to the document count of the entire cluster, or individual indices. - ``_ + ``_ :arg index: A comma-separated list of index names to limit the returned information @@ -78,15 +78,15 @@ class CatClient(NamespacedClient): to sort by :arg v: Verbose mode. Display column headers """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_cat", "count", index), params=params, headers=headers ) @query_params("format", "h", "help", "s", "time", "ts", "v") - def health(self, params=None, headers=None): + async def health(self, params=None, headers=None): """ Returns a concise representation of the cluster health. - ``_ + ``_ :arg format: a short version of the Accept header, e.g. json, yaml @@ -99,21 +99,21 @@ class CatClient(NamespacedClient): :arg ts: Set to false to disable timestamping Default: True :arg v: Verbose mode. Display column headers """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", "/_cat/health", params=params, headers=headers ) @query_params("help", "s") - def help(self, params=None, headers=None): + async def help(self, params=None, headers=None): """ Returns help for the Cat APIs. - ``_ + ``_ :arg help: Return help information :arg s: Comma-separated list of column names or column aliases to sort by """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", "/_cat", params=params, headers=headers ) @@ -132,11 +132,11 @@ class CatClient(NamespacedClient): "time", "v", ) - def indices(self, index=None, params=None, headers=None): + async def indices(self, index=None, params=None, headers=None): """ Returns information about indices: number of primaries and replicas, document counts, disk size, ... - ``_ + ``_ :arg index: A comma-separated list of index names to limit the returned information @@ -166,15 +166,15 @@ class CatClient(NamespacedClient): choices: d, h, m, s, ms, micros, nanos :arg v: Verbose mode. Display column headers """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_cat", "indices", index), params=params, headers=headers ) @query_params("format", "h", "help", "local", "master_timeout", "s", "v") - def master(self, params=None, headers=None): + async def master(self, params=None, headers=None): """ Returns information about the master node. - ``_ + ``_ :arg format: a short version of the Accept header, e.g. json, yaml @@ -188,17 +188,26 @@ class CatClient(NamespacedClient): to sort by :arg v: Verbose mode. Display column headers """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", "/_cat/master", params=params, headers=headers ) @query_params( - "bytes", "format", "full_id", "h", "help", "master_timeout", "s", "time", "v" + "bytes", + "format", + "full_id", + "h", + "help", + "local", + "master_timeout", + "s", + "time", + "v", ) - def nodes(self, params=None, headers=None): + async def nodes(self, params=None, headers=None): """ Returns basic statistics about performance of cluster nodes. - ``_ + ``_ :arg bytes: The unit in which to display byte values Valid choices: b, k, kb, m, mb, g, gb, t, tb, p, pb @@ -208,6 +217,8 @@ class CatClient(NamespacedClient): version (default: false) :arg h: Comma-separated list of column names to display :arg help: Return help information + :arg local: Calculate the selected nodes using the local cluster + state rather than the state from master node (default: false) :arg master_timeout: Explicit operation timeout for connection to master node :arg s: Comma-separated list of column names or column aliases @@ -216,17 +227,17 @@ class CatClient(NamespacedClient): choices: d, h, m, s, ms, micros, nanos :arg v: Verbose mode. Display column headers """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", "/_cat/nodes", params=params, headers=headers ) @query_params( "active_only", "bytes", "detailed", "format", "h", "help", "s", "time", "v" ) - def recovery(self, index=None, params=None, headers=None): + async def recovery(self, index=None, params=None, headers=None): """ Returns information about index shard recoveries, both on-going completed. - ``_ + ``_ :arg index: Comma-separated list or wildcard expression of index names to limit the returned information @@ -246,17 +257,17 @@ class CatClient(NamespacedClient): choices: d, h, m, s, ms, micros, nanos :arg v: Verbose mode. Display column headers """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_cat", "recovery", index), params=params, headers=headers ) @query_params( "bytes", "format", "h", "help", "local", "master_timeout", "s", "time", "v" ) - def shards(self, index=None, params=None, headers=None): + async def shards(self, index=None, params=None, headers=None): """ Provides a detailed view of shard allocation on nodes. - ``_ + ``_ :arg index: A comma-separated list of index names to limit the returned information @@ -276,15 +287,15 @@ class CatClient(NamespacedClient): choices: d, h, m, s, ms, micros, nanos :arg v: Verbose mode. Display column headers """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_cat", "shards", index), params=params, headers=headers ) @query_params("bytes", "format", "h", "help", "s", "v") - def segments(self, index=None, params=None, headers=None): + async def segments(self, index=None, params=None, headers=None): """ Provides low-level information about the segments in the shards of an index. - ``_ + ``_ :arg index: A comma-separated list of index names to limit the returned information @@ -298,15 +309,15 @@ class CatClient(NamespacedClient): to sort by :arg v: Verbose mode. Display column headers """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_cat", "segments", index), params=params, headers=headers ) @query_params("format", "h", "help", "local", "master_timeout", "s", "time", "v") - def pending_tasks(self, params=None, headers=None): + async def pending_tasks(self, params=None, headers=None): """ Returns a concise representation of the cluster pending tasks. - ``_ + ``_ :arg format: a short version of the Accept header, e.g. json, yaml @@ -322,16 +333,16 @@ class CatClient(NamespacedClient): choices: d, h, m, s, ms, micros, nanos :arg v: Verbose mode. Display column headers """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", "/_cat/pending_tasks", params=params, headers=headers ) - @query_params("format", "h", "help", "local", "master_timeout", "s", "time", "v") - def thread_pool(self, thread_pool_patterns=None, params=None, headers=None): + @query_params("format", "h", "help", "local", "master_timeout", "s", "size", "v") + async def thread_pool(self, thread_pool_patterns=None, params=None, headers=None): """ Returns cluster-wide thread pool statistics per node. By default the active, queue and rejected statistics are returned for all thread pools. - ``_ + ``_ :arg thread_pool_patterns: A comma-separated list of regular- expressions to filter the thread pools in the output @@ -345,11 +356,11 @@ class CatClient(NamespacedClient): to master node :arg s: Comma-separated list of column names or column aliases to sort by - :arg time: The unit in which to display time values Valid - choices: d, h, m, s, ms, micros, nanos + :arg size: The multiplier in which to display values Valid + choices: , k, m, g, t, p :arg v: Verbose mode. Display column headers """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_cat", "thread_pool", thread_pool_patterns), params=params, @@ -357,11 +368,11 @@ class CatClient(NamespacedClient): ) @query_params("bytes", "format", "h", "help", "s", "v") - def fielddata(self, fields=None, params=None, headers=None): + async def fielddata(self, fields=None, params=None, headers=None): """ Shows how much heap memory is currently being used by fielddata on every data node in the cluster. - ``_ + ``_ :arg fields: A comma-separated list of fields to return in the output @@ -375,7 +386,7 @@ class CatClient(NamespacedClient): to sort by :arg v: Verbose mode. Display column headers """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_cat", "fielddata", fields), params=params, @@ -383,10 +394,10 @@ class CatClient(NamespacedClient): ) @query_params("format", "h", "help", "local", "master_timeout", "s", "v") - def plugins(self, params=None, headers=None): + async def plugins(self, params=None, headers=None): """ Returns information about installed plugins across nodes node. - ``_ + ``_ :arg format: a short version of the Accept header, e.g. json, yaml @@ -400,15 +411,15 @@ class CatClient(NamespacedClient): to sort by :arg v: Verbose mode. Display column headers """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", "/_cat/plugins", params=params, headers=headers ) @query_params("format", "h", "help", "local", "master_timeout", "s", "v") - def nodeattrs(self, params=None, headers=None): + async def nodeattrs(self, params=None, headers=None): """ Returns information about custom node attributes. - ``_ + ``_ :arg format: a short version of the Accept header, e.g. json, yaml @@ -422,15 +433,15 @@ class CatClient(NamespacedClient): to sort by :arg v: Verbose mode. Display column headers """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", "/_cat/nodeattrs", params=params, headers=headers ) @query_params("format", "h", "help", "local", "master_timeout", "s", "v") - def repositories(self, params=None, headers=None): + async def repositories(self, params=None, headers=None): """ Returns information about snapshot repositories registered in the cluster. - ``_ + ``_ :arg format: a short version of the Accept header, e.g. json, yaml @@ -444,17 +455,17 @@ class CatClient(NamespacedClient): to sort by :arg v: Verbose mode. Display column headers """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", "/_cat/repositories", params=params, headers=headers ) @query_params( "format", "h", "help", "ignore_unavailable", "master_timeout", "s", "time", "v" ) - def snapshots(self, repository=None, params=None, headers=None): + async def snapshots(self, repository=None, params=None, headers=None): """ Returns all snapshots in a specific repository. - ``_ + ``_ :arg repository: Name of repository from which to fetch the snapshot information @@ -472,7 +483,7 @@ class CatClient(NamespacedClient): choices: d, h, m, s, ms, micros, nanos :arg v: Verbose mode. Display column headers """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_cat", "snapshots", repository), params=params, @@ -491,11 +502,11 @@ class CatClient(NamespacedClient): "time", "v", ) - def tasks(self, params=None, headers=None): + async def tasks(self, params=None, headers=None): """ Returns information about the tasks currently executing on one or more nodes in the cluster. - ``_ + ``_ :arg actions: A comma-separated list of actions that should be returned. Leave empty to return all. @@ -516,15 +527,15 @@ class CatClient(NamespacedClient): choices: d, h, m, s, ms, micros, nanos :arg v: Verbose mode. Display column headers """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", "/_cat/tasks", params=params, headers=headers ) @query_params("format", "h", "help", "local", "master_timeout", "s", "v") - def templates(self, name=None, params=None, headers=None): + async def templates(self, name=None, params=None, headers=None): """ Returns information about existing templates. - ``_ + ``_ :arg name: A pattern that returned template names must match :arg format: a short version of the Accept header, e.g. json, @@ -539,15 +550,15 @@ class CatClient(NamespacedClient): to sort by :arg v: Verbose mode. Display column headers """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_cat", "templates", name), params=params, headers=headers ) @query_params("allow_no_match", "bytes", "format", "h", "help", "s", "time", "v") - def ml_data_frame_analytics(self, id=None, params=None, headers=None): + async def ml_data_frame_analytics(self, id=None, params=None, headers=None): """ Gets configuration and usage information about data frame analytics jobs. - ``_ + ``_ :arg id: The ID of the data frame analytics to fetch :arg allow_no_match: Whether to ignore if a wildcard expression @@ -565,7 +576,7 @@ class CatClient(NamespacedClient): choices: d, h, m, s, ms, micros, nanos :arg v: Verbose mode. Display column headers """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_cat", "ml", "data_frame", "analytics", id), params=params, @@ -573,10 +584,10 @@ class CatClient(NamespacedClient): ) @query_params("allow_no_datafeeds", "format", "h", "help", "s", "time", "v") - def ml_datafeeds(self, datafeed_id=None, params=None, headers=None): + async def ml_datafeeds(self, datafeed_id=None, params=None, headers=None): """ Gets configuration and usage information about datafeeds. - ``_ + ``_ :arg datafeed_id: The ID of the datafeeds stats to fetch :arg allow_no_datafeeds: Whether to ignore if a wildcard @@ -592,7 +603,7 @@ class CatClient(NamespacedClient): choices: d, h, m, s, ms, micros, nanos :arg v: Verbose mode. Display column headers """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_cat", "ml", "datafeeds", datafeed_id), params=params, @@ -600,10 +611,10 @@ class CatClient(NamespacedClient): ) @query_params("allow_no_jobs", "bytes", "format", "h", "help", "s", "time", "v") - def ml_jobs(self, job_id=None, params=None, headers=None): + async def ml_jobs(self, job_id=None, params=None, headers=None): """ Gets configuration and usage information about anomaly detection jobs. - ``_ + ``_ :arg job_id: The ID of the jobs stats to fetch :arg allow_no_jobs: Whether to ignore if a wildcard expression @@ -621,7 +632,7 @@ class CatClient(NamespacedClient): choices: d, h, m, s, ms, micros, nanos :arg v: Verbose mode. Display column headers """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_cat", "ml", "anomaly_detectors", job_id), params=params, @@ -640,10 +651,10 @@ class CatClient(NamespacedClient): "time", "v", ) - def ml_trained_models(self, model_id=None, params=None, headers=None): + async def ml_trained_models(self, model_id=None, params=None, headers=None): """ Gets configuration and usage information about inference trained models. - ``_ + ``_ :arg model_id: The ID of the trained models stats to fetch :arg allow_no_match: Whether to ignore if a wildcard expression @@ -653,7 +664,7 @@ class CatClient(NamespacedClient): choices: b, k, kb, m, mb, g, gb, t, tb, p, pb :arg format: a short version of the Accept header, e.g. json, yaml - :arg from\\_: skips a number of trained models + :arg from_: skips a number of trained models :arg h: Comma-separated list of column names to display :arg help: Return help information :arg s: Comma-separated list of column names or column aliases @@ -668,7 +679,7 @@ class CatClient(NamespacedClient): if "from_" in params: params["from"] = params.pop("from_") - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_cat", "ml", "trained_models", model_id), params=params, @@ -678,10 +689,10 @@ class CatClient(NamespacedClient): @query_params( "allow_no_match", "format", "from_", "h", "help", "s", "size", "time", "v" ) - def transforms(self, transform_id=None, params=None, headers=None): + async def transforms(self, transform_id=None, params=None, headers=None): """ Gets configuration and usage information about transforms. - ``_ + ``_ :arg transform_id: The id of the transform for which to get stats. '_all' or '*' implies all transforms @@ -690,7 +701,7 @@ class CatClient(NamespacedClient): transforms have been specified) :arg format: a short version of the Accept header, e.g. json, yaml - :arg from\\_: skips a number of transform configs, defaults to 0 + :arg from_: skips a number of transform configs, defaults to 0 :arg h: Comma-separated list of column names to display :arg help: Return help information :arg s: Comma-separated list of column names or column aliases @@ -705,7 +716,7 @@ class CatClient(NamespacedClient): if "from_" in params: params["from"] = params.pop("from_") - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_cat", "transforms", transform_id), params=params, diff --git a/elasticsearch/_async/client/ccr.py b/elasticsearch/_async/client/ccr.py index fa0568fc..c3352aaf 100644 --- a/elasticsearch/_async/client/ccr.py +++ b/elasticsearch/_async/client/ccr.py @@ -7,17 +7,17 @@ from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH class CcrClient(NamespacedClient): @query_params() - def delete_auto_follow_pattern(self, name, params=None, headers=None): + async def delete_auto_follow_pattern(self, name, params=None, headers=None): """ Deletes auto-follow patterns. - ``_ + ``_ :arg name: The name of the auto follow pattern. """ if name in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'name'.") - return self.transport.perform_request( + return await self.transport.perform_request( "DELETE", _make_path("_ccr", "auto_follow", name), params=params, @@ -25,10 +25,10 @@ class CcrClient(NamespacedClient): ) @query_params("wait_for_active_shards") - def follow(self, index, body, params=None, headers=None): + async def follow(self, index, body, params=None, headers=None): """ Creates a new follower index configured to follow the referenced leader index. - ``_ + ``_ :arg index: The name of the follower index :arg body: The name of the leader index and other optional ccr @@ -43,7 +43,7 @@ class CcrClient(NamespacedClient): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( + return await self.transport.perform_request( "PUT", _make_path(index, "_ccr", "follow"), params=params, @@ -52,11 +52,11 @@ class CcrClient(NamespacedClient): ) @query_params() - def follow_info(self, index, params=None, headers=None): + async def follow_info(self, index, params=None, headers=None): """ Retrieves information about all follower indices, including parameters and status for each follower index - ``_ + ``_ :arg index: A comma-separated list of index patterns; use `_all` to perform the operation on all indices @@ -64,16 +64,16 @@ class CcrClient(NamespacedClient): if index in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'index'.") - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path(index, "_ccr", "info"), params=params, headers=headers ) @query_params() - def follow_stats(self, index, params=None, headers=None): + async def follow_stats(self, index, params=None, headers=None): """ Retrieves follower stats. return shard-level stats about the following tasks associated with each shard for the specified indices. - ``_ + ``_ :arg index: A comma-separated list of index patterns; use `_all` to perform the operation on all indices @@ -81,15 +81,15 @@ class CcrClient(NamespacedClient): if index in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'index'.") - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path(index, "_ccr", "stats"), params=params, headers=headers ) @query_params() - def forget_follower(self, index, body, params=None, headers=None): + async def forget_follower(self, index, body, params=None, headers=None): """ Removes the follower retention leases from the leader. - ``_ + ``_ :arg index: the name of the leader index for which specified follower retention leases should be removed @@ -102,7 +102,7 @@ class CcrClient(NamespacedClient): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path(index, "_ccr", "forget_follower"), params=params, @@ -111,15 +111,15 @@ class CcrClient(NamespacedClient): ) @query_params() - def get_auto_follow_pattern(self, name=None, params=None, headers=None): + async def get_auto_follow_pattern(self, name=None, params=None, headers=None): """ Gets configured auto-follow patterns. Returns the specified auto-follow pattern collection. - ``_ + ``_ :arg name: The name of the auto follow pattern. """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_ccr", "auto_follow", name), params=params, @@ -127,11 +127,11 @@ class CcrClient(NamespacedClient): ) @query_params() - def pause_follow(self, index, params=None, headers=None): + async def pause_follow(self, index, params=None, headers=None): """ Pauses a follower index. The follower index will not fetch any additional operations from the leader index. - ``_ + ``_ :arg index: The name of the follower index that should pause following its leader index. @@ -139,7 +139,7 @@ class CcrClient(NamespacedClient): if index in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'index'.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path(index, "_ccr", "pause_follow"), params=params, @@ -147,12 +147,12 @@ class CcrClient(NamespacedClient): ) @query_params() - def put_auto_follow_pattern(self, name, body, params=None, headers=None): + async def put_auto_follow_pattern(self, name, body, params=None, headers=None): """ Creates a new named collection of auto-follow patterns against a specified remote cluster. Newly created indices on the remote cluster matching any of the specified patterns will be automatically configured as follower indices. - ``_ + ``_ :arg name: The name of the auto follow pattern. :arg body: The specification of the auto follow pattern @@ -161,7 +161,7 @@ class CcrClient(NamespacedClient): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( + return await self.transport.perform_request( "PUT", _make_path("_ccr", "auto_follow", name), params=params, @@ -170,10 +170,10 @@ class CcrClient(NamespacedClient): ) @query_params() - def resume_follow(self, index, body=None, params=None, headers=None): + async def resume_follow(self, index, body=None, params=None, headers=None): """ Resumes a follower index that has been paused - ``_ + ``_ :arg index: The name of the follow index to resume following. :arg body: The name of the leader index and other optional ccr @@ -182,7 +182,7 @@ class CcrClient(NamespacedClient): if index in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'index'.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path(index, "_ccr", "resume_follow"), params=params, @@ -191,21 +191,21 @@ class CcrClient(NamespacedClient): ) @query_params() - def stats(self, params=None, headers=None): + async def stats(self, params=None, headers=None): """ Gets all stats related to cross-cluster replication. - ``_ + ``_ """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", "/_ccr/stats", params=params, headers=headers ) @query_params() - def unfollow(self, index, params=None, headers=None): + async def unfollow(self, index, params=None, headers=None): """ Stops the following task associated with a follower index and removes index metadata and settings associated with cross-cluster replication. - ``_ + ``_ :arg index: The name of the follower index that should be turned into a regular index. @@ -213,7 +213,7 @@ class CcrClient(NamespacedClient): if index in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'index'.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path(index, "_ccr", "unfollow"), params=params, @@ -221,10 +221,10 @@ class CcrClient(NamespacedClient): ) @query_params() - def pause_auto_follow_pattern(self, name, params=None, headers=None): + async def pause_auto_follow_pattern(self, name, params=None, headers=None): """ Pauses an auto-follow pattern - ``_ + ``_ :arg name: The name of the auto follow pattern that should pause discovering new indices to follow. @@ -232,7 +232,7 @@ class CcrClient(NamespacedClient): if name in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'name'.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path("_ccr", "auto_follow", name, "pause"), params=params, @@ -240,10 +240,10 @@ class CcrClient(NamespacedClient): ) @query_params() - def resume_auto_follow_pattern(self, name, params=None, headers=None): + async def resume_auto_follow_pattern(self, name, params=None, headers=None): """ Resumes an auto-follow pattern that has been paused - ``_ + ``_ :arg name: The name of the auto follow pattern to resume discovering new indices to follow. @@ -251,7 +251,7 @@ class CcrClient(NamespacedClient): if name in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'name'.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path("_ccr", "auto_follow", name, "resume"), params=params, diff --git a/elasticsearch/_async/client/cluster.py b/elasticsearch/_async/client/cluster.py index 600b89e7..93933cab 100644 --- a/elasticsearch/_async/client/cluster.py +++ b/elasticsearch/_async/client/cluster.py @@ -19,10 +19,10 @@ class ClusterClient(NamespacedClient): "wait_for_nodes", "wait_for_status", ) - def health(self, index=None, params=None, headers=None): + async def health(self, index=None, params=None, headers=None): """ Returns basic information about the health of the cluster. - ``_ + ``_ :arg index: Limit the information returned to a specific index :arg expand_wildcards: Whether to expand wildcard expression to @@ -49,7 +49,7 @@ class ClusterClient(NamespacedClient): :arg wait_for_status: Wait until cluster is in a specific state Valid choices: green, yellow, red """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_cluster", "health", index), params=params, @@ -57,17 +57,17 @@ class ClusterClient(NamespacedClient): ) @query_params("local", "master_timeout") - def pending_tasks(self, params=None, headers=None): + async def pending_tasks(self, params=None, headers=None): """ Returns a list of any cluster-level changes (e.g. create index, update mapping, allocate or fail shard) which have not yet been executed. - ``_ + ``_ :arg local: Return local information, do not retrieve the state from master node (default: false) :arg master_timeout: Specify timeout for connection to master """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", "/_cluster/pending_tasks", params=params, headers=headers ) @@ -81,10 +81,10 @@ class ClusterClient(NamespacedClient): "wait_for_metadata_version", "wait_for_timeout", ) - def state(self, metric=None, index=None, params=None, headers=None): + async def state(self, metric=None, index=None, params=None, headers=None): """ Returns a comprehensive information about the state of the cluster. - ``_ + ``_ :arg metric: Limit the information returned to the specified metrics Valid choices: _all, blocks, metadata, nodes, routing_table, @@ -112,7 +112,7 @@ class ClusterClient(NamespacedClient): if index and metric in SKIP_IN_PATH: metric = "_all" - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_cluster", "state", metric, index), params=params, @@ -120,10 +120,10 @@ class ClusterClient(NamespacedClient): ) @query_params("flat_settings", "timeout") - def stats(self, node_id=None, params=None, headers=None): + async def stats(self, node_id=None, params=None, headers=None): """ Returns high-level overview of cluster statistics. - ``_ + ``_ :arg node_id: A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from @@ -133,7 +133,7 @@ class ClusterClient(NamespacedClient): false) :arg timeout: Explicit operation timeout """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", "/_cluster/stats" if node_id in SKIP_IN_PATH @@ -145,10 +145,10 @@ class ClusterClient(NamespacedClient): @query_params( "dry_run", "explain", "master_timeout", "metric", "retry_failed", "timeout" ) - def reroute(self, body=None, params=None, headers=None): + async def reroute(self, body=None, params=None, headers=None): """ Allows to manually change the allocation of individual shards in the cluster. - ``_ + ``_ :arg body: The definition of `commands` to perform (`move`, `cancel`, `allocate`) @@ -165,15 +165,15 @@ class ClusterClient(NamespacedClient): due to too many subsequent allocation failures :arg timeout: Explicit operation timeout """ - return self.transport.perform_request( + return await self.transport.perform_request( "POST", "/_cluster/reroute", params=params, headers=headers, body=body ) @query_params("flat_settings", "include_defaults", "master_timeout", "timeout") - def get_settings(self, params=None, headers=None): + async def get_settings(self, params=None, headers=None): """ Returns cluster settings. - ``_ + ``_ :arg flat_settings: Return settings in flat format (default: false) @@ -183,15 +183,15 @@ class ClusterClient(NamespacedClient): to master node :arg timeout: Explicit operation timeout """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", "/_cluster/settings", params=params, headers=headers ) @query_params("flat_settings", "master_timeout", "timeout") - def put_settings(self, body, params=None, headers=None): + async def put_settings(self, body, params=None, headers=None): """ Updates the cluster settings. - ``_ + ``_ :arg body: The settings to be updated. Can be either `transient` or `persistent` (survives cluster restart). @@ -204,25 +204,25 @@ class ClusterClient(NamespacedClient): if body in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'body'.") - return self.transport.perform_request( + return await self.transport.perform_request( "PUT", "/_cluster/settings", params=params, headers=headers, body=body ) @query_params() - def remote_info(self, params=None, headers=None): + async def remote_info(self, params=None, headers=None): """ Returns the information about configured remote clusters. - ``_ + ``_ """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", "/_remote/info", params=params, headers=headers ) @query_params("include_disk_info", "include_yes_decisions") - def allocation_explain(self, body=None, params=None, headers=None): + async def allocation_explain(self, body=None, params=None, headers=None): """ Provides explanations for shard allocations in the cluster. - ``_ + ``_ :arg body: The index, shard, and primary flag to explain. Empty means 'explain the first unassigned shard' @@ -231,7 +231,7 @@ class ClusterClient(NamespacedClient): :arg include_yes_decisions: Return 'YES' decisions in explanation (default: false) """ - return self.transport.perform_request( + return await self.transport.perform_request( "POST", "/_cluster/allocation/explain", params=params, @@ -240,10 +240,10 @@ class ClusterClient(NamespacedClient): ) @query_params("master_timeout", "timeout") - def delete_component_template(self, name, params=None, headers=None): + async def delete_component_template(self, name, params=None, headers=None): """ Deletes a component template - ``_ + ``_ :arg name: The name of the template :arg master_timeout: Specify timeout for connection to master @@ -252,7 +252,7 @@ class ClusterClient(NamespacedClient): if name in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'name'.") - return self.transport.perform_request( + return await self.transport.perform_request( "DELETE", _make_path("_component_template", name), params=params, @@ -260,10 +260,10 @@ class ClusterClient(NamespacedClient): ) @query_params("local", "master_timeout") - def get_component_template(self, name=None, params=None, headers=None): + async def get_component_template(self, name=None, params=None, headers=None): """ Returns one or more component templates - ``_ + ``_ :arg name: The comma separated names of the component templates :arg local: Return local information, do not retrieve the state @@ -271,7 +271,7 @@ class ClusterClient(NamespacedClient): :arg master_timeout: Explicit operation timeout for connection to master node """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_component_template", name), params=params, @@ -279,10 +279,10 @@ class ClusterClient(NamespacedClient): ) @query_params("create", "master_timeout", "timeout") - def put_component_template(self, name, body, params=None, headers=None): + async def put_component_template(self, name, body, params=None, headers=None): """ Creates or updates a component template - ``_ + ``_ :arg name: The name of the template :arg body: The template definition @@ -295,7 +295,7 @@ class ClusterClient(NamespacedClient): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( + return await self.transport.perform_request( "PUT", _make_path("_component_template", name), params=params, @@ -304,10 +304,10 @@ class ClusterClient(NamespacedClient): ) @query_params("local", "master_timeout") - def exists_component_template(self, name, params=None, headers=None): + async def exists_component_template(self, name, params=None, headers=None): """ Returns information about whether a particular component template exist - ``_ + ``_ :arg name: The name of the template :arg local: Return local information, do not retrieve the state @@ -318,7 +318,7 @@ class ClusterClient(NamespacedClient): if name in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'name'.") - return self.transport.perform_request( + return await self.transport.perform_request( "HEAD", _make_path("_component_template", name), params=params, @@ -326,16 +326,16 @@ class ClusterClient(NamespacedClient): ) @query_params("wait_for_removal") - def delete_voting_config_exclusions(self, params=None, headers=None): + async def delete_voting_config_exclusions(self, params=None, headers=None): """ Clears cluster voting config exclusions. - ``_ + ``_ :arg wait_for_removal: Specifies whether to wait for all excluded nodes to be removed from the cluster before clearing the voting configuration exclusions list. Default: True """ - return self.transport.perform_request( + return await self.transport.perform_request( "DELETE", "/_cluster/voting_config_exclusions", params=params, @@ -343,10 +343,10 @@ class ClusterClient(NamespacedClient): ) @query_params("node_ids", "node_names", "timeout") - def post_voting_config_exclusions(self, params=None, headers=None): + async def post_voting_config_exclusions(self, params=None, headers=None): """ Updates the cluster voting config exclusions by node ids or node names. - ``_ + ``_ :arg node_ids: A comma-separated list of the persistent ids of the nodes to exclude from the voting configuration. If specified, you @@ -356,6 +356,6 @@ class ClusterClient(NamespacedClient): not also specify ?node_ids. :arg timeout: Explicit operation timeout Default: 30s """ - return self.transport.perform_request( + return await self.transport.perform_request( "POST", "/_cluster/voting_config_exclusions", params=params, headers=headers ) diff --git a/elasticsearch/_async/client/data_frame.py b/elasticsearch/_async/client/data_frame.py new file mode 100644 index 00000000..48dcfda5 --- /dev/null +++ b/elasticsearch/_async/client/data_frame.py @@ -0,0 +1,141 @@ +# Licensed to Elasticsearch B.V under one or more agreements. +# Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +# See the LICENSE file in the project root for more information + +from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH + + +class Data_FrameClient(NamespacedClient): + @query_params() + async def delete_data_frame_transform( + self, transform_id, params=None, headers=None + ): + """ + ``_ + + :arg transform_id: The id of the transform to delete + """ + if transform_id in SKIP_IN_PATH: + raise ValueError( + "Empty value passed for a required argument 'transform_id'." + ) + return await self.transport.perform_request( + "DELETE", + _make_path("_data_frame", "transforms", transform_id), + params=params, + headers=headers, + ) + + @query_params("from_", "size") + async def get_data_frame_transform( + self, transform_id=None, params=None, headers=None + ): + """ + ``_ + + :arg transform_id: The id or comma delimited list of id expressions of + the transforms to get, '_all' or '*' implies get all transforms + :arg from_: skips a number of transform configs, defaults to 0 + :arg size: specifies a max number of transforms to get, defaults to 100 + """ + return await self.transport.perform_request( + "GET", + _make_path("_data_frame", "transforms", transform_id), + params=params, + headers=headers, + ) + + @query_params() + async def get_data_frame_transform_stats( + self, transform_id=None, params=None, headers=None + ): + """ + ``_ + + :arg transform_id: The id of the transform for which to get stats. + '_all' or '*' implies all transforms + """ + return await self.transport.perform_request( + "GET", + _make_path("_data_frame", "transforms", transform_id, "_stats"), + params=params, + ) + + @query_params() + async def preview_data_frame_transform(self, body, params=None, headers=None): + """ + ``_ + + :arg body: The definition for the data_frame transform to preview + """ + if body in SKIP_IN_PATH: + raise ValueError("Empty value passed for a required argument 'body'.") + return await self.transport.perform_request( + "POST", + "/_data_frame/transforms/_preview", + params=params, + headers=headers, + body=body, + ) + + @query_params() + async def put_data_frame_transform( + self, transform_id, body, params=None, headers=None + ): + """ + ``_ + + :arg transform_id: The id of the new transform. + :arg body: The data frame transform definition + """ + for param in (transform_id, body): + if param in SKIP_IN_PATH: + raise ValueError("Empty value passed for a required argument.") + return await self.transport.perform_request( + "PUT", + _make_path("_data_frame", "transforms", transform_id), + params=params, + headers=headers, + body=body, + ) + + @query_params("timeout") + async def start_data_frame_transform(self, transform_id, params=None, headers=None): + """ + ``_ + + :arg transform_id: The id of the transform to start + :arg timeout: Controls the time to wait for the transform to start + """ + if transform_id in SKIP_IN_PATH: + raise ValueError( + "Empty value passed for a required argument 'transform_id'." + ) + return await self.transport.perform_request( + "POST", + _make_path("_data_frame", "transforms", transform_id, "_start"), + params=params, + headers=headers, + ) + + @query_params("timeout", "wait_for_completion") + async def stop_data_frame_transform(self, transform_id, params=None, headers=None): + """ + ``_ + + :arg transform_id: The id of the transform to stop + :arg timeout: Controls the time to wait until the transform has stopped. + Default to 30 seconds + :arg wait_for_completion: Whether to wait for the transform to fully + stop before returning or not. Default to false + """ + if transform_id in SKIP_IN_PATH: + raise ValueError( + "Empty value passed for a required argument 'transform_id'." + ) + return await self.transport.perform_request( + "POST", + _make_path("_data_frame", "transforms", transform_id, "_stop"), + params=params, + headers=headers, + ) diff --git a/elasticsearch/_async/client/deprecation.py b/elasticsearch/_async/client/deprecation.py new file mode 100644 index 00000000..deeb978d --- /dev/null +++ b/elasticsearch/_async/client/deprecation.py @@ -0,0 +1,21 @@ +# Licensed to Elasticsearch B.V under one or more agreements. +# Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +# See the LICENSE file in the project root for more information + +from .utils import NamespacedClient, query_params, _make_path + + +class DeprecationClient(NamespacedClient): + @query_params() + async def info(self, index=None, params=None, headers=None): + """ + ``_ + + :arg index: Index pattern + """ + return await self.transport.perform_request( + "GET", + _make_path(index, "_xpack", "migration", "deprecations"), + params=params, + headers=headers, + ) diff --git a/elasticsearch/_async/client/enrich.py b/elasticsearch/_async/client/enrich.py index ba51d0e1..6d1f7b91 100644 --- a/elasticsearch/_async/client/enrich.py +++ b/elasticsearch/_async/client/enrich.py @@ -7,17 +7,17 @@ from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH class EnrichClient(NamespacedClient): @query_params() - def delete_policy(self, name, params=None, headers=None): + async def delete_policy(self, name, params=None, headers=None): """ Deletes an existing enrich policy and its enrich index. - ``_ + ``_ :arg name: The name of the enrich policy """ if name in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'name'.") - return self.transport.perform_request( + return await self.transport.perform_request( "DELETE", _make_path("_enrich", "policy", name), params=params, @@ -25,10 +25,10 @@ class EnrichClient(NamespacedClient): ) @query_params("wait_for_completion") - def execute_policy(self, name, params=None, headers=None): + async def execute_policy(self, name, params=None, headers=None): """ Creates the enrich index for an existing enrich policy. - ``_ + ``_ :arg name: The name of the enrich policy :arg wait_for_completion: Should the request should block until @@ -37,7 +37,7 @@ class EnrichClient(NamespacedClient): if name in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'name'.") - return self.transport.perform_request( + return await self.transport.perform_request( "PUT", _make_path("_enrich", "policy", name, "_execute"), params=params, @@ -45,22 +45,22 @@ class EnrichClient(NamespacedClient): ) @query_params() - def get_policy(self, name=None, params=None, headers=None): + async def get_policy(self, name=None, params=None, headers=None): """ Gets information about an enrich policy. - ``_ + ``_ :arg name: A comma-separated list of enrich policy names """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_enrich", "policy", name), params=params, headers=headers ) @query_params() - def put_policy(self, name, body, params=None, headers=None): + async def put_policy(self, name, body, params=None, headers=None): """ Creates a new enrich policy. - ``_ + ``_ :arg name: The name of the enrich policy :arg body: The enrich policy to register @@ -69,7 +69,7 @@ class EnrichClient(NamespacedClient): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( + return await self.transport.perform_request( "PUT", _make_path("_enrich", "policy", name), params=params, @@ -78,12 +78,12 @@ class EnrichClient(NamespacedClient): ) @query_params() - def stats(self, params=None, headers=None): + async def stats(self, params=None, headers=None): """ Gets enrich coordinator statistics and information about enrich policies that are currently executing. - ``_ + ``_ """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", "/_enrich/_stats", params=params, headers=headers ) diff --git a/elasticsearch/_async/client/eql.py b/elasticsearch/_async/client/eql.py index 01bb4aaa..11b23830 100644 --- a/elasticsearch/_async/client/eql.py +++ b/elasticsearch/_async/client/eql.py @@ -7,10 +7,10 @@ from .utils import NamespacedClient, SKIP_IN_PATH, query_params, _make_path class EqlClient(NamespacedClient): @query_params() - def search(self, index, body, params=None, headers=None): + async def search(self, index, body, params=None, headers=None): """ Returns results matching a query expressed in Event Query Language (EQL) - ``_ + ``_ :arg index: The name of the index to scope the operation :arg body: Eql request body. Use the `query` to limit the query @@ -20,7 +20,7 @@ class EqlClient(NamespacedClient): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path(index, "_eql", "search"), params=params, diff --git a/elasticsearch/_async/client/graph.py b/elasticsearch/_async/client/graph.py index 3c560615..489dd8dd 100644 --- a/elasticsearch/_async/client/graph.py +++ b/elasticsearch/_async/client/graph.py @@ -7,24 +7,26 @@ from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH class GraphClient(NamespacedClient): @query_params("routing", "timeout") - def explore(self, index, body=None, params=None, headers=None): + async def explore(self, index, body=None, doc_type=None, params=None, headers=None): """ Explore extracted and summarized information about the documents and terms in an index. - ``_ + ``_ :arg index: A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices :arg body: Graph Query DSL + :arg doc_type: A comma-separated list of document types to + search; leave empty to perform the operation on all types :arg routing: Specific routing value :arg timeout: Explicit operation timeout """ if index in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'index'.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", - _make_path(index, "_graph", "explore"), + _make_path(index, doc_type, "_graph", "explore"), params=params, headers=headers, body=body, diff --git a/elasticsearch/_async/client/ilm.py b/elasticsearch/_async/client/ilm.py index 4e09316d..e25e9774 100644 --- a/elasticsearch/_async/client/ilm.py +++ b/elasticsearch/_async/client/ilm.py @@ -7,18 +7,18 @@ from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH class IlmClient(NamespacedClient): @query_params() - def delete_lifecycle(self, policy, params=None, headers=None): + async def delete_lifecycle(self, policy, params=None, headers=None): """ Deletes the specified lifecycle policy definition. A currently used policy cannot be deleted. - ``_ + ``_ :arg policy: The name of the index lifecycle policy """ if policy in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'policy'.") - return self.transport.perform_request( + return await self.transport.perform_request( "DELETE", _make_path("_ilm", "policy", policy), params=params, @@ -26,11 +26,11 @@ class IlmClient(NamespacedClient): ) @query_params("only_errors", "only_managed") - def explain_lifecycle(self, index, params=None, headers=None): + async def explain_lifecycle(self, index, params=None, headers=None): """ Retrieves information about the index's current lifecycle state, such as the currently executing phase, action, and step. - ``_ + ``_ :arg index: The name of the index to explain :arg only_errors: filters the indices included in the response @@ -41,38 +41,38 @@ class IlmClient(NamespacedClient): if index in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'index'.") - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path(index, "_ilm", "explain"), params=params, headers=headers ) @query_params() - def get_lifecycle(self, policy=None, params=None, headers=None): + async def get_lifecycle(self, policy=None, params=None, headers=None): """ Returns the specified policy definition. Includes the policy version and last modified date. - ``_ + ``_ :arg policy: The name of the index lifecycle policy """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_ilm", "policy", policy), params=params, headers=headers ) @query_params() - def get_status(self, params=None, headers=None): + async def get_status(self, params=None, headers=None): """ Retrieves the current index lifecycle management (ILM) status. - ``_ + ``_ """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", "/_ilm/status", params=params, headers=headers ) @query_params() - def move_to_step(self, index, body=None, params=None, headers=None): + async def move_to_step(self, index, body=None, params=None, headers=None): """ Manually moves an index into the specified step and executes that step. - ``_ + ``_ :arg index: The name of the index whose lifecycle step is to change @@ -81,7 +81,7 @@ class IlmClient(NamespacedClient): if index in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'index'.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path("_ilm", "move", index), params=params, @@ -90,10 +90,10 @@ class IlmClient(NamespacedClient): ) @query_params() - def put_lifecycle(self, policy, body=None, params=None, headers=None): + async def put_lifecycle(self, policy, body=None, params=None, headers=None): """ Creates a lifecycle policy - ``_ + ``_ :arg policy: The name of the index lifecycle policy :arg body: The lifecycle policy definition to register @@ -101,7 +101,7 @@ class IlmClient(NamespacedClient): if policy in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'policy'.") - return self.transport.perform_request( + return await self.transport.perform_request( "PUT", _make_path("_ilm", "policy", policy), params=params, @@ -110,25 +110,25 @@ class IlmClient(NamespacedClient): ) @query_params() - def remove_policy(self, index, params=None, headers=None): + async def remove_policy(self, index, params=None, headers=None): """ Removes the assigned lifecycle policy and stops managing the specified index - ``_ + ``_ :arg index: The name of the index to remove policy on """ if index in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'index'.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path(index, "_ilm", "remove"), params=params, headers=headers ) @query_params() - def retry(self, index, params=None, headers=None): + async def retry(self, index, params=None, headers=None): """ Retries executing the policy for an index that is in the ERROR step. - ``_ + ``_ :arg index: The name of the indices (comma-separated) whose failed lifecycle step is to be retry @@ -136,27 +136,27 @@ class IlmClient(NamespacedClient): if index in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'index'.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path(index, "_ilm", "retry"), params=params, headers=headers ) @query_params() - def start(self, params=None, headers=None): + async def start(self, params=None, headers=None): """ Start the index lifecycle management (ILM) plugin. - ``_ + ``_ """ - return self.transport.perform_request( + return await self.transport.perform_request( "POST", "/_ilm/start", params=params, headers=headers ) @query_params() - def stop(self, params=None, headers=None): + async def stop(self, params=None, headers=None): """ Halts all lifecycle management operations and stops the index lifecycle management (ILM) plugin - ``_ + ``_ """ - return self.transport.perform_request( + return await self.transport.perform_request( "POST", "/_ilm/stop", params=params, headers=headers ) diff --git a/elasticsearch/_async/client/indices.py b/elasticsearch/_async/client/indices.py index 68efaf62..9b27fc9e 100644 --- a/elasticsearch/_async/client/indices.py +++ b/elasticsearch/_async/client/indices.py @@ -7,17 +7,17 @@ from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH class IndicesClient(NamespacedClient): @query_params() - def analyze(self, body=None, index=None, params=None, headers=None): + async def analyze(self, body=None, index=None, params=None, headers=None): """ Performs the analysis process on a text and return the tokens breakdown of the text. - ``_ + ``_ :arg body: Define analyzer/tokenizer parameters and the text on which the analysis should be performed :arg index: The name of the index to scope the operation """ - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path(index, "_analyze"), params=params, @@ -26,10 +26,10 @@ class IndicesClient(NamespacedClient): ) @query_params("allow_no_indices", "expand_wildcards", "ignore_unavailable") - def refresh(self, index=None, params=None, headers=None): + async def refresh(self, index=None, params=None, headers=None): """ Performs the refresh operation in one or more indices. - ``_ + ``_ :arg index: A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices @@ -42,7 +42,7 @@ class IndicesClient(NamespacedClient): :arg ignore_unavailable: Whether specified concrete indices should be ignored when unavailable (missing or closed) """ - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path(index, "_refresh"), params=params, headers=headers ) @@ -53,10 +53,10 @@ class IndicesClient(NamespacedClient): "ignore_unavailable", "wait_if_ongoing", ) - def flush(self, index=None, params=None, headers=None): + async def flush(self, index=None, params=None, headers=None): """ Performs the flush operation on one or more indices. - ``_ + ``_ :arg index: A comma-separated list of index names; use `_all` or empty string for all indices @@ -78,19 +78,23 @@ class IndicesClient(NamespacedClient): already executing. The default is true. If set to false the flush will be skipped iff if another flush operation is already running. """ - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path(index, "_flush"), params=params, headers=headers ) - @query_params("master_timeout", "timeout", "wait_for_active_shards") - def create(self, index, body=None, params=None, headers=None): + @query_params( + "include_type_name", "master_timeout", "timeout", "wait_for_active_shards" + ) + async def create(self, index, body=None, params=None, headers=None): """ Creates an index with optional settings and mappings. - ``_ + ``_ :arg index: The name of the index :arg body: The configuration for the index (`settings` and `mappings`) + :arg include_type_name: Whether a type should be expected in the + body of the mappings. :arg master_timeout: Specify timeout for connection to master :arg timeout: Explicit operation timeout :arg wait_for_active_shards: Set the number of active shards to @@ -99,15 +103,15 @@ class IndicesClient(NamespacedClient): if index in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'index'.") - return self.transport.perform_request( + return await self.transport.perform_request( "PUT", _make_path(index), params=params, headers=headers, body=body ) @query_params("master_timeout", "timeout", "wait_for_active_shards") - def clone(self, index, target, body=None, params=None, headers=None): + async def clone(self, index, target, body=None, params=None, headers=None): """ Clones an index - ``_ + ``_ :arg index: The name of the source index to clone :arg target: The name of the target index to clone into @@ -122,7 +126,7 @@ class IndicesClient(NamespacedClient): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( + return await self.transport.perform_request( "PUT", _make_path(index, "_clone", target), params=params, @@ -136,13 +140,14 @@ class IndicesClient(NamespacedClient): "flat_settings", "ignore_unavailable", "include_defaults", + "include_type_name", "local", "master_timeout", ) - def get(self, index, params=None, headers=None): + async def get(self, index, params=None, headers=None): """ Returns information about one or more indices. - ``_ + ``_ :arg index: A comma-separated list of index names :arg allow_no_indices: Ignore if a wildcard expression resolves @@ -156,6 +161,8 @@ class IndicesClient(NamespacedClient): false) :arg include_defaults: Whether to return all default setting for each of the indices. + :arg include_type_name: Whether to add the type name to the + response (default: false) :arg local: Return local information, do not retrieve the state from master node (default: false) :arg master_timeout: Specify timeout for connection to master @@ -163,7 +170,7 @@ class IndicesClient(NamespacedClient): if index in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'index'.") - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path(index), params=params, headers=headers ) @@ -175,10 +182,10 @@ class IndicesClient(NamespacedClient): "timeout", "wait_for_active_shards", ) - def open(self, index, params=None, headers=None): + async def open(self, index, params=None, headers=None): """ Opens an index. - ``_ + ``_ :arg index: A comma separated list of indices to open :arg allow_no_indices: Whether to ignore if a wildcard indices @@ -197,7 +204,7 @@ class IndicesClient(NamespacedClient): if index in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'index'.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path(index, "_open"), params=params, headers=headers ) @@ -209,10 +216,10 @@ class IndicesClient(NamespacedClient): "timeout", "wait_for_active_shards", ) - def close(self, index, params=None, headers=None): + async def close(self, index, params=None, headers=None): """ Closes an index. - ``_ + ``_ :arg index: A comma separated list of indices to close :arg allow_no_indices: Whether to ignore if a wildcard indices @@ -231,7 +238,7 @@ class IndicesClient(NamespacedClient): if index in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'index'.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path(index, "_close"), params=params, headers=headers ) @@ -242,10 +249,10 @@ class IndicesClient(NamespacedClient): "master_timeout", "timeout", ) - def delete(self, index, params=None, headers=None): + async def delete(self, index, params=None, headers=None): """ Deletes an index. - ``_ + ``_ :arg index: A comma-separated list of indices to delete; use `_all` or `*` string to delete all indices @@ -262,7 +269,7 @@ class IndicesClient(NamespacedClient): if index in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'index'.") - return self.transport.perform_request( + return await self.transport.perform_request( "DELETE", _make_path(index), params=params, headers=headers ) @@ -274,10 +281,10 @@ class IndicesClient(NamespacedClient): "include_defaults", "local", ) - def exists(self, index, params=None, headers=None): + async def exists(self, index, params=None, headers=None): """ Returns information about whether a particular index exists. - ``_ + ``_ :arg index: A comma-separated list of index names :arg allow_no_indices: Ignore if a wildcard expression resolves @@ -297,16 +304,16 @@ class IndicesClient(NamespacedClient): if index in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'index'.") - return self.transport.perform_request( + return await self.transport.perform_request( "HEAD", _make_path(index), params=params, headers=headers ) @query_params("allow_no_indices", "expand_wildcards", "ignore_unavailable", "local") - def exists_type(self, index, doc_type, params=None, headers=None): + async def exists_type(self, index, doc_type, params=None, headers=None): """ Returns information about whether a particular document type exists. (DEPRECATED) - ``_ + ``_ :arg index: A comma-separated list of index names; use `_all` to check the types across all indices @@ -326,7 +333,7 @@ class IndicesClient(NamespacedClient): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( + return await self.transport.perform_request( "HEAD", _make_path(index, "_mapping", doc_type), params=params, @@ -337,18 +344,22 @@ class IndicesClient(NamespacedClient): "allow_no_indices", "expand_wildcards", "ignore_unavailable", + "include_type_name", "master_timeout", "timeout", ) - def put_mapping(self, index, body, params=None, headers=None): + async def put_mapping( + self, body, index=None, doc_type=None, params=None, headers=None + ): """ Updates the index mappings. - ``_ + ``_ + :arg body: The mapping definition :arg index: A comma-separated list of index names the mapping should be added to (supports wildcards); use `_all` or omit to add the mapping on all indices. - :arg body: The mapping definition + :arg doc_type: The name of the document type :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) @@ -357,16 +368,20 @@ class IndicesClient(NamespacedClient): closed, hidden, none, all Default: open :arg ignore_unavailable: Whether specified concrete indices should be ignored when unavailable (missing or closed) + :arg include_type_name: Whether a type should be expected in the + body of the mappings. :arg master_timeout: Specify timeout for connection to master :arg timeout: Explicit operation timeout """ - for param in (index, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") + if body in SKIP_IN_PATH: + raise ValueError("Empty value passed for a required argument 'body'.") - return self.transport.perform_request( + if doc_type not in SKIP_IN_PATH and index in SKIP_IN_PATH: + index = "_all" + + return await self.transport.perform_request( "PUT", - _make_path(index, "_mapping"), + _make_path(index, doc_type, "_mapping"), params=params, headers=headers, body=body, @@ -376,15 +391,17 @@ class IndicesClient(NamespacedClient): "allow_no_indices", "expand_wildcards", "ignore_unavailable", + "include_type_name", "local", "master_timeout", ) - def get_mapping(self, index=None, params=None, headers=None): + async def get_mapping(self, index=None, doc_type=None, params=None, headers=None): """ Returns mappings for one or more indices. - ``_ + ``_ :arg index: A comma-separated list of index names + :arg doc_type: A comma-separated list of document types :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) @@ -393,19 +410,67 @@ class IndicesClient(NamespacedClient): closed, hidden, none, all Default: open :arg ignore_unavailable: Whether specified concrete indices should be ignored when unavailable (missing or closed) + :arg include_type_name: Whether to add the type name to the + response (default: false) :arg local: Return local information, do not retrieve the state from master node (default: false) :arg master_timeout: Specify timeout for connection to master """ - return self.transport.perform_request( - "GET", _make_path(index, "_mapping"), params=params, headers=headers + return await self.transport.perform_request( + "GET", + _make_path(index, "_mapping", doc_type), + params=params, + headers=headers, + ) + + @query_params( + "allow_no_indices", + "expand_wildcards", + "ignore_unavailable", + "include_defaults", + "include_type_name", + "local", + ) + async def get_field_mapping( + self, fields, index=None, doc_type=None, params=None, headers=None + ): + """ + Returns mapping for one or more fields. + ``_ + + :arg fields: A comma-separated list of fields + :arg index: A comma-separated list of index names + :arg doc_type: A comma-separated list of document types + :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 include_defaults: Whether the default mapping values should + be returned as well + :arg include_type_name: Whether a type should be returned in the + body of the mappings. + :arg local: Return local information, do not retrieve the state + from master node (default: false) + """ + if fields in SKIP_IN_PATH: + raise ValueError("Empty value passed for a required argument 'fields'.") + + return await self.transport.perform_request( + "GET", + _make_path(index, "_mapping", doc_type, "field", fields), + params=params, + headers=headers, ) @query_params("master_timeout", "timeout") - def put_alias(self, index, name, body=None, params=None, headers=None): + async def put_alias(self, index, name, body=None, params=None, headers=None): """ Creates or updates an alias. - ``_ + ``_ :arg index: A comma-separated list of index names the alias should point to (supports wildcards); use `_all` to perform the @@ -420,7 +485,7 @@ class IndicesClient(NamespacedClient): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( + return await self.transport.perform_request( "PUT", _make_path(index, "_alias", name), params=params, @@ -429,10 +494,10 @@ class IndicesClient(NamespacedClient): ) @query_params("allow_no_indices", "expand_wildcards", "ignore_unavailable", "local") - def exists_alias(self, name, index=None, params=None, headers=None): + async def exists_alias(self, name, index=None, params=None, headers=None): """ Returns information about whether a particular alias exists. - ``_ + ``_ :arg name: A comma-separated list of alias names to return :arg index: A comma-separated list of index names to filter @@ -451,15 +516,15 @@ class IndicesClient(NamespacedClient): if name in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'name'.") - return self.transport.perform_request( + return await self.transport.perform_request( "HEAD", _make_path(index, "_alias", name), params=params, headers=headers ) @query_params("allow_no_indices", "expand_wildcards", "ignore_unavailable", "local") - def get_alias(self, index=None, name=None, params=None, headers=None): + async def get_alias(self, index=None, name=None, params=None, headers=None): """ Returns an alias. - ``_ + ``_ :arg index: A comma-separated list of index names to filter aliases @@ -475,15 +540,15 @@ class IndicesClient(NamespacedClient): :arg local: Return local information, do not retrieve the state from master node (default: false) """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path(index, "_alias", name), params=params, headers=headers ) @query_params("master_timeout", "timeout") - def update_aliases(self, body, params=None, headers=None): + async def update_aliases(self, body, params=None, headers=None): """ Updates index aliases. - ``_ + ``_ :arg body: The definition of `actions` to perform :arg master_timeout: Specify timeout for connection to master @@ -492,15 +557,15 @@ class IndicesClient(NamespacedClient): if body in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'body'.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", "/_aliases", params=params, headers=headers, body=body ) @query_params("master_timeout", "timeout") - def delete_alias(self, index, name, params=None, headers=None): + async def delete_alias(self, index, name, params=None, headers=None): """ Deletes an alias. - ``_ + ``_ :arg index: A comma-separated list of index names (supports wildcards); use `_all` for all indices @@ -513,20 +578,22 @@ class IndicesClient(NamespacedClient): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( + return await self.transport.perform_request( "DELETE", _make_path(index, "_alias", name), params=params, headers=headers ) - @query_params("create", "master_timeout", "order") - def put_template(self, name, body, params=None, headers=None): + @query_params("create", "include_type_name", "master_timeout", "order") + async def put_template(self, name, body, params=None, headers=None): """ Creates or updates an index template. - ``_ + ``_ :arg name: The name of the template :arg body: The template definition :arg create: Whether the index template should only be added if new or can also replace an existing one + :arg include_type_name: Whether a type should be returned in the + body of the mappings. :arg master_timeout: Specify timeout for connection to master :arg order: The order for this template when merging multiple matching ones (higher numbers are merged later, overriding the lower @@ -536,7 +603,7 @@ class IndicesClient(NamespacedClient): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( + return await self.transport.perform_request( "PUT", _make_path("_template", name), params=params, @@ -545,10 +612,10 @@ class IndicesClient(NamespacedClient): ) @query_params("flat_settings", "local", "master_timeout") - def exists_template(self, name, params=None, headers=None): + async def exists_template(self, name, params=None, headers=None): """ Returns information about whether a particular index template exists. - ``_ + ``_ :arg name: The comma separated names of the index templates :arg flat_settings: Return settings in flat format (default: @@ -561,33 +628,35 @@ class IndicesClient(NamespacedClient): if name in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'name'.") - return self.transport.perform_request( + return await self.transport.perform_request( "HEAD", _make_path("_template", name), params=params, headers=headers ) - @query_params("flat_settings", "local", "master_timeout") - def get_template(self, name=None, params=None, headers=None): + @query_params("flat_settings", "include_type_name", "local", "master_timeout") + async def get_template(self, name=None, params=None, headers=None): """ Returns an index template. - ``_ + ``_ :arg name: The comma separated names of the index templates :arg flat_settings: Return settings in flat format (default: false) + :arg include_type_name: Whether a type should be returned in the + body of the mappings. :arg local: Return local information, do not retrieve the state from master node (default: false) :arg master_timeout: Explicit operation timeout for connection to master node """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_template", name), params=params, headers=headers ) @query_params("master_timeout", "timeout") - def delete_template(self, name, params=None, headers=None): + async def delete_template(self, name, params=None, headers=None): """ Deletes an index template. - ``_ + ``_ :arg name: The name of the template :arg master_timeout: Specify timeout for connection to master @@ -596,7 +665,7 @@ class IndicesClient(NamespacedClient): if name in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'name'.") - return self.transport.perform_request( + return await self.transport.perform_request( "DELETE", _make_path("_template", name), params=params, headers=headers ) @@ -609,10 +678,10 @@ class IndicesClient(NamespacedClient): "local", "master_timeout", ) - def get_settings(self, index=None, name=None, params=None, headers=None): + async def get_settings(self, index=None, name=None, params=None, headers=None): """ Returns settings for one or more indices. - ``_ + ``_ :arg index: A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices @@ -633,7 +702,7 @@ class IndicesClient(NamespacedClient): from master node (default: false) :arg master_timeout: Specify timeout for connection to master """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path(index, "_settings", name), params=params, headers=headers ) @@ -646,10 +715,10 @@ class IndicesClient(NamespacedClient): "preserve_existing", "timeout", ) - def put_settings(self, body, index=None, params=None, headers=None): + async def put_settings(self, body, index=None, params=None, headers=None): """ Updates the index settings. - ``_ + ``_ :arg body: The index settings to be updated :arg index: A comma-separated list of index names; use `_all` or @@ -673,7 +742,7 @@ class IndicesClient(NamespacedClient): if body in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'body'.") - return self.transport.perform_request( + return await self.transport.perform_request( "PUT", _make_path(index, "_settings"), params=params, @@ -693,17 +762,17 @@ class IndicesClient(NamespacedClient): "level", "types", ) - def stats(self, index=None, metric=None, params=None, headers=None): + async def stats(self, index=None, metric=None, params=None, headers=None): """ Provides statistics on operations happening in an index. - ``_ + ``_ :arg index: A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices :arg metric: Limit the information returned the specific metrics. Valid choices: _all, completion, docs, fielddata, query_cache, flush, get, indexing, merge, request_cache, refresh, search, segments, - store, warmer, suggest, bulk + store, warmer, suggest :arg completion_fields: A comma-separated list of fields for `fielddata` and `suggest` index metric (supports wildcards) :arg expand_wildcards: Whether to expand wildcard expression to @@ -729,17 +798,17 @@ class IndicesClient(NamespacedClient): :arg types: A comma-separated list of document types for the `indexing` index metric """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path(index, "_stats", metric), params=params, headers=headers ) @query_params( "allow_no_indices", "expand_wildcards", "ignore_unavailable", "verbose" ) - def segments(self, index=None, params=None, headers=None): + async def segments(self, index=None, params=None, headers=None): """ Provides low-level information about segments in a Lucene index. - ``_ + ``_ :arg index: A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices @@ -753,393 +822,10 @@ class IndicesClient(NamespacedClient): should be ignored when unavailable (missing or closed) :arg verbose: Includes detailed memory usage by Lucene. """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path(index, "_segments"), params=params, headers=headers ) - @query_params( - "allow_no_indices", - "expand_wildcards", - "fielddata", - "fields", - "ignore_unavailable", - "query", - "request", - ) - def clear_cache(self, index=None, params=None, headers=None): - """ - Clears all or specific caches for one or more indices. - ``_ - - :arg index: A comma-separated list of index name to limit the - operation - :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 fielddata: Clear field data - :arg fields: A comma-separated list of fields to clear when - using the `fielddata` parameter (default: all) - :arg ignore_unavailable: Whether specified concrete indices - should be ignored when unavailable (missing or closed) - :arg query: Clear query caches - :arg request: Clear request cache - """ - return self.transport.perform_request( - "POST", _make_path(index, "_cache", "clear"), params=params, headers=headers - ) - - @query_params("active_only", "detailed") - def recovery(self, index=None, params=None, headers=None): - """ - Returns information about ongoing index shard recoveries. - ``_ - - :arg index: A comma-separated list of index names; use `_all` or - empty string to perform the operation on all indices - :arg active_only: Display only those recoveries that are - currently on-going - :arg detailed: Whether to display detailed information about - shard recovery - """ - return self.transport.perform_request( - "GET", _make_path(index, "_recovery"), params=params, headers=headers - ) - - @query_params( - "allow_no_indices", - "expand_wildcards", - "ignore_unavailable", - "only_ancient_segments", - "wait_for_completion", - ) - def upgrade(self, index=None, params=None, headers=None): - """ - DEPRECATED Upgrades to the current version of Lucene. - ``_ - - :arg index: A comma-separated list of index names; use `_all` or - empty string to perform the operation on all indices - :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 only_ancient_segments: If true, only ancient (an older - Lucene major release) segments will be upgraded - :arg wait_for_completion: Specify whether the request should - block until the all segments are upgraded (default: false) - """ - return self.transport.perform_request( - "POST", _make_path(index, "_upgrade"), params=params, headers=headers - ) - - @query_params("allow_no_indices", "expand_wildcards", "ignore_unavailable") - def get_upgrade(self, index=None, params=None, headers=None): - """ - DEPRECATED Returns a progress status of current upgrade. - ``_ - - :arg index: A comma-separated list of index names; use `_all` or - empty string to perform the operation on all indices - :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) - """ - return self.transport.perform_request( - "GET", _make_path(index, "_upgrade"), params=params, headers=headers - ) - - @query_params( - "allow_no_indices", "expand_wildcards", "ignore_unavailable", "status" - ) - def shard_stores(self, index=None, params=None, headers=None): - """ - Provides store information for shard copies of indices. - ``_ - - :arg index: A comma-separated list of index names; use `_all` or - empty string to perform the operation on all indices - :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 status: A comma-separated list of statuses used to filter - on shards to get store information for Valid choices: green, yellow, - red, all - """ - return self.transport.perform_request( - "GET", _make_path(index, "_shard_stores"), params=params, headers=headers - ) - - @query_params( - "allow_no_indices", - "expand_wildcards", - "flush", - "ignore_unavailable", - "max_num_segments", - "only_expunge_deletes", - ) - def forcemerge(self, index=None, params=None, headers=None): - """ - Performs the force merge operation on one or more indices. - ``_ - - :arg index: A comma-separated list of index names; use `_all` or - empty string to perform the operation on all indices - :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 flush: Specify whether the index should be flushed after - performing the operation (default: true) - :arg ignore_unavailable: Whether specified concrete indices - should be ignored when unavailable (missing or closed) - :arg max_num_segments: The number of segments the index should - be merged into (default: dynamic) - :arg only_expunge_deletes: Specify whether the operation should - only expunge deleted documents - """ - return self.transport.perform_request( - "POST", _make_path(index, "_forcemerge"), params=params, headers=headers - ) - - @query_params("master_timeout", "timeout", "wait_for_active_shards") - def shrink(self, index, target, body=None, params=None, headers=None): - """ - Allow to shrink an existing index into a new index with fewer primary shards. - ``_ - - :arg index: The name of the source index to shrink - :arg target: The name of the target index to shrink into - :arg body: The configuration for the target index (`settings` - and `aliases`) - :arg master_timeout: Specify timeout for connection to master - :arg timeout: Explicit operation timeout - :arg wait_for_active_shards: Set the number of active shards to - wait for on the shrunken index before the operation returns. - """ - for param in (index, target): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return self.transport.perform_request( - "PUT", - _make_path(index, "_shrink", target), - params=params, - headers=headers, - body=body, - ) - - @query_params("master_timeout", "timeout", "wait_for_active_shards") - def split(self, index, target, body=None, params=None, headers=None): - """ - Allows you to split an existing index into a new index with more primary - shards. - ``_ - - :arg index: The name of the source index to split - :arg target: The name of the target index to split into - :arg body: The configuration for the target index (`settings` - and `aliases`) - :arg master_timeout: Specify timeout for connection to master - :arg timeout: Explicit operation timeout - :arg wait_for_active_shards: Set the number of active shards to - wait for on the shrunken index before the operation returns. - """ - for param in (index, target): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return self.transport.perform_request( - "PUT", - _make_path(index, "_split", target), - params=params, - headers=headers, - body=body, - ) - - @query_params("dry_run", "master_timeout", "timeout", "wait_for_active_shards") - def rollover(self, alias, body=None, new_index=None, params=None, headers=None): - """ - Updates an alias to point to a new index when the existing index is considered - to be too large or too old. - ``_ - - :arg alias: The name of the alias to rollover - :arg body: The conditions that needs to be met for executing - rollover - :arg new_index: The name of the rollover index - :arg dry_run: If set to true the rollover action will only be - validated but not actually performed even if a condition matches. The - default is false - :arg master_timeout: Specify timeout for connection to master - :arg timeout: Explicit operation timeout - :arg wait_for_active_shards: Set the number of active shards to - wait for on the newly created rollover index before the operation - returns. - """ - if alias in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'alias'.") - - return self.transport.perform_request( - "POST", - _make_path(alias, "_rollover", new_index), - params=params, - headers=headers, - body=body, - ) - - @query_params( - "allow_no_indices", - "expand_wildcards", - "ignore_unavailable", - "master_timeout", - "timeout", - "wait_for_active_shards", - ) - def freeze(self, index, params=None, headers=None): - """ - Freezes an index. A frozen index has almost no overhead on the cluster (except - for maintaining its metadata in memory) and is read-only. - ``_ - - :arg index: The name of the index to freeze - :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: closed - :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 - :arg wait_for_active_shards: Sets the number of active shards to - wait for before the operation returns. - """ - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return self.transport.perform_request( - "POST", _make_path(index, "_freeze"), params=params, headers=headers - ) - - @query_params( - "allow_no_indices", - "expand_wildcards", - "ignore_unavailable", - "master_timeout", - "timeout", - "wait_for_active_shards", - ) - def unfreeze(self, index, params=None, headers=None): - """ - Unfreezes an index. When a frozen index is unfrozen, the index goes through the - normal recovery process and becomes writeable again. - ``_ - - :arg index: The name of the index to unfreeze - :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: closed - :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 - :arg wait_for_active_shards: Sets the number of active shards to - wait for before the operation returns. - """ - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return self.transport.perform_request( - "POST", _make_path(index, "_unfreeze"), params=params, headers=headers - ) - - @query_params("allow_no_indices", "expand_wildcards", "ignore_unavailable") - def reload_search_analyzers(self, index, params=None, headers=None): - """ - Reloads an index's search analyzers and their resources. - ``_ - - :arg index: A comma-separated list of index names to reload - analyzers for - :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) - """ - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return self.transport.perform_request( - "GET", - _make_path(index, "_reload_search_analyzers"), - params=params, - headers=headers, - ) - - @query_params( - "allow_no_indices", - "expand_wildcards", - "ignore_unavailable", - "include_defaults", - "local", - ) - def get_field_mapping(self, fields, index=None, params=None, headers=None): - """ - Returns mapping for one or more fields. - ``_ - - :arg fields: A comma-separated list of fields - :arg index: A comma-separated list of index names - :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 include_defaults: Whether the default mapping values should - be returned as well - :arg local: Return local information, do not retrieve the state - from master node (default: false) - """ - if fields in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'fields'.") - - return self.transport.perform_request( - "GET", - _make_path(index, "_mapping", "field", fields), - params=params, - headers=headers, - ) - @query_params( "all_shards", "allow_no_indices", @@ -1154,12 +840,12 @@ class IndicesClient(NamespacedClient): "q", "rewrite", ) - def validate_query( + async def validate_query( self, body=None, index=None, doc_type=None, params=None, headers=None ): """ Allows a user to validate a potentially expensive query without executing it. - ``_ + ``_ :arg body: The query definition specified with the Query DSL :arg index: A comma-separated list of index names to restrict @@ -1192,7 +878,7 @@ class IndicesClient(NamespacedClient): :arg rewrite: Provide a more detailed explanation showing the actual Lucene query that will be executed. """ - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path(index, doc_type, "_validate", "query"), params=params, @@ -1200,11 +886,400 @@ class IndicesClient(NamespacedClient): body=body, ) + @query_params( + "allow_no_indices", + "expand_wildcards", + "fielddata", + "fields", + "ignore_unavailable", + "query", + "request", + ) + async def clear_cache(self, index=None, params=None, headers=None): + """ + Clears all or specific caches for one or more indices. + ``_ + + :arg index: A comma-separated list of index name to limit the + operation + :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 fielddata: Clear field data + :arg fields: A comma-separated list of fields to clear when + using the `fielddata` parameter (default: all) + :arg ignore_unavailable: Whether specified concrete indices + should be ignored when unavailable (missing or closed) + :arg query: Clear query caches + :arg request: Clear request cache + """ + return await self.transport.perform_request( + "POST", _make_path(index, "_cache", "clear"), params=params, headers=headers + ) + + @query_params("active_only", "detailed") + async def recovery(self, index=None, params=None, headers=None): + """ + Returns information about ongoing index shard recoveries. + ``_ + + :arg index: A comma-separated list of index names; use `_all` or + empty string to perform the operation on all indices + :arg active_only: Display only those recoveries that are + currently on-going + :arg detailed: Whether to display detailed information about + shard recovery + """ + return await self.transport.perform_request( + "GET", _make_path(index, "_recovery"), params=params, headers=headers + ) + + @query_params( + "allow_no_indices", + "expand_wildcards", + "ignore_unavailable", + "only_ancient_segments", + "wait_for_completion", + ) + async def upgrade(self, index=None, params=None, headers=None): + """ + The _upgrade API is no longer useful and will be removed. + ``_ + + :arg index: A comma-separated list of index names; use `_all` or + empty string to perform the operation on all indices + :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 only_ancient_segments: If true, only ancient (an older + Lucene major release) segments will be upgraded + :arg wait_for_completion: Specify whether the request should + block until the all segments are upgraded (default: false) + """ + return await self.transport.perform_request( + "POST", _make_path(index, "_upgrade"), params=params, headers=headers + ) + + @query_params("allow_no_indices", "expand_wildcards", "ignore_unavailable") + async def get_upgrade(self, index=None, params=None, headers=None): + """ + The _upgrade API is no longer useful and will be removed. + ``_ + + :arg index: A comma-separated list of index names; use `_all` or + empty string to perform the operation on all indices + :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) + """ + return await self.transport.perform_request( + "GET", _make_path(index, "_upgrade"), params=params, headers=headers + ) + + @query_params("allow_no_indices", "expand_wildcards", "ignore_unavailable") + async def flush_synced(self, index=None, params=None, headers=None): + """ + Performs a synced flush operation on one or more indices. Synced flush is + deprecated and will be removed in 8.0. Use flush instead + ``_ + + :arg index: A comma-separated list of index names; use `_all` or + empty string for all indices + :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, none, all Default: open + :arg ignore_unavailable: Whether specified concrete indices + should be ignored when unavailable (missing or closed) + """ + return await self.transport.perform_request( + "POST", + _make_path(index, "_flush", "synced"), + params=params, + headers=headers, + ) + + @query_params( + "allow_no_indices", "expand_wildcards", "ignore_unavailable", "status" + ) + async def shard_stores(self, index=None, params=None, headers=None): + """ + Provides store information for shard copies of indices. + ``_ + + :arg index: A comma-separated list of index names; use `_all` or + empty string to perform the operation on all indices + :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 status: A comma-separated list of statuses used to filter + on shards to get store information for Valid choices: green, yellow, + red, all + """ + return await self.transport.perform_request( + "GET", _make_path(index, "_shard_stores"), params=params, headers=headers + ) + + @query_params( + "allow_no_indices", + "expand_wildcards", + "flush", + "ignore_unavailable", + "max_num_segments", + "only_expunge_deletes", + ) + async def forcemerge(self, index=None, params=None, headers=None): + """ + Performs the force merge operation on one or more indices. + ``_ + + :arg index: A comma-separated list of index names; use `_all` or + empty string to perform the operation on all indices + :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 flush: Specify whether the index should be flushed after + performing the operation (default: true) + :arg ignore_unavailable: Whether specified concrete indices + should be ignored when unavailable (missing or closed) + :arg max_num_segments: The number of segments the index should + be merged into (default: dynamic) + :arg only_expunge_deletes: Specify whether the operation should + only expunge deleted documents + """ + return await self.transport.perform_request( + "POST", _make_path(index, "_forcemerge"), params=params, headers=headers + ) + + @query_params( + "copy_settings", "master_timeout", "timeout", "wait_for_active_shards" + ) + async def shrink(self, index, target, body=None, params=None, headers=None): + """ + Allow to shrink an existing index into a new index with fewer primary shards. + ``_ + + :arg index: The name of the source index to shrink + :arg target: The name of the target index to shrink into + :arg body: The configuration for the target index (`settings` + and `aliases`) + :arg copy_settings: whether or not to copy settings from the + source index (defaults to false) + :arg master_timeout: Specify timeout for connection to master + :arg timeout: Explicit operation timeout + :arg wait_for_active_shards: Set the number of active shards to + wait for on the shrunken index before the operation returns. + """ + for param in (index, target): + 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, "_shrink", target), + params=params, + headers=headers, + body=body, + ) + + @query_params( + "copy_settings", "master_timeout", "timeout", "wait_for_active_shards" + ) + async def split(self, index, target, body=None, params=None, headers=None): + """ + Allows you to split an existing index into a new index with more primary + shards. + ``_ + + :arg index: The name of the source index to split + :arg target: The name of the target index to split into + :arg body: The configuration for the target index (`settings` + and `aliases`) + :arg copy_settings: whether or not to copy settings from the + source index (defaults to false) + :arg master_timeout: Specify timeout for connection to master + :arg timeout: Explicit operation timeout + :arg wait_for_active_shards: Set the number of active shards to + wait for on the shrunken index before the operation returns. + """ + for param in (index, target): + 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, "_split", target), + params=params, + headers=headers, + body=body, + ) + + @query_params( + "dry_run", + "include_type_name", + "master_timeout", + "timeout", + "wait_for_active_shards", + ) + async def rollover( + self, alias, body=None, new_index=None, params=None, headers=None + ): + """ + Updates an alias to point to a new index when the existing index is considered + to be too large or too old. + ``_ + + :arg alias: The name of the alias to rollover + :arg body: The conditions that needs to be met for executing + rollover + :arg new_index: The name of the rollover index + :arg dry_run: If set to true the rollover action will only be + validated but not actually performed even if a condition matches. The + default is false + :arg include_type_name: Whether a type should be included in the + body of the mappings. + :arg master_timeout: Specify timeout for connection to master + :arg timeout: Explicit operation timeout + :arg wait_for_active_shards: Set the number of active shards to + wait for on the newly created rollover index before the operation + returns. + """ + if alias in SKIP_IN_PATH: + raise ValueError("Empty value passed for a required argument 'alias'.") + + return await self.transport.perform_request( + "POST", + _make_path(alias, "_rollover", new_index), + params=params, + headers=headers, + body=body, + ) + + @query_params( + "allow_no_indices", + "expand_wildcards", + "ignore_unavailable", + "master_timeout", + "timeout", + "wait_for_active_shards", + ) + async def freeze(self, index, params=None, headers=None): + """ + Freezes an index. A frozen index has almost no overhead on the cluster (except + for maintaining its metadata in memory) and is read-only. + ``_ + + :arg index: The name of the index to freeze + :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: closed + :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 + :arg wait_for_active_shards: Sets the number of active shards to + wait for before the operation returns. + """ + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for a required argument 'index'.") + + return await self.transport.perform_request( + "POST", _make_path(index, "_freeze"), params=params, headers=headers + ) + + @query_params( + "allow_no_indices", + "expand_wildcards", + "ignore_unavailable", + "master_timeout", + "timeout", + "wait_for_active_shards", + ) + async def unfreeze(self, index, params=None, headers=None): + """ + Unfreezes an index. When a frozen index is unfrozen, the index goes through the + normal recovery process and becomes writeable again. + ``_ + + :arg index: The name of the index to unfreeze + :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: closed + :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 + :arg wait_for_active_shards: Sets the number of active shards to + wait for before the operation returns. + """ + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for a required argument 'index'.") + + return await self.transport.perform_request( + "POST", _make_path(index, "_unfreeze"), params=params, headers=headers + ) + + @query_params("allow_no_indices", "expand_wildcards", "ignore_unavailable") + async def reload_search_analyzers(self, index, params=None, headers=None): + """ + Reloads an index's search analyzers and their resources. + ``_ + + :arg index: A comma-separated list of index names to reload + analyzers for + :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) + """ + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for a required argument 'index'.") + + return await self.transport.perform_request( + "GET", + _make_path(index, "_reload_search_analyzers"), + params=params, + headers=headers, + ) + @query_params() - def create_data_stream(self, name, body, params=None, headers=None): + async def create_data_stream(self, name, body, params=None, headers=None): """ Creates or updates a data stream - ``_ + ``_ :arg name: The name of the data stream :arg body: The data stream definition @@ -1213,7 +1288,7 @@ class IndicesClient(NamespacedClient): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( + return await self.transport.perform_request( "PUT", _make_path("_data_stream", name), params=params, @@ -1222,38 +1297,25 @@ class IndicesClient(NamespacedClient): ) @query_params() - def delete_data_stream(self, name, params=None, headers=None): + async def delete_data_stream(self, name, params=None, headers=None): """ Deletes a data stream. - ``_ + ``_ :arg name: The name of the data stream """ if name in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'name'.") - return self.transport.perform_request( + return await self.transport.perform_request( "DELETE", _make_path("_data_stream", name), params=params, headers=headers ) - @query_params() - def get_data_streams(self, name=None, params=None, headers=None): - """ - Returns data streams. - ``_ - - :arg name: The name or wildcard expression of the requested data - streams - """ - return self.transport.perform_request( - "GET", _make_path("_data_streams", name), params=params, headers=headers - ) - @query_params("master_timeout", "timeout") - def delete_index_template(self, name, params=None, headers=None): + async def delete_index_template(self, name, params=None, headers=None): """ Deletes an index template. - ``_ + ``_ :arg name: The name of the template :arg master_timeout: Specify timeout for connection to master @@ -1262,7 +1324,7 @@ class IndicesClient(NamespacedClient): if name in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'name'.") - return self.transport.perform_request( + return await self.transport.perform_request( "DELETE", _make_path("_index_template", name), params=params, @@ -1270,10 +1332,31 @@ class IndicesClient(NamespacedClient): ) @query_params("flat_settings", "local", "master_timeout") - def get_index_template(self, name=None, params=None, headers=None): + async def exists_index_template(self, name, params=None, headers=None): + """ + Returns information about whether a particular index template exists. + ``_ + + :arg name: The name of the template + :arg flat_settings: Return settings in flat format (default: + false) + :arg local: Return local information, do not retrieve the state + from master node (default: false) + :arg master_timeout: Explicit operation timeout for connection + to master node + """ + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for a required argument 'name'.") + + return await self.transport.perform_request( + "HEAD", _make_path("_index_template", name), params=params, headers=headers + ) + + @query_params("flat_settings", "local", "master_timeout") + async def get_index_template(self, name=None, params=None, headers=None): """ Returns an index template. - ``_ + ``_ :arg name: The comma separated names of the index templates :arg flat_settings: Return settings in flat format (default: @@ -1283,15 +1366,15 @@ class IndicesClient(NamespacedClient): :arg master_timeout: Explicit operation timeout for connection to master node """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_index_template", name), params=params, headers=headers ) @query_params("cause", "create", "master_timeout") - def put_index_template(self, name, body, params=None, headers=None): + async def put_index_template(self, name, body, params=None, headers=None): """ Creates or updates an index template. - ``_ + ``_ :arg name: The name of the template :arg body: The template definition @@ -1305,7 +1388,7 @@ class IndicesClient(NamespacedClient): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( + return await self.transport.perform_request( "PUT", _make_path("_index_template", name), params=params, @@ -1313,33 +1396,12 @@ class IndicesClient(NamespacedClient): body=body, ) - @query_params("flat_settings", "local", "master_timeout") - def exists_index_template(self, name, params=None, headers=None): - """ - Returns information about whether a particular index template exists. - ``_ - - :arg name: The name of the template - :arg flat_settings: Return settings in flat format (default: - false) - :arg local: Return local information, do not retrieve the state - from master node (default: false) - :arg master_timeout: Explicit operation timeout for connection - to master node - """ - if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'name'.") - - return self.transport.perform_request( - "HEAD", _make_path("_index_template", name), params=params, headers=headers - ) - @query_params("cause", "create", "master_timeout") - def simulate_index_template(self, name, body=None, params=None, headers=None): + async def simulate_index_template(self, name, body=None, params=None, headers=None): """ Simulate matching the given index name against the index templates in the system - ``_ + ``_ :arg name: The name of the index (it must be a concrete index name) @@ -1355,10 +1417,47 @@ class IndicesClient(NamespacedClient): if name in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'name'.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path("_index_template", "_simulate_index", name), params=params, headers=headers, body=body, ) + + @query_params() + async def get_data_stream(self, name=None, params=None, headers=None): + """ + Returns data streams. + ``_ + + :arg name: The name or wildcard expression of the requested data + streams + """ + return await self.transport.perform_request( + "GET", _make_path("_data_stream", name), params=params, headers=headers + ) + + @query_params("cause", "create", "master_timeout") + async def simulate_template(self, body=None, name=None, params=None, headers=None): + """ + Simulate resolving the given template name or body + ``_ + + :arg body: New index template definition to be simulated, if no + index template name is specified + :arg name: The name of the index template + :arg cause: User defined reason for dry-run creating the new + template for simulation purposes + :arg create: Whether the index template we optionally defined in + the body should only be dry-run added if new or can also replace an + existing one + :arg master_timeout: Specify timeout for connection to master + """ + return await self.transport.perform_request( + "POST", + _make_path("_index_template", "_simulate", name), + params=params, + headers=headers, + body=body, + ) diff --git a/elasticsearch/_async/client/ingest.py b/elasticsearch/_async/client/ingest.py index c30c41df..3113a2df 100644 --- a/elasticsearch/_async/client/ingest.py +++ b/elasticsearch/_async/client/ingest.py @@ -7,25 +7,25 @@ from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH class IngestClient(NamespacedClient): @query_params("master_timeout") - def get_pipeline(self, id=None, params=None, headers=None): + async def get_pipeline(self, id=None, params=None, headers=None): """ Returns a pipeline. - ``_ + ``_ :arg id: Comma separated list of pipeline ids. Wildcards supported :arg master_timeout: Explicit operation timeout for connection to master node """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_ingest", "pipeline", id), params=params, headers=headers ) @query_params("master_timeout", "timeout") - def put_pipeline(self, id, body, params=None, headers=None): + async def put_pipeline(self, id, body, params=None, headers=None): """ Creates or updates a pipeline. - ``_ + ``_ :arg id: Pipeline ID :arg body: The ingest definition @@ -37,7 +37,7 @@ class IngestClient(NamespacedClient): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( + return await self.transport.perform_request( "PUT", _make_path("_ingest", "pipeline", id), params=params, @@ -46,10 +46,10 @@ class IngestClient(NamespacedClient): ) @query_params("master_timeout", "timeout") - def delete_pipeline(self, id, params=None, headers=None): + async def delete_pipeline(self, id, params=None, headers=None): """ Deletes a pipeline. - ``_ + ``_ :arg id: Pipeline ID :arg master_timeout: Explicit operation timeout for connection @@ -59,7 +59,7 @@ class IngestClient(NamespacedClient): if id in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'id'.") - return self.transport.perform_request( + return await self.transport.perform_request( "DELETE", _make_path("_ingest", "pipeline", id), params=params, @@ -67,10 +67,10 @@ class IngestClient(NamespacedClient): ) @query_params("verbose") - def simulate(self, body, id=None, params=None, headers=None): + async def simulate(self, body, id=None, params=None, headers=None): """ Allows to simulate a pipeline with example documents. - ``_ + ``_ :arg body: The simulate definition :arg id: Pipeline ID @@ -80,7 +80,7 @@ class IngestClient(NamespacedClient): if body in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'body'.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path("_ingest", "pipeline", id, "_simulate"), params=params, @@ -89,11 +89,11 @@ class IngestClient(NamespacedClient): ) @query_params() - def processor_grok(self, params=None, headers=None): + async def processor_grok(self, params=None, headers=None): """ Returns a list of the built-in patterns. - ``_ + ``_ """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", "/_ingest/processor/grok", params=params, headers=headers ) diff --git a/elasticsearch/_async/client/license.py b/elasticsearch/_async/client/license.py index e455725a..a39c1f3f 100644 --- a/elasticsearch/_async/client/license.py +++ b/elasticsearch/_async/client/license.py @@ -7,82 +7,82 @@ from .utils import NamespacedClient, query_params class LicenseClient(NamespacedClient): @query_params() - def delete(self, params=None, headers=None): + async def delete(self, params=None, headers=None): """ Deletes licensing information for the cluster - ``_ + ``_ """ - return self.transport.perform_request( + return await self.transport.perform_request( "DELETE", "/_license", params=params, headers=headers ) @query_params("accept_enterprise", "local") - def get(self, params=None, headers=None): + async def get(self, params=None, headers=None): """ Retrieves licensing information for the cluster - ``_ + ``_ - :arg accept_enterprise: Supported for backwards compatibility - with 7.x. If this param is used it must be set to true + :arg accept_enterprise: If the active license is an enterprise + license, return type as 'enterprise' (default: false) :arg local: Return local information, do not retrieve the state from master node (default: false) """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", "/_license", params=params, headers=headers ) @query_params() - def get_basic_status(self, params=None, headers=None): + async def get_basic_status(self, params=None, headers=None): """ Retrieves information about the status of the basic license. - ``_ + ``_ """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", "/_license/basic_status", params=params, headers=headers ) @query_params() - def get_trial_status(self, params=None, headers=None): + async def get_trial_status(self, params=None, headers=None): """ Retrieves information about the status of the trial license. - ``_ + ``_ """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", "/_license/trial_status", params=params, headers=headers ) @query_params("acknowledge") - def post(self, body=None, params=None, headers=None): + async def post(self, body=None, params=None, headers=None): """ Updates the license for the cluster. - ``_ + ``_ :arg body: licenses to be installed :arg acknowledge: whether the user has acknowledged acknowledge messages (default: false) """ - return self.transport.perform_request( + return await self.transport.perform_request( "PUT", "/_license", params=params, headers=headers, body=body ) @query_params("acknowledge") - def post_start_basic(self, params=None, headers=None): + async def post_start_basic(self, params=None, headers=None): """ Starts an indefinite basic license. - ``_ + ``_ :arg acknowledge: whether the user has acknowledged acknowledge messages (default: false) """ - return self.transport.perform_request( + return await self.transport.perform_request( "POST", "/_license/start_basic", params=params, headers=headers ) @query_params("acknowledge", "doc_type") - def post_start_trial(self, params=None, headers=None): + async def post_start_trial(self, params=None, headers=None): """ starts a limited time trial license. - ``_ + ``_ :arg acknowledge: whether the user has acknowledged acknowledge messages (default: false) @@ -93,6 +93,6 @@ class LicenseClient(NamespacedClient): if "doc_type" in params: params["type"] = params.pop("doc_type") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", "/_license/start_trial", params=params, headers=headers ) diff --git a/elasticsearch/_async/client/migration.py b/elasticsearch/_async/client/migration.py index c58b987d..dd927c8e 100644 --- a/elasticsearch/_async/client/migration.py +++ b/elasticsearch/_async/client/migration.py @@ -7,16 +7,16 @@ from .utils import NamespacedClient, query_params, _make_path class MigrationClient(NamespacedClient): @query_params() - def deprecations(self, index=None, params=None, headers=None): + async def deprecations(self, index=None, params=None, headers=None): """ Retrieves information about different cluster, node, and index level settings that use deprecated features that will be removed or changed in the next major version. - ``_ + ``_ :arg index: Index pattern """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path(index, "_migration", "deprecations"), params=params, diff --git a/elasticsearch/_async/client/ml.py b/elasticsearch/_async/client/ml.py index ce594396..d8e27711 100644 --- a/elasticsearch/_async/client/ml.py +++ b/elasticsearch/_async/client/ml.py @@ -7,11 +7,11 @@ from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH, _bu class MlClient(NamespacedClient): @query_params("allow_no_jobs", "force", "timeout") - def close_job(self, job_id, body=None, params=None, headers=None): + async def close_job(self, job_id, body=None, params=None, headers=None): """ Closes one or more anomaly detection jobs. A job can be opened and closed multiple times throughout its lifecycle. - ``_ + ``_ :arg job_id: The name of the job to close :arg body: The URL params optionally sent in the body @@ -25,7 +25,7 @@ class MlClient(NamespacedClient): if job_id in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'job_id'.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path("_ml", "anomaly_detectors", job_id, "_close"), params=params, @@ -34,10 +34,10 @@ class MlClient(NamespacedClient): ) @query_params() - def delete_calendar(self, calendar_id, params=None, headers=None): + async def delete_calendar(self, calendar_id, params=None, headers=None): """ Deletes a calendar. - ``_ + ``_ :arg calendar_id: The ID of the calendar to delete """ @@ -46,7 +46,7 @@ class MlClient(NamespacedClient): "Empty value passed for a required argument 'calendar_id'." ) - return self.transport.perform_request( + return await self.transport.perform_request( "DELETE", _make_path("_ml", "calendars", calendar_id), params=params, @@ -54,10 +54,12 @@ class MlClient(NamespacedClient): ) @query_params() - def delete_calendar_event(self, calendar_id, event_id, params=None, headers=None): + async def delete_calendar_event( + self, calendar_id, event_id, params=None, headers=None + ): """ Deletes scheduled events from a calendar. - ``_ + ``_ :arg calendar_id: The ID of the calendar to modify :arg event_id: The ID of the event to remove from the calendar @@ -66,7 +68,7 @@ class MlClient(NamespacedClient): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( + return await self.transport.perform_request( "DELETE", _make_path("_ml", "calendars", calendar_id, "events", event_id), params=params, @@ -74,10 +76,10 @@ class MlClient(NamespacedClient): ) @query_params() - def delete_calendar_job(self, calendar_id, job_id, params=None, headers=None): + async def delete_calendar_job(self, calendar_id, job_id, params=None, headers=None): """ Deletes anomaly detection jobs from a calendar. - ``_ + ``_ :arg calendar_id: The ID of the calendar to modify :arg job_id: The ID of the job to remove from the calendar @@ -86,7 +88,7 @@ class MlClient(NamespacedClient): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( + return await self.transport.perform_request( "DELETE", _make_path("_ml", "calendars", calendar_id, "jobs", job_id), params=params, @@ -94,10 +96,10 @@ class MlClient(NamespacedClient): ) @query_params("force") - def delete_datafeed(self, datafeed_id, params=None, headers=None): + async def delete_datafeed(self, datafeed_id, params=None, headers=None): """ Deletes an existing datafeed. - ``_ + ``_ :arg datafeed_id: The ID of the datafeed to delete :arg force: True if the datafeed should be forcefully deleted @@ -107,7 +109,7 @@ class MlClient(NamespacedClient): "Empty value passed for a required argument 'datafeed_id'." ) - return self.transport.perform_request( + return await self.transport.perform_request( "DELETE", _make_path("_ml", "datafeeds", datafeed_id), params=params, @@ -115,27 +117,33 @@ class MlClient(NamespacedClient): ) @query_params() - def delete_expired_data(self, params=None, headers=None): + async def delete_expired_data(self, body=None, params=None, headers=None): """ Deletes expired and unused machine learning data. - ``_ + ``_ + + :arg body: deleting expired data parameters """ - return self.transport.perform_request( - "DELETE", "/_ml/_delete_expired_data", params=params, headers=headers + return await self.transport.perform_request( + "DELETE", + "/_ml/_delete_expired_data", + params=params, + headers=headers, + body=body, ) @query_params() - def delete_filter(self, filter_id, params=None, headers=None): + async def delete_filter(self, filter_id, params=None, headers=None): """ Deletes a filter. - ``_ + ``_ :arg filter_id: The ID of the filter to delete """ if filter_id in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'filter_id'.") - return self.transport.perform_request( + return await self.transport.perform_request( "DELETE", _make_path("_ml", "filters", filter_id), params=params, @@ -143,10 +151,12 @@ class MlClient(NamespacedClient): ) @query_params("allow_no_forecasts", "timeout") - def delete_forecast(self, job_id, forecast_id=None, params=None, headers=None): + async def delete_forecast( + self, job_id, forecast_id=None, params=None, headers=None + ): """ Deletes forecasts from a machine learning job. - ``_ + ``_ :arg job_id: The ID of the job from which to delete forecasts :arg forecast_id: The ID of the forecast to delete, can be comma @@ -159,7 +169,7 @@ class MlClient(NamespacedClient): if job_id in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'job_id'.") - return self.transport.perform_request( + return await self.transport.perform_request( "DELETE", _make_path("_ml", "anomaly_detectors", job_id, "_forecast", forecast_id), params=params, @@ -167,10 +177,10 @@ class MlClient(NamespacedClient): ) @query_params("force", "wait_for_completion") - def delete_job(self, job_id, params=None, headers=None): + async def delete_job(self, job_id, params=None, headers=None): """ Deletes an existing anomaly detection job. - ``_ + ``_ :arg job_id: The ID of the job to delete :arg force: True if the job should be forcefully deleted @@ -180,7 +190,7 @@ class MlClient(NamespacedClient): if job_id in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'job_id'.") - return self.transport.perform_request( + return await self.transport.perform_request( "DELETE", _make_path("_ml", "anomaly_detectors", job_id), params=params, @@ -188,10 +198,12 @@ class MlClient(NamespacedClient): ) @query_params() - def delete_model_snapshot(self, job_id, snapshot_id, params=None, headers=None): + async def delete_model_snapshot( + self, job_id, snapshot_id, params=None, headers=None + ): """ Deletes an existing model snapshot. - ``_ + ``_ :arg job_id: The ID of the job to fetch :arg snapshot_id: The ID of the snapshot to delete @@ -200,7 +212,7 @@ class MlClient(NamespacedClient): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( + return await self.transport.perform_request( "DELETE", _make_path( "_ml", "anomaly_detectors", job_id, "model_snapshots", snapshot_id @@ -225,11 +237,11 @@ class MlClient(NamespacedClient): "timestamp_field", "timestamp_format", ) - def find_file_structure(self, body, params=None, headers=None): + async def find_file_structure(self, body, params=None, headers=None): """ Finds the structure of a text file. The text file must contain data that is suitable to be ingested into Elasticsearch. - ``_ + ``_ :arg body: The contents of the file to be analyzed :arg charset: Optional parameter to specify the character set of @@ -268,7 +280,7 @@ class MlClient(NamespacedClient): raise ValueError("Empty value passed for a required argument 'body'.") body = _bulk_body(self.transport.serializer, body) - return self.transport.perform_request( + return await self.transport.perform_request( "POST", "/_ml/find_file_structure", params=params, @@ -277,10 +289,10 @@ class MlClient(NamespacedClient): ) @query_params("advance_time", "calc_interim", "end", "skip_time", "start") - def flush_job(self, job_id, body=None, params=None, headers=None): + async def flush_job(self, job_id, body=None, params=None, headers=None): """ Forces any buffered data to be processed by the job. - ``_ + ``_ :arg job_id: The name of the job to flush :arg body: Flush parameters @@ -298,7 +310,7 @@ class MlClient(NamespacedClient): if job_id in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'job_id'.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path("_ml", "anomaly_detectors", job_id, "_flush"), params=params, @@ -307,10 +319,10 @@ class MlClient(NamespacedClient): ) @query_params("duration", "expires_in") - def forecast(self, job_id, params=None, headers=None): + async def forecast(self, job_id, params=None, headers=None): """ Predicts the future behavior of a time series by using its historical behavior. - ``_ + ``_ :arg job_id: The ID of the job to forecast for :arg duration: The duration of the forecast @@ -320,7 +332,7 @@ class MlClient(NamespacedClient): if job_id in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'job_id'.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path("_ml", "anomaly_detectors", job_id, "_forecast"), params=params, @@ -338,10 +350,12 @@ class MlClient(NamespacedClient): "sort", "start", ) - def get_buckets(self, job_id, body=None, timestamp=None, params=None, headers=None): + async def get_buckets( + self, job_id, body=None, timestamp=None, params=None, headers=None + ): """ Retrieves anomaly detection job results for one or more buckets. - ``_ + ``_ :arg job_id: ID of the job to get bucket results from :arg body: Bucket selection details if not provided in URI @@ -352,7 +366,7 @@ class MlClient(NamespacedClient): :arg end: End time filter for buckets :arg exclude_interim: Exclude interim results :arg expand: Include anomaly records - :arg from\\_: skips a number of buckets + :arg from_: skips a number of buckets :arg size: specifies a max number of buckets to get :arg sort: Sort buckets by a particular field :arg start: Start time filter for buckets @@ -364,7 +378,7 @@ class MlClient(NamespacedClient): if job_id in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'job_id'.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path( "_ml", "anomaly_detectors", job_id, "results", "buckets", timestamp @@ -375,14 +389,14 @@ class MlClient(NamespacedClient): ) @query_params("end", "from_", "job_id", "size", "start") - def get_calendar_events(self, calendar_id, params=None, headers=None): + async def get_calendar_events(self, calendar_id, params=None, headers=None): """ Retrieves information about the scheduled events in calendars. - ``_ + ``_ :arg calendar_id: The ID of the calendar containing the events :arg end: Get events before this time - :arg from\\_: Skips a number of events + :arg from_: Skips a number of events :arg job_id: Get events for the job. When this option is used calendar_id must be '_all' :arg size: Specifies a max number of events to get @@ -397,7 +411,7 @@ class MlClient(NamespacedClient): "Empty value passed for a required argument 'calendar_id'." ) - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_ml", "calendars", calendar_id, "events"), params=params, @@ -405,22 +419,24 @@ class MlClient(NamespacedClient): ) @query_params("from_", "size") - def get_calendars(self, body=None, calendar_id=None, params=None, headers=None): + async def get_calendars( + self, body=None, calendar_id=None, params=None, headers=None + ): """ Retrieves configuration information for calendars. - ``_ + ``_ :arg body: The from and size parameters optionally sent in the body :arg calendar_id: The ID of the calendar to fetch - :arg from\\_: skips a number of calendars + :arg from_: skips a number of calendars :arg size: specifies a max number of calendars to get """ # from is a reserved word so it cannot be used, use from_ instead if "from_" in params: params["from"] = params.pop("from_") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path("_ml", "calendars", calendar_id), params=params, @@ -428,18 +444,50 @@ class MlClient(NamespacedClient): body=body, ) + @query_params("from_", "size") + async def get_categories( + self, job_id, body=None, category_id=None, params=None, headers=None + ): + """ + Retrieves anomaly detection job results for one or more categories. + ``_ + + :arg job_id: The name of the job + :arg body: Category selection details if not provided in URI + :arg category_id: The identifier of the category definition of + interest + :arg from_: skips a number of categories + :arg size: specifies a max number of categories to get + """ + # from is a reserved word so it cannot be used, use from_ instead + if "from_" in params: + params["from"] = params.pop("from_") + + if job_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for a required argument 'job_id'.") + + return await self.transport.perform_request( + "POST", + _make_path( + "_ml", "anomaly_detectors", job_id, "results", "categories", category_id + ), + params=params, + headers=headers, + body=body, + ) + @query_params("allow_no_datafeeds") - def get_datafeed_stats(self, datafeed_id=None, params=None, headers=None): + async def get_datafeed_stats(self, datafeed_id=None, params=None, headers=None): """ Retrieves usage information for datafeeds. - ``_ + ``_ :arg datafeed_id: The ID of the datafeeds stats to fetch :arg allow_no_datafeeds: Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_ml", "datafeeds", datafeed_id, "_stats"), params=params, @@ -447,17 +495,17 @@ class MlClient(NamespacedClient): ) @query_params("allow_no_datafeeds") - def get_datafeeds(self, datafeed_id=None, params=None, headers=None): + async def get_datafeeds(self, datafeed_id=None, params=None, headers=None): """ Retrieves configuration information for datafeeds. - ``_ + ``_ :arg datafeed_id: The ID of the datafeeds to fetch :arg allow_no_datafeeds: Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_ml", "datafeeds", datafeed_id), params=params, @@ -465,20 +513,20 @@ class MlClient(NamespacedClient): ) @query_params("from_", "size") - def get_filters(self, filter_id=None, params=None, headers=None): + async def get_filters(self, filter_id=None, params=None, headers=None): """ Retrieves filters. - ``_ + ``_ :arg filter_id: The ID of the filter to fetch - :arg from\\_: skips a number of filters + :arg from_: skips a number of filters :arg size: specifies a max number of filters to get """ # from is a reserved word so it cannot be used, use from_ instead if "from_" in params: params["from"] = params.pop("from_") - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_ml", "filters", filter_id), params=params, @@ -495,10 +543,10 @@ class MlClient(NamespacedClient): "sort", "start", ) - def get_influencers(self, job_id, body=None, params=None, headers=None): + async def get_influencers(self, job_id, body=None, params=None, headers=None): """ Retrieves anomaly detection job results for one or more influencers. - ``_ + ``_ :arg job_id: Identifier for the anomaly detection job :arg body: Influencer selection criteria @@ -506,7 +554,7 @@ class MlClient(NamespacedClient): order :arg end: end timestamp for the requested influencers :arg exclude_interim: Exclude interim results - :arg from\\_: skips a number of influencers + :arg from_: skips a number of influencers :arg influencer_score: influencer score threshold for the requested influencers :arg size: specifies a max number of influencers to get @@ -520,7 +568,7 @@ class MlClient(NamespacedClient): if job_id in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'job_id'.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path("_ml", "anomaly_detectors", job_id, "results", "influencers"), params=params, @@ -529,17 +577,17 @@ class MlClient(NamespacedClient): ) @query_params("allow_no_jobs") - def get_job_stats(self, job_id=None, params=None, headers=None): + async def get_job_stats(self, job_id=None, params=None, headers=None): """ Retrieves usage information for anomaly detection jobs. - ``_ + ``_ :arg job_id: The ID of the jobs stats to fetch :arg allow_no_jobs: Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_ml", "anomaly_detectors", job_id, "_stats"), params=params, @@ -547,23 +595,60 @@ class MlClient(NamespacedClient): ) @query_params("allow_no_jobs") - def get_jobs(self, job_id=None, params=None, headers=None): + async def get_jobs(self, job_id=None, params=None, headers=None): """ Retrieves configuration information for anomaly detection jobs. - ``_ + ``_ :arg job_id: The ID of the jobs to fetch :arg allow_no_jobs: Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_ml", "anomaly_detectors", job_id), params=params, headers=headers, ) + @query_params("desc", "end", "from_", "size", "sort", "start") + async def get_model_snapshots( + self, job_id, body=None, snapshot_id=None, params=None, headers=None + ): + """ + Retrieves information about model snapshots. + ``_ + + :arg job_id: The ID of the job to fetch + :arg body: Model snapshot selection criteria + :arg snapshot_id: The ID of the snapshot to fetch + :arg desc: True if the results should be sorted in descending + order + :arg end: The filter 'end' query parameter + :arg from_: Skips a number of documents + :arg size: The default number of documents returned in queries + as a string. + :arg sort: Name of the field to sort on + :arg start: The filter 'start' query parameter + """ + # from is a reserved word so it cannot be used, use from_ instead + if "from_" in params: + params["from"] = params.pop("from_") + + if job_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for a required argument 'job_id'.") + + return await self.transport.perform_request( + "POST", + _make_path( + "_ml", "anomaly_detectors", job_id, "model_snapshots", snapshot_id + ), + params=params, + headers=headers, + body=body, + ) + @query_params( "allow_no_jobs", "bucket_span", @@ -573,11 +658,11 @@ class MlClient(NamespacedClient): "start", "top_n", ) - def get_overall_buckets(self, job_id, body=None, params=None, headers=None): + async def get_overall_buckets(self, job_id, body=None, params=None, headers=None): """ Retrieves overall bucket results that summarize the bucket results of multiple anomaly detection jobs. - ``_ + ``_ :arg job_id: The job IDs for which to calculate overall bucket results @@ -602,7 +687,7 @@ class MlClient(NamespacedClient): if job_id in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'job_id'.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path( "_ml", "anomaly_detectors", job_id, "results", "overall_buckets" @@ -622,17 +707,17 @@ class MlClient(NamespacedClient): "sort", "start", ) - def get_records(self, job_id, body=None, params=None, headers=None): + async def get_records(self, job_id, body=None, params=None, headers=None): """ Retrieves anomaly records for an anomaly detection job. - ``_ + ``_ :arg job_id: The ID of the job :arg body: Record selection criteria :arg desc: Set the sort direction :arg end: End time filter for records :arg exclude_interim: Exclude interim results - :arg from\\_: skips a number of records + :arg from_: skips a number of records :arg record_score: Returns records with anomaly scores greater or equal than this value :arg size: specifies a max number of records to get @@ -646,7 +731,7 @@ class MlClient(NamespacedClient): if job_id in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'job_id'.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path("_ml", "anomaly_detectors", job_id, "results", "records"), params=params, @@ -655,27 +740,27 @@ class MlClient(NamespacedClient): ) @query_params() - def info(self, params=None, headers=None): + async def info(self, params=None, headers=None): """ Returns defaults and limits used by machine learning. - ``_ + ``_ """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", "/_ml/info", params=params, headers=headers ) @query_params() - def open_job(self, job_id, params=None, headers=None): + async def open_job(self, job_id, params=None, headers=None): """ Opens one or more anomaly detection jobs. - ``_ + ``_ :arg job_id: The ID of the job to open """ if job_id in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'job_id'.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path("_ml", "anomaly_detectors", job_id, "_open"), params=params, @@ -683,10 +768,10 @@ class MlClient(NamespacedClient): ) @query_params() - def post_calendar_events(self, calendar_id, body, params=None, headers=None): + async def post_calendar_events(self, calendar_id, body, params=None, headers=None): """ Posts scheduled events in a calendar. - ``_ + ``_ :arg calendar_id: The ID of the calendar to modify :arg body: A list of events @@ -695,7 +780,7 @@ class MlClient(NamespacedClient): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path("_ml", "calendars", calendar_id, "events"), params=params, @@ -704,10 +789,10 @@ class MlClient(NamespacedClient): ) @query_params("reset_end", "reset_start") - def post_data(self, job_id, body, params=None, headers=None): + async def post_data(self, job_id, body, params=None, headers=None): """ Sends data to an anomaly detection job for analysis. - ``_ + ``_ :arg job_id: The name of the job receiving the data :arg body: The data to process @@ -721,7 +806,7 @@ class MlClient(NamespacedClient): raise ValueError("Empty value passed for a required argument.") body = _bulk_body(self.transport.serializer, body) - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path("_ml", "anomaly_detectors", job_id, "_data"), params=params, @@ -730,10 +815,10 @@ class MlClient(NamespacedClient): ) @query_params() - def preview_datafeed(self, datafeed_id, params=None, headers=None): + async def preview_datafeed(self, datafeed_id, params=None, headers=None): """ Previews a datafeed. - ``_ + ``_ :arg datafeed_id: The ID of the datafeed to preview """ @@ -742,7 +827,7 @@ class MlClient(NamespacedClient): "Empty value passed for a required argument 'datafeed_id'." ) - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_ml", "datafeeds", datafeed_id, "_preview"), params=params, @@ -750,10 +835,10 @@ class MlClient(NamespacedClient): ) @query_params() - def put_calendar(self, calendar_id, body=None, params=None, headers=None): + async def put_calendar(self, calendar_id, body=None, params=None, headers=None): """ Instantiates a calendar. - ``_ + ``_ :arg calendar_id: The ID of the calendar to create :arg body: The calendar details @@ -763,7 +848,7 @@ class MlClient(NamespacedClient): "Empty value passed for a required argument 'calendar_id'." ) - return self.transport.perform_request( + return await self.transport.perform_request( "PUT", _make_path("_ml", "calendars", calendar_id), params=params, @@ -772,10 +857,10 @@ class MlClient(NamespacedClient): ) @query_params() - def put_calendar_job(self, calendar_id, job_id, params=None, headers=None): + async def put_calendar_job(self, calendar_id, job_id, params=None, headers=None): """ Adds an anomaly detection job to a calendar. - ``_ + ``_ :arg calendar_id: The ID of the calendar to modify :arg job_id: The ID of the job to add to the calendar @@ -784,7 +869,7 @@ class MlClient(NamespacedClient): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( + return await self.transport.perform_request( "PUT", _make_path("_ml", "calendars", calendar_id, "jobs", job_id), params=params, @@ -794,10 +879,10 @@ class MlClient(NamespacedClient): @query_params( "allow_no_indices", "expand_wildcards", "ignore_throttled", "ignore_unavailable" ) - def put_datafeed(self, datafeed_id, body, params=None, headers=None): + async def put_datafeed(self, datafeed_id, body, params=None, headers=None): """ Instantiates a datafeed. - ``_ + ``_ :arg datafeed_id: The ID of the datafeed to create :arg body: The datafeed config @@ -815,7 +900,7 @@ class MlClient(NamespacedClient): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( + return await self.transport.perform_request( "PUT", _make_path("_ml", "datafeeds", datafeed_id), params=params, @@ -824,10 +909,10 @@ class MlClient(NamespacedClient): ) @query_params() - def put_filter(self, filter_id, body, params=None, headers=None): + async def put_filter(self, filter_id, body, params=None, headers=None): """ Instantiates a filter. - ``_ + ``_ :arg filter_id: The ID of the filter to create :arg body: The filter details @@ -836,7 +921,7 @@ class MlClient(NamespacedClient): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( + return await self.transport.perform_request( "PUT", _make_path("_ml", "filters", filter_id), params=params, @@ -845,10 +930,10 @@ class MlClient(NamespacedClient): ) @query_params() - def put_job(self, job_id, body, params=None, headers=None): + async def put_job(self, job_id, body, params=None, headers=None): """ Instantiates an anomaly detection job. - ``_ + ``_ :arg job_id: The ID of the job to create :arg body: The job @@ -857,7 +942,7 @@ class MlClient(NamespacedClient): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( + return await self.transport.perform_request( "PUT", _make_path("_ml", "anomaly_detectors", job_id), params=params, @@ -865,27 +950,60 @@ class MlClient(NamespacedClient): body=body, ) + @query_params("delete_intervening_results") + async def revert_model_snapshot( + self, job_id, snapshot_id, body=None, params=None, headers=None + ): + """ + Reverts to a specific snapshot. + ``_ + + :arg job_id: The ID of the job to fetch + :arg snapshot_id: The ID of the snapshot to revert to + :arg body: Reversion options + :arg delete_intervening_results: Should we reset the results + back to the time of the snapshot? + """ + for param in (job_id, snapshot_id): + 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", + "anomaly_detectors", + job_id, + "model_snapshots", + snapshot_id, + "_revert", + ), + params=params, + headers=headers, + body=body, + ) + @query_params("enabled", "timeout") - def set_upgrade_mode(self, params=None, headers=None): + async def set_upgrade_mode(self, params=None, headers=None): """ Sets a cluster wide upgrade_mode setting that prepares machine learning indices for an upgrade. - ``_ + ``_ :arg enabled: Whether to enable upgrade_mode ML setting or not. Defaults to false. :arg timeout: Controls the time to wait before action times out. Defaults to 30 seconds """ - return self.transport.perform_request( + return await self.transport.perform_request( "POST", "/_ml/set_upgrade_mode", params=params, headers=headers ) @query_params("end", "start", "timeout") - def start_datafeed(self, datafeed_id, body=None, params=None, headers=None): + async def start_datafeed(self, datafeed_id, body=None, params=None, headers=None): """ Starts one or more datafeeds. - ``_ + ``_ :arg datafeed_id: The ID of the datafeed to start :arg body: The start datafeed parameters @@ -900,7 +1018,7 @@ class MlClient(NamespacedClient): "Empty value passed for a required argument 'datafeed_id'." ) - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path("_ml", "datafeeds", datafeed_id, "_start"), params=params, @@ -909,10 +1027,10 @@ class MlClient(NamespacedClient): ) @query_params("allow_no_datafeeds", "force", "timeout") - def stop_datafeed(self, datafeed_id, params=None, headers=None): + async def stop_datafeed(self, datafeed_id, params=None, headers=None): """ Stops one or more datafeeds. - ``_ + ``_ :arg datafeed_id: The ID of the datafeed to stop :arg allow_no_datafeeds: Whether to ignore if a wildcard @@ -927,7 +1045,7 @@ class MlClient(NamespacedClient): "Empty value passed for a required argument 'datafeed_id'." ) - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path("_ml", "datafeeds", datafeed_id, "_stop"), params=params, @@ -937,10 +1055,10 @@ class MlClient(NamespacedClient): @query_params( "allow_no_indices", "expand_wildcards", "ignore_throttled", "ignore_unavailable" ) - def update_datafeed(self, datafeed_id, body, params=None, headers=None): + async def update_datafeed(self, datafeed_id, body, params=None, headers=None): """ Updates certain properties of a datafeed. - ``_ + ``_ :arg datafeed_id: The ID of the datafeed to update :arg body: The datafeed update settings @@ -958,7 +1076,7 @@ class MlClient(NamespacedClient): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path("_ml", "datafeeds", datafeed_id, "_update"), params=params, @@ -967,10 +1085,10 @@ class MlClient(NamespacedClient): ) @query_params() - def update_filter(self, filter_id, body, params=None, headers=None): + async def update_filter(self, filter_id, body, params=None, headers=None): """ Updates the description of a filter, adds items, or removes items. - ``_ + ``_ :arg filter_id: The ID of the filter to update :arg body: The filter update @@ -979,7 +1097,7 @@ class MlClient(NamespacedClient): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path("_ml", "filters", filter_id, "_update"), params=params, @@ -988,10 +1106,10 @@ class MlClient(NamespacedClient): ) @query_params() - def update_job(self, job_id, body, params=None, headers=None): + async def update_job(self, job_id, body, params=None, headers=None): """ Updates certain properties of an anomaly detection job. - ``_ + ``_ :arg job_id: The ID of the job to create :arg body: The job update settings @@ -1000,7 +1118,7 @@ class MlClient(NamespacedClient): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path("_ml", "anomaly_detectors", job_id, "_update"), params=params, @@ -1009,16 +1127,48 @@ class MlClient(NamespacedClient): ) @query_params() - def validate(self, body, params=None, headers=None): + async def update_model_snapshot( + self, job_id, snapshot_id, body, params=None, headers=None + ): + """ + Updates certain properties of a snapshot. + ``_ + + :arg job_id: The ID of the job to fetch + :arg snapshot_id: The ID of the snapshot to update + :arg body: The model snapshot properties to update + """ + for param in (job_id, snapshot_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", + "anomaly_detectors", + job_id, + "model_snapshots", + snapshot_id, + "_update", + ), + params=params, + headers=headers, + body=body, + ) + + @query_params() + async def validate(self, body, params=None, headers=None): """ Validates an anomaly detection job. + ``_ :arg body: The job config """ if body in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'body'.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", "/_ml/anomaly_detectors/_validate", params=params, @@ -1027,16 +1177,17 @@ class MlClient(NamespacedClient): ) @query_params() - def validate_detector(self, body, params=None, headers=None): + async def validate_detector(self, body, params=None, headers=None): """ Validates an anomaly detection detector. + ``_ :arg body: The detector """ if body in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'body'.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", "/_ml/anomaly_detectors/_validate/detector", params=params, @@ -1045,10 +1196,10 @@ class MlClient(NamespacedClient): ) @query_params("force") - def delete_data_frame_analytics(self, id, params=None, headers=None): + async def delete_data_frame_analytics(self, id, params=None, headers=None): """ Deletes an existing data frame analytics job. - ``_ + ``_ :arg id: The ID of the data frame analytics to delete :arg force: True if the job should be forcefully deleted @@ -1056,7 +1207,7 @@ class MlClient(NamespacedClient): if id in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'id'.") - return self.transport.perform_request( + return await self.transport.perform_request( "DELETE", _make_path("_ml", "data_frame", "analytics", id), params=params, @@ -1064,17 +1215,17 @@ class MlClient(NamespacedClient): ) @query_params() - def evaluate_data_frame(self, body, params=None, headers=None): + async def evaluate_data_frame(self, body, params=None, headers=None): """ Evaluates the data frame analytics for an annotated index. - ``_ + ``_ :arg body: The evaluation definition """ if body in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'body'.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", "/_ml/data_frame/_evaluate", params=params, @@ -1083,16 +1234,16 @@ class MlClient(NamespacedClient): ) @query_params("allow_no_match", "from_", "size") - def get_data_frame_analytics(self, id=None, params=None, headers=None): + async def get_data_frame_analytics(self, id=None, params=None, headers=None): """ Retrieves configuration information for data frame analytics jobs. - ``_ + ``_ :arg id: The ID of the data frame analytics to fetch :arg allow_no_match: Whether to ignore if a wildcard expression matches no data frame analytics. (This includes `_all` string or when no data frame analytics have been specified) Default: True - :arg from\\_: skips a number of analytics + :arg from_: skips a number of analytics :arg size: specifies a max number of analytics to get Default: 100 """ @@ -1100,7 +1251,7 @@ class MlClient(NamespacedClient): if "from_" in params: params["from"] = params.pop("from_") - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_ml", "data_frame", "analytics", id), params=params, @@ -1108,16 +1259,16 @@ class MlClient(NamespacedClient): ) @query_params("allow_no_match", "from_", "size") - def get_data_frame_analytics_stats(self, id=None, params=None, headers=None): + async def get_data_frame_analytics_stats(self, id=None, params=None, headers=None): """ Retrieves usage information for data frame analytics jobs. - ``_ + ``_ :arg id: The ID of the data frame analytics stats to fetch :arg allow_no_match: Whether to ignore if a wildcard expression matches no data frame analytics. (This includes `_all` string or when no data frame analytics have been specified) Default: True - :arg from\\_: skips a number of analytics + :arg from_: skips a number of analytics :arg size: specifies a max number of analytics to get Default: 100 """ @@ -1125,7 +1276,7 @@ class MlClient(NamespacedClient): if "from_" in params: params["from"] = params.pop("from_") - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_ml", "data_frame", "analytics", id, "_stats"), params=params, @@ -1133,10 +1284,10 @@ class MlClient(NamespacedClient): ) @query_params() - def put_data_frame_analytics(self, id, body, params=None, headers=None): + async def put_data_frame_analytics(self, id, body, params=None, headers=None): """ Instantiates a data frame analytics job. - ``_ + ``_ :arg id: The ID of the data frame analytics to create :arg body: The data frame analytics configuration @@ -1145,7 +1296,7 @@ class MlClient(NamespacedClient): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( + return await self.transport.perform_request( "PUT", _make_path("_ml", "data_frame", "analytics", id), params=params, @@ -1154,10 +1305,12 @@ class MlClient(NamespacedClient): ) @query_params("timeout") - def start_data_frame_analytics(self, id, body=None, params=None, headers=None): + async def start_data_frame_analytics( + self, id, body=None, params=None, headers=None + ): """ Starts a data frame analytics job. - ``_ + ``_ :arg id: The ID of the data frame analytics to start :arg body: The start data frame analytics parameters @@ -1167,7 +1320,7 @@ class MlClient(NamespacedClient): if id in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'id'.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path("_ml", "data_frame", "analytics", id, "_start"), params=params, @@ -1176,10 +1329,10 @@ class MlClient(NamespacedClient): ) @query_params("allow_no_match", "force", "timeout") - def stop_data_frame_analytics(self, id, body=None, params=None, headers=None): + async def stop_data_frame_analytics(self, id, body=None, params=None, headers=None): """ Stops one or more data frame analytics jobs. - ``_ + ``_ :arg id: The ID of the data frame analytics to stop :arg body: The stop data frame analytics parameters @@ -1194,7 +1347,7 @@ class MlClient(NamespacedClient): if id in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'id'.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path("_ml", "data_frame", "analytics", id, "_stop"), params=params, @@ -1203,24 +1356,43 @@ class MlClient(NamespacedClient): ) @query_params() - def delete_trained_model(self, model_id, params=None, headers=None): + async def delete_trained_model(self, model_id, params=None, headers=None): """ Deletes an existing trained inference model that is currently not referenced by an ingest pipeline. - ``_ + ``_ :arg model_id: The ID of the trained model to delete """ if model_id in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'model_id'.") - return self.transport.perform_request( + return await self.transport.perform_request( "DELETE", _make_path("_ml", "inference", model_id), params=params, headers=headers, ) + @query_params() + async def explain_data_frame_analytics( + self, body=None, id=None, params=None, headers=None + ): + """ + Explains a data frame analytics config. + ``_ + + :arg body: The data frame analytics config to explain + :arg id: The ID of the data frame analytics to explain + """ + return await self.transport.perform_request( + "POST", + _make_path("_ml", "data_frame", "analytics", id, "_explain"), + params=params, + headers=headers, + body=body, + ) + @query_params( "allow_no_match", "decompress_definition", @@ -1229,10 +1401,10 @@ class MlClient(NamespacedClient): "size", "tags", ) - def get_trained_models(self, model_id=None, params=None, headers=None): + async def get_trained_models(self, model_id=None, params=None, headers=None): """ Retrieves configuration information for a trained inference model. - ``_ + ``_ :arg model_id: The ID of the trained models to fetch :arg allow_no_match: Whether to ignore if a wildcard expression @@ -1241,7 +1413,7 @@ class MlClient(NamespacedClient): :arg decompress_definition: Should the model definition be decompressed into valid JSON or returned in a custom compressed format. Defaults to true. Default: True - :arg from\\_: skips a number of trained models + :arg from_: skips a number of trained models :arg include_model_definition: Should the full model definition be included in the results. These definitions can be large. So be cautious when including them. Defaults to false. @@ -1254,7 +1426,7 @@ class MlClient(NamespacedClient): if "from_" in params: params["from"] = params.pop("from_") - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_ml", "inference", model_id), params=params, @@ -1262,16 +1434,16 @@ class MlClient(NamespacedClient): ) @query_params("allow_no_match", "from_", "size") - def get_trained_models_stats(self, model_id=None, params=None, headers=None): + async def get_trained_models_stats(self, model_id=None, params=None, headers=None): """ Retrieves usage information for trained inference models. - ``_ + ``_ :arg model_id: The ID of the trained models stats to fetch :arg allow_no_match: Whether to ignore if a wildcard expression matches no trained models. (This includes `_all` string or when no trained models have been specified) Default: True - :arg from\\_: skips a number of trained models + :arg from_: skips a number of trained models :arg size: specifies a max number of trained models to get Default: 100 """ @@ -1279,7 +1451,7 @@ class MlClient(NamespacedClient): if "from_" in params: params["from"] = params.pop("from_") - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_ml", "inference", model_id, "_stats"), params=params, @@ -1287,10 +1459,10 @@ class MlClient(NamespacedClient): ) @query_params() - def put_trained_model(self, model_id, body, params=None, headers=None): + async def put_trained_model(self, model_id, body, params=None, headers=None): """ Creates an inference trained model. - ``_ + ``_ :arg model_id: The ID of the trained models to store :arg body: The trained model configuration @@ -1299,7 +1471,7 @@ class MlClient(NamespacedClient): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( + return await self.transport.perform_request( "PUT", _make_path("_ml", "inference", model_id), params=params, @@ -1308,10 +1480,10 @@ class MlClient(NamespacedClient): ) @query_params() - def estimate_model_memory(self, body, params=None, headers=None): + async def estimate_model_memory(self, body, params=None, headers=None): """ Estimates the model memory - ``_ + ``_ :arg body: The analysis config, plus cardinality estimates for fields it references @@ -1319,162 +1491,10 @@ class MlClient(NamespacedClient): if body in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'body'.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", "/_ml/anomaly_detectors/_estimate_model_memory", params=params, headers=headers, body=body, ) - - @query_params() - def explain_data_frame_analytics( - self, body=None, id=None, params=None, headers=None - ): - """ - Explains a data frame analytics config. - ``_ - - :arg body: The data frame analytics config to explain - :arg id: The ID of the data frame analytics to explain - """ - return self.transport.perform_request( - "POST", - _make_path("_ml", "data_frame", "analytics", id, "_explain"), - params=params, - headers=headers, - body=body, - ) - - @query_params("from_", "size") - def get_categories( - self, job_id, body=None, category_id=None, params=None, headers=None - ): - """ - Retrieves anomaly detection job results for one or more categories. - ``_ - - :arg job_id: The name of the job - :arg body: Category selection details if not provided in URI - :arg category_id: The identifier of the category definition of - interest - :arg from\\_: skips a number of categories - :arg size: specifies a max number of categories to get - """ - # from is a reserved word so it cannot be used, use from_ instead - if "from_" in params: - params["from"] = params.pop("from_") - - if job_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'job_id'.") - - return self.transport.perform_request( - "POST", - _make_path( - "_ml", "anomaly_detectors", job_id, "results", "categories", category_id - ), - params=params, - headers=headers, - body=body, - ) - - @query_params("desc", "end", "from_", "size", "sort", "start") - def get_model_snapshots( - self, job_id, body=None, snapshot_id=None, params=None, headers=None - ): - """ - Retrieves information about model snapshots. - ``_ - - :arg job_id: The ID of the job to fetch - :arg body: Model snapshot selection criteria - :arg snapshot_id: The ID of the snapshot to fetch - :arg desc: True if the results should be sorted in descending - order - :arg end: The filter 'end' query parameter - :arg from\\_: Skips a number of documents - :arg size: The default number of documents returned in queries - as a string. - :arg sort: Name of the field to sort on - :arg start: The filter 'start' query parameter - """ - # from is a reserved word so it cannot be used, use from_ instead - if "from_" in params: - params["from"] = params.pop("from_") - - if job_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'job_id'.") - - return self.transport.perform_request( - "POST", - _make_path( - "_ml", "anomaly_detectors", job_id, "model_snapshots", snapshot_id - ), - params=params, - headers=headers, - body=body, - ) - - @query_params("delete_intervening_results") - def revert_model_snapshot( - self, job_id, snapshot_id, body=None, params=None, headers=None - ): - """ - Reverts to a specific snapshot. - ``_ - - :arg job_id: The ID of the job to fetch - :arg snapshot_id: The ID of the snapshot to revert to - :arg body: Reversion options - :arg delete_intervening_results: Should we reset the results - back to the time of the snapshot? - """ - for param in (job_id, snapshot_id): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return self.transport.perform_request( - "POST", - _make_path( - "_ml", - "anomaly_detectors", - job_id, - "model_snapshots", - snapshot_id, - "_revert", - ), - params=params, - headers=headers, - body=body, - ) - - @query_params() - def update_model_snapshot( - self, job_id, snapshot_id, body, params=None, headers=None - ): - """ - Updates certain properties of a snapshot. - ``_ - - :arg job_id: The ID of the job to fetch - :arg snapshot_id: The ID of the snapshot to update - :arg body: The model snapshot properties to update - """ - for param in (job_id, snapshot_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", - "anomaly_detectors", - job_id, - "model_snapshots", - snapshot_id, - "_update", - ), - params=params, - headers=headers, - body=body, - ) diff --git a/elasticsearch/_async/client/monitoring.py b/elasticsearch/_async/client/monitoring.py index cf5677cd..f51fd3b5 100644 --- a/elasticsearch/_async/client/monitoring.py +++ b/elasticsearch/_async/client/monitoring.py @@ -7,10 +7,10 @@ from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH, _bu class MonitoringClient(NamespacedClient): @query_params("interval", "system_api_version", "system_id") - def bulk(self, body, doc_type=None, params=None, headers=None): + async def bulk(self, body, doc_type=None, params=None, headers=None): """ Used by the monitoring features to send monitoring data. - ``_ + ``_ :arg body: The operation definition and data (action-data pairs), separated by newlines @@ -25,7 +25,7 @@ class MonitoringClient(NamespacedClient): raise ValueError("Empty value passed for a required argument 'body'.") body = _bulk_body(self.transport.serializer, body) - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path("_monitoring", doc_type, "bulk"), params=params, diff --git a/elasticsearch/_async/client/nodes.py b/elasticsearch/_async/client/nodes.py index c3aaec3a..26367cce 100644 --- a/elasticsearch/_async/client/nodes.py +++ b/elasticsearch/_async/client/nodes.py @@ -7,12 +7,12 @@ from .utils import NamespacedClient, query_params, _make_path class NodesClient(NamespacedClient): @query_params("timeout") - def reload_secure_settings( + async def reload_secure_settings( self, body=None, node_id=None, params=None, headers=None ): """ Reloads secure settings. - ``_ + ``_ :arg body: An object containing the password for the elasticsearch keystore @@ -21,7 +21,7 @@ class NodesClient(NamespacedClient): all cluster nodes. :arg timeout: Explicit operation timeout """ - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path("_nodes", node_id, "reload_secure_settings"), params=params, @@ -30,10 +30,10 @@ class NodesClient(NamespacedClient): ) @query_params("flat_settings", "timeout") - def info(self, node_id=None, metric=None, params=None, headers=None): + async def info(self, node_id=None, metric=None, params=None, headers=None): """ Returns information about nodes in the cluster. - ``_ + ``_ :arg node_id: A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from @@ -46,17 +46,70 @@ class NodesClient(NamespacedClient): false) :arg timeout: Explicit operation timeout """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_nodes", node_id, metric), params=params, headers=headers ) + @query_params( + "completion_fields", + "fielddata_fields", + "fields", + "groups", + "include_segment_file_sizes", + "level", + "timeout", + "types", + ) + async def stats( + self, node_id=None, metric=None, index_metric=None, params=None, headers=None + ): + """ + Returns statistical information about nodes in the cluster. + ``_ + + :arg node_id: A comma-separated list of node IDs or names to + limit the returned information; use `_local` to return information from + the node you're connecting to, leave empty to get information from all + nodes + :arg metric: Limit the information returned to the specified + metrics Valid choices: _all, breaker, fs, http, indices, jvm, os, + process, thread_pool, transport, discovery + :arg index_metric: Limit the information returned for `indices` + metric to the specific index metrics. Isn't used if `indices` (or `all`) + metric isn't specified. Valid choices: _all, completion, docs, + fielddata, query_cache, flush, get, indexing, merge, request_cache, + refresh, search, segments, store, warmer, suggest + :arg completion_fields: A comma-separated list of fields for + `fielddata` and `suggest` index metric (supports wildcards) + :arg fielddata_fields: A comma-separated list of fields for + `fielddata` index metric (supports wildcards) + :arg fields: A comma-separated list of fields for `fielddata` + and `completion` index metric (supports wildcards) + :arg groups: A comma-separated list of search groups for + `search` index metric + :arg include_segment_file_sizes: Whether to report the + aggregated disk usage of each one of the Lucene index files (only + applies if segment stats are requested) + :arg level: Return indices stats aggregated at index, node or + shard level Valid choices: indices, node, shards Default: node + :arg timeout: Explicit operation timeout + :arg types: A comma-separated list of document types for the + `indexing` index metric + """ + return await self.transport.perform_request( + "GET", + _make_path("_nodes", node_id, "stats", metric, index_metric), + params=params, + headers=headers, + ) + @query_params( "doc_type", "ignore_idle_threads", "interval", "snapshots", "threads", "timeout" ) - def hot_threads(self, node_id=None, params=None, headers=None): + async def hot_threads(self, node_id=None, params=None, headers=None): """ Returns information about hot threads on each node in the cluster. - ``_ + ``_ :arg node_id: A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from @@ -78,7 +131,7 @@ class NodesClient(NamespacedClient): if "doc_type" in params: params["type"] = params.pop("doc_type") - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_nodes", node_id, "hot_threads"), params=params, @@ -86,10 +139,10 @@ class NodesClient(NamespacedClient): ) @query_params("timeout") - def usage(self, node_id=None, metric=None, params=None, headers=None): + async def usage(self, node_id=None, metric=None, params=None, headers=None): """ Returns low-level information about REST actions usage on nodes. - ``_ + ``_ :arg node_id: A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from @@ -99,62 +152,9 @@ class NodesClient(NamespacedClient): metrics Valid choices: _all, rest_actions :arg timeout: Explicit operation timeout """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_nodes", node_id, "usage", metric), params=params, headers=headers, ) - - @query_params( - "completion_fields", - "fielddata_fields", - "fields", - "groups", - "include_segment_file_sizes", - "level", - "timeout", - "types", - ) - def stats( - self, node_id=None, metric=None, index_metric=None, params=None, headers=None - ): - """ - Returns statistical information about nodes in the cluster. - ``_ - - :arg node_id: A comma-separated list of node IDs or names to - limit the returned information; use `_local` to return information from - the node you're connecting to, leave empty to get information from all - nodes - :arg metric: Limit the information returned to the specified - metrics Valid choices: _all, breaker, fs, http, indices, jvm, os, - process, thread_pool, transport, discovery - :arg index_metric: Limit the information returned for `indices` - metric to the specific index metrics. Isn't used if `indices` (or `all`) - metric isn't specified. Valid choices: _all, completion, docs, - fielddata, query_cache, flush, get, indexing, merge, request_cache, - refresh, search, segments, store, warmer, suggest, bulk - :arg completion_fields: A comma-separated list of fields for - `fielddata` and `suggest` index metric (supports wildcards) - :arg fielddata_fields: A comma-separated list of fields for - `fielddata` index metric (supports wildcards) - :arg fields: A comma-separated list of fields for `fielddata` - and `completion` index metric (supports wildcards) - :arg groups: A comma-separated list of search groups for - `search` index metric - :arg include_segment_file_sizes: Whether to report the - aggregated disk usage of each one of the Lucene index files (only - applies if segment stats are requested) - :arg level: Return indices stats aggregated at index, node or - shard level Valid choices: indices, node, shards Default: node - :arg timeout: Explicit operation timeout - :arg types: A comma-separated list of document types for the - `indexing` index metric - """ - return self.transport.perform_request( - "GET", - _make_path("_nodes", node_id, "stats", metric, index_metric), - params=params, - headers=headers, - ) diff --git a/elasticsearch/_async/client/remote.py b/elasticsearch/_async/client/remote.py index 2c2767b1..92c484d9 100644 --- a/elasticsearch/_async/client/remote.py +++ b/elasticsearch/_async/client/remote.py @@ -7,10 +7,10 @@ from .utils import NamespacedClient, query_params class RemoteClient(NamespacedClient): @query_params() - def info(self, params=None, headers=None): + async def info(self, params=None, headers=None): """ - ``_ + ``_ """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", "/_remote/info", params=params, headers=headers ) diff --git a/elasticsearch/_async/client/rollup.py b/elasticsearch/_async/client/rollup.py index 0ee11270..013cf72a 100644 --- a/elasticsearch/_async/client/rollup.py +++ b/elasticsearch/_async/client/rollup.py @@ -7,53 +7,53 @@ from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH class RollupClient(NamespacedClient): @query_params() - def delete_job(self, id, params=None, headers=None): + async def delete_job(self, id, params=None, headers=None): """ Deletes an existing rollup job. - ``_ + ``_ :arg id: The ID of the job to delete """ if id in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'id'.") - return self.transport.perform_request( + return await self.transport.perform_request( "DELETE", _make_path("_rollup", "job", id), params=params, headers=headers ) @query_params() - def get_jobs(self, id=None, params=None, headers=None): + async def get_jobs(self, id=None, params=None, headers=None): """ Retrieves the configuration, stats, and status of rollup jobs. - ``_ + ``_ :arg id: The ID of the job(s) to fetch. Accepts glob patterns, or left blank for all jobs """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_rollup", "job", id), params=params, headers=headers ) @query_params() - def get_rollup_caps(self, id=None, params=None, headers=None): + async def get_rollup_caps(self, id=None, params=None, headers=None): """ Returns the capabilities of any rollup jobs that have been configured for a specific index or index pattern. - ``_ + ``_ :arg id: The ID of the index to check rollup capabilities on, or left blank for all jobs """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_rollup", "data", id), params=params, headers=headers ) @query_params() - def get_rollup_index_caps(self, index, params=None, headers=None): + async def get_rollup_index_caps(self, index, params=None, headers=None): """ Returns the rollup capabilities of all jobs inside of a rollup index (e.g. the index where rollup data is stored). - ``_ + ``_ :arg index: The rollup index or index pattern to obtain rollup capabilities from. @@ -61,15 +61,15 @@ class RollupClient(NamespacedClient): if index in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'index'.") - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path(index, "_rollup", "data"), params=params, headers=headers ) @query_params() - def put_job(self, id, body, params=None, headers=None): + async def put_job(self, id, body, params=None, headers=None): """ Creates a rollup job. - ``_ + ``_ :arg id: The ID of the job to create :arg body: The job configuration @@ -78,7 +78,7 @@ class RollupClient(NamespacedClient): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( + return await self.transport.perform_request( "PUT", _make_path("_rollup", "job", id), params=params, @@ -87,10 +87,12 @@ class RollupClient(NamespacedClient): ) @query_params("rest_total_hits_as_int", "typed_keys") - def rollup_search(self, index, body, doc_type=None, params=None, headers=None): + async def rollup_search( + self, index, body, doc_type=None, params=None, headers=None + ): """ Enables searching rolled-up data using the standard query DSL. - ``_ + ``_ :arg index: The indices or index-pattern(s) (containing rollup or regular data) that should be searched @@ -105,7 +107,7 @@ class RollupClient(NamespacedClient): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path(index, doc_type, "_rollup_search"), params=params, @@ -114,17 +116,17 @@ class RollupClient(NamespacedClient): ) @query_params() - def start_job(self, id, params=None, headers=None): + async def start_job(self, id, params=None, headers=None): """ Starts an existing, stopped rollup job. - ``_ + ``_ :arg id: The ID of the job to start """ if id in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'id'.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path("_rollup", "job", id, "_start"), params=params, @@ -132,10 +134,10 @@ class RollupClient(NamespacedClient): ) @query_params("timeout", "wait_for_completion") - def stop_job(self, id, params=None, headers=None): + async def stop_job(self, id, params=None, headers=None): """ Stops an existing, started rollup job. - ``_ + ``_ :arg id: The ID of the job to stop :arg timeout: Block for (at maximum) the specified duration @@ -147,7 +149,7 @@ class RollupClient(NamespacedClient): if id in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'id'.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path("_rollup", "job", id, "_stop"), params=params, diff --git a/elasticsearch/_async/client/searchable_snapshots.py b/elasticsearch/_async/client/searchable_snapshots.py index 1616493d..7205ed59 100644 --- a/elasticsearch/_async/client/searchable_snapshots.py +++ b/elasticsearch/_async/client/searchable_snapshots.py @@ -7,10 +7,10 @@ from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH class SearchableSnapshotsClient(NamespacedClient): @query_params("allow_no_indices", "expand_wildcards", "ignore_unavailable") - def clear_cache(self, index=None, params=None, headers=None): + async def clear_cache(self, index=None, params=None, headers=None): """ Clear the cache of searchable snapshots. - ``_ + ``_ :arg index: A comma-separated list of index name to limit the operation @@ -23,7 +23,7 @@ class SearchableSnapshotsClient(NamespacedClient): :arg ignore_unavailable: Whether specified concrete indices should be ignored when unavailable (missing or closed) """ - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path(index, "_searchable_snapshots", "cache", "clear"), params=params, @@ -31,10 +31,10 @@ class SearchableSnapshotsClient(NamespacedClient): ) @query_params("master_timeout", "wait_for_completion") - def mount(self, repository, snapshot, body, params=None, headers=None): + async def mount(self, repository, snapshot, body, params=None, headers=None): """ Mount a snapshot as a searchable index. - ``_ + ``_ :arg repository: The name of the repository containing the snapshot of the index to mount @@ -50,7 +50,7 @@ class SearchableSnapshotsClient(NamespacedClient): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path("_snapshot", repository, snapshot, "_mount"), params=params, @@ -59,17 +59,17 @@ class SearchableSnapshotsClient(NamespacedClient): ) @query_params() - def repository_stats(self, repository, params=None, headers=None): + async def repository_stats(self, repository, params=None, headers=None): """ Retrieve usage statistics about a snapshot repository. - ``_ + ``_ :arg repository: The repository for which to get the stats for """ if repository in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'repository'.") - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_snapshot", repository, "_stats"), params=params, @@ -77,14 +77,14 @@ class SearchableSnapshotsClient(NamespacedClient): ) @query_params() - def stats(self, index=None, params=None, headers=None): + async def stats(self, index=None, params=None, headers=None): """ Retrieve various statistics about searchable snapshots. - ``_ + ``_ :arg index: A comma-separated list of index names """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path(index, "_searchable_snapshots", "stats"), params=params, diff --git a/elasticsearch/_async/client/security.py b/elasticsearch/_async/client/security.py index 90e2ce7c..0466be48 100644 --- a/elasticsearch/_async/client/security.py +++ b/elasticsearch/_async/client/security.py @@ -7,21 +7,21 @@ from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH class SecurityClient(NamespacedClient): @query_params() - def authenticate(self, params=None, headers=None): + async def authenticate(self, params=None, headers=None): """ Enables authentication as a user and retrieve information about the authenticated user. - ``_ + ``_ """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", "/_security/_authenticate", params=params, headers=headers ) @query_params("refresh") - def change_password(self, body, username=None, params=None, headers=None): + async def change_password(self, body, username=None, params=None, headers=None): """ Changes the passwords of users in the native realm and built-in users. - ``_ + ``_ :arg body: the new password for the user :arg username: The username of the user to change the password @@ -34,7 +34,7 @@ class SecurityClient(NamespacedClient): if body in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'body'.") - return self.transport.perform_request( + return await self.transport.perform_request( "PUT", _make_path("_security", "user", username, "_password"), params=params, @@ -43,11 +43,11 @@ class SecurityClient(NamespacedClient): ) @query_params("usernames") - def clear_cached_realms(self, realms, params=None, headers=None): + async def clear_cached_realms(self, realms, params=None, headers=None): """ Evicts users from the user cache. Can completely clear the cache or evict specific users. - ``_ + ``_ :arg realms: Comma-separated list of realms to clear :arg usernames: Comma-separated list of usernames to clear from @@ -56,7 +56,7 @@ class SecurityClient(NamespacedClient): if realms in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'realms'.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path("_security", "realm", realms, "_clear_cache"), params=params, @@ -64,17 +64,17 @@ class SecurityClient(NamespacedClient): ) @query_params() - def clear_cached_roles(self, name, params=None, headers=None): + async def clear_cached_roles(self, name, params=None, headers=None): """ Evicts roles from the native role cache. - ``_ + ``_ :arg name: Role name """ if name in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'name'.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path("_security", "role", name, "_clear_cache"), params=params, @@ -82,10 +82,10 @@ class SecurityClient(NamespacedClient): ) @query_params("refresh") - def create_api_key(self, body, params=None, headers=None): + async def create_api_key(self, body, params=None, headers=None): """ Creates an API key for access without requiring basic authentication. - ``_ + ``_ :arg body: The api key request to create an API key :arg refresh: If `true` (the default) then refresh the affected @@ -96,15 +96,15 @@ class SecurityClient(NamespacedClient): if body in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'body'.") - return self.transport.perform_request( + return await self.transport.perform_request( "PUT", "/_security/api_key", params=params, headers=headers, body=body ) @query_params("refresh") - def delete_privileges(self, application, name, params=None, headers=None): + async def delete_privileges(self, application, name, params=None, headers=None): """ Removes application privileges. - ``_ + ``_ :arg application: Application name :arg name: Privilege name @@ -117,7 +117,7 @@ class SecurityClient(NamespacedClient): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( + return await self.transport.perform_request( "DELETE", _make_path("_security", "privilege", application, name), params=params, @@ -125,10 +125,10 @@ class SecurityClient(NamespacedClient): ) @query_params("refresh") - def delete_role(self, name, params=None, headers=None): + async def delete_role(self, name, params=None, headers=None): """ Removes roles in the native realm. - ``_ + ``_ :arg name: Role name :arg refresh: If `true` (the default) then refresh the affected @@ -139,7 +139,7 @@ class SecurityClient(NamespacedClient): if name in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'name'.") - return self.transport.perform_request( + return await self.transport.perform_request( "DELETE", _make_path("_security", "role", name), params=params, @@ -147,10 +147,10 @@ class SecurityClient(NamespacedClient): ) @query_params("refresh") - def delete_role_mapping(self, name, params=None, headers=None): + async def delete_role_mapping(self, name, params=None, headers=None): """ Removes role mappings. - ``_ + ``_ :arg name: Role-mapping name :arg refresh: If `true` (the default) then refresh the affected @@ -161,7 +161,7 @@ class SecurityClient(NamespacedClient): if name in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'name'.") - return self.transport.perform_request( + return await self.transport.perform_request( "DELETE", _make_path("_security", "role_mapping", name), params=params, @@ -169,10 +169,10 @@ class SecurityClient(NamespacedClient): ) @query_params("refresh") - def delete_user(self, username, params=None, headers=None): + async def delete_user(self, username, params=None, headers=None): """ Deletes users from the native realm. - ``_ + ``_ :arg username: username :arg refresh: If `true` (the default) then refresh the affected @@ -183,7 +183,7 @@ class SecurityClient(NamespacedClient): if username in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'username'.") - return self.transport.perform_request( + return await self.transport.perform_request( "DELETE", _make_path("_security", "user", username), params=params, @@ -191,10 +191,10 @@ class SecurityClient(NamespacedClient): ) @query_params("refresh") - def disable_user(self, username, params=None, headers=None): + async def disable_user(self, username, params=None, headers=None): """ Disables users in the native realm. - ``_ + ``_ :arg username: The username of the user to disable :arg refresh: If `true` (the default) then refresh the affected @@ -205,7 +205,7 @@ class SecurityClient(NamespacedClient): if username in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'username'.") - return self.transport.perform_request( + return await self.transport.perform_request( "PUT", _make_path("_security", "user", username, "_disable"), params=params, @@ -213,10 +213,10 @@ class SecurityClient(NamespacedClient): ) @query_params("refresh") - def enable_user(self, username, params=None, headers=None): + async def enable_user(self, username, params=None, headers=None): """ Enables users in the native realm. - ``_ + ``_ :arg username: The username of the user to enable :arg refresh: If `true` (the default) then refresh the affected @@ -227,7 +227,7 @@ class SecurityClient(NamespacedClient): if username in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'username'.") - return self.transport.perform_request( + return await self.transport.perform_request( "PUT", _make_path("_security", "user", username, "_enable"), params=params, @@ -235,10 +235,10 @@ class SecurityClient(NamespacedClient): ) @query_params("id", "name", "owner", "realm_name", "username") - def get_api_key(self, params=None, headers=None): + async def get_api_key(self, params=None, headers=None): """ Retrieves information for one or more API keys. - ``_ + ``_ :arg id: API key id of the API key to be retrieved :arg name: API key name of the API key to be retrieved @@ -249,20 +249,22 @@ class SecurityClient(NamespacedClient): :arg username: user name of the user who created this API key to be retrieved """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", "/_security/api_key", params=params, headers=headers ) @query_params() - def get_privileges(self, application=None, name=None, params=None, headers=None): + async def get_privileges( + self, application=None, name=None, params=None, headers=None + ): """ Retrieves application privileges. - ``_ + ``_ :arg application: Application name :arg name: Privilege name """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_security", "privilege", application, name), params=params, @@ -270,26 +272,26 @@ class SecurityClient(NamespacedClient): ) @query_params() - def get_role(self, name=None, params=None, headers=None): + async def get_role(self, name=None, params=None, headers=None): """ Retrieves roles in the native realm. - ``_ + ``_ :arg name: Role name """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_security", "role", name), params=params, headers=headers ) @query_params() - def get_role_mapping(self, name=None, params=None, headers=None): + async def get_role_mapping(self, name=None, params=None, headers=None): """ Retrieves role mappings. - ``_ + ``_ :arg name: Role-Mapping name """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_security", "role_mapping", name), params=params, @@ -297,29 +299,29 @@ class SecurityClient(NamespacedClient): ) @query_params() - def get_token(self, body, params=None, headers=None): + async def get_token(self, body, params=None, headers=None): """ Creates a bearer token for access without requiring basic authentication. - ``_ + ``_ :arg body: The token request to get """ if body in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'body'.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", "/_security/oauth2/token", params=params, headers=headers, body=body ) @query_params() - def get_user(self, username=None, params=None, headers=None): + async def get_user(self, username=None, params=None, headers=None): """ Retrieves information about users in the native realm and built-in users. - ``_ + ``_ :arg username: A comma-separated list of usernames """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_security", "user", username), params=params, @@ -327,20 +329,20 @@ class SecurityClient(NamespacedClient): ) @query_params() - def get_user_privileges(self, params=None, headers=None): + async def get_user_privileges(self, params=None, headers=None): """ Retrieves application privileges. - ``_ + ``_ """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", "/_security/user/_privileges", params=params, headers=headers ) @query_params() - def has_privileges(self, body, user=None, params=None, headers=None): + async def has_privileges(self, body, user=None, params=None, headers=None): """ Determines whether the specified user has a specified list of privileges. - ``_ + ``_ :arg body: The privileges to test :arg user: Username @@ -348,7 +350,7 @@ class SecurityClient(NamespacedClient): if body in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'body'.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path("_security", "user", user, "_has_privileges"), params=params, @@ -357,32 +359,32 @@ class SecurityClient(NamespacedClient): ) @query_params() - def invalidate_api_key(self, body, params=None, headers=None): + async def invalidate_api_key(self, body, params=None, headers=None): """ Invalidates one or more API keys. - ``_ + ``_ :arg body: The api key request to invalidate API key(s) """ if body in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'body'.") - return self.transport.perform_request( + return await self.transport.perform_request( "DELETE", "/_security/api_key", params=params, headers=headers, body=body ) @query_params() - def invalidate_token(self, body, params=None, headers=None): + async def invalidate_token(self, body, params=None, headers=None): """ Invalidates one or more access tokens or refresh tokens. - ``_ + ``_ :arg body: The token to invalidate """ if body in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'body'.") - return self.transport.perform_request( + return await self.transport.perform_request( "DELETE", "/_security/oauth2/token", params=params, @@ -391,10 +393,10 @@ class SecurityClient(NamespacedClient): ) @query_params("refresh") - def put_privileges(self, body, params=None, headers=None): + async def put_privileges(self, body, params=None, headers=None): """ Adds or updates application privileges. - ``_ + ``_ :arg body: The privilege(s) to add :arg refresh: If `true` (the default) then refresh the affected @@ -405,15 +407,15 @@ class SecurityClient(NamespacedClient): if body in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'body'.") - return self.transport.perform_request( + return await self.transport.perform_request( "PUT", "/_security/privilege/", params=params, headers=headers, body=body ) @query_params("refresh") - def put_role(self, name, body, params=None, headers=None): + async def put_role(self, name, body, params=None, headers=None): """ Adds and updates roles in the native realm. - ``_ + ``_ :arg name: Role name :arg body: The role to add @@ -426,7 +428,7 @@ class SecurityClient(NamespacedClient): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( + return await self.transport.perform_request( "PUT", _make_path("_security", "role", name), params=params, @@ -435,10 +437,10 @@ class SecurityClient(NamespacedClient): ) @query_params("refresh") - def put_role_mapping(self, name, body, params=None, headers=None): + async def put_role_mapping(self, name, body, params=None, headers=None): """ Creates and updates role mappings. - ``_ + ``_ :arg name: Role-mapping name :arg body: The role mapping to add @@ -451,7 +453,7 @@ class SecurityClient(NamespacedClient): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( + return await self.transport.perform_request( "PUT", _make_path("_security", "role_mapping", name), params=params, @@ -460,11 +462,11 @@ class SecurityClient(NamespacedClient): ) @query_params("refresh") - def put_user(self, username, body, params=None, headers=None): + async def put_user(self, username, body, params=None, headers=None): """ Adds and updates users in the native realm. These users are commonly referred to as native users. - ``_ + ``_ :arg username: The username of the User :arg body: The user to add @@ -477,7 +479,7 @@ class SecurityClient(NamespacedClient): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( + return await self.transport.perform_request( "PUT", _make_path("_security", "user", username), params=params, @@ -486,12 +488,12 @@ class SecurityClient(NamespacedClient): ) @query_params() - def get_builtin_privileges(self, params=None, headers=None): + async def get_builtin_privileges(self, params=None, headers=None): """ Retrieves the list of cluster privileges and index privileges that are available in this version of Elasticsearch. - ``_ + ``_ """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", "/_security/privilege/_builtin", params=params, headers=headers ) diff --git a/elasticsearch/_async/client/slm.py b/elasticsearch/_async/client/slm.py index 915650d8..ad6845e9 100644 --- a/elasticsearch/_async/client/slm.py +++ b/elasticsearch/_async/client/slm.py @@ -7,10 +7,10 @@ from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH class SlmClient(NamespacedClient): @query_params() - def delete_lifecycle(self, policy_id, params=None, headers=None): + async def delete_lifecycle(self, policy_id, params=None, headers=None): """ Deletes an existing snapshot lifecycle policy. - ``_ + ``_ :arg policy_id: The id of the snapshot lifecycle policy to remove @@ -18,7 +18,7 @@ class SlmClient(NamespacedClient): if policy_id in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'policy_id'.") - return self.transport.perform_request( + return await self.transport.perform_request( "DELETE", _make_path("_slm", "policy", policy_id), params=params, @@ -26,11 +26,11 @@ class SlmClient(NamespacedClient): ) @query_params() - def execute_lifecycle(self, policy_id, params=None, headers=None): + async def execute_lifecycle(self, policy_id, params=None, headers=None): """ Immediately creates a snapshot according to the lifecycle policy, without waiting for the scheduled time. - ``_ + ``_ :arg policy_id: The id of the snapshot lifecycle policy to be executed @@ -38,7 +38,7 @@ class SlmClient(NamespacedClient): if policy_id in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'policy_id'.") - return self.transport.perform_request( + return await self.transport.perform_request( "PUT", _make_path("_slm", "policy", policy_id, "_execute"), params=params, @@ -46,27 +46,27 @@ class SlmClient(NamespacedClient): ) @query_params() - def execute_retention(self, params=None, headers=None): + async def execute_retention(self, params=None, headers=None): """ Deletes any snapshots that are expired according to the policy's retention rules. - ``_ + ``_ """ - return self.transport.perform_request( + return await self.transport.perform_request( "POST", "/_slm/_execute_retention", params=params, headers=headers ) @query_params() - def get_lifecycle(self, policy_id=None, params=None, headers=None): + async def get_lifecycle(self, policy_id=None, params=None, headers=None): """ Retrieves one or more snapshot lifecycle policy definitions and information about the latest snapshot attempts. - ``_ + ``_ :arg policy_id: Comma-separated list of snapshot lifecycle policies to retrieve """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_slm", "policy", policy_id), params=params, @@ -74,21 +74,21 @@ class SlmClient(NamespacedClient): ) @query_params() - def get_stats(self, params=None, headers=None): + async def get_stats(self, params=None, headers=None): """ Returns global and policy-level statistics about actions taken by snapshot lifecycle management. - ``_ + ``_ """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", "/_slm/stats", params=params, headers=headers ) @query_params() - def put_lifecycle(self, policy_id, body=None, params=None, headers=None): + async def put_lifecycle(self, policy_id, body=None, params=None, headers=None): """ Creates or updates a snapshot lifecycle policy. - ``_ + ``_ :arg policy_id: The id of the snapshot lifecycle policy :arg body: The snapshot lifecycle policy definition to register @@ -96,7 +96,7 @@ class SlmClient(NamespacedClient): if policy_id in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'policy_id'.") - return self.transport.perform_request( + return await self.transport.perform_request( "PUT", _make_path("_slm", "policy", policy_id), params=params, @@ -105,31 +105,31 @@ class SlmClient(NamespacedClient): ) @query_params() - def get_status(self, params=None, headers=None): + async def get_status(self, params=None, headers=None): """ Retrieves the status of snapshot lifecycle management (SLM). - ``_ + ``_ """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", "/_slm/status", params=params, headers=headers ) @query_params() - def start(self, params=None, headers=None): + async def start(self, params=None, headers=None): """ Turns on snapshot lifecycle management (SLM). - ``_ + ``_ """ - return self.transport.perform_request( + return await self.transport.perform_request( "POST", "/_slm/start", params=params, headers=headers ) @query_params() - def stop(self, params=None, headers=None): + async def stop(self, params=None, headers=None): """ Turns off snapshot lifecycle management (SLM). - ``_ + ``_ """ - return self.transport.perform_request( + return await self.transport.perform_request( "POST", "/_slm/stop", params=params, headers=headers ) diff --git a/elasticsearch/_async/client/snapshot.py b/elasticsearch/_async/client/snapshot.py index 55b4b759..366a2893 100644 --- a/elasticsearch/_async/client/snapshot.py +++ b/elasticsearch/_async/client/snapshot.py @@ -7,10 +7,10 @@ from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH class SnapshotClient(NamespacedClient): @query_params("master_timeout", "wait_for_completion") - def create(self, repository, snapshot, body=None, params=None, headers=None): + async def create(self, repository, snapshot, body=None, params=None, headers=None): """ Creates a snapshot in a repository. - ``_ + ``_ :arg repository: A repository name :arg snapshot: A snapshot name @@ -24,7 +24,7 @@ class SnapshotClient(NamespacedClient): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( + return await self.transport.perform_request( "PUT", _make_path("_snapshot", repository, snapshot), params=params, @@ -33,10 +33,10 @@ class SnapshotClient(NamespacedClient): ) @query_params("master_timeout") - def delete(self, repository, snapshot, params=None, headers=None): + async def delete(self, repository, snapshot, params=None, headers=None): """ Deletes a snapshot. - ``_ + ``_ :arg repository: A repository name :arg snapshot: A snapshot name @@ -47,7 +47,7 @@ class SnapshotClient(NamespacedClient): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( + return await self.transport.perform_request( "DELETE", _make_path("_snapshot", repository, snapshot), params=params, @@ -55,10 +55,10 @@ class SnapshotClient(NamespacedClient): ) @query_params("ignore_unavailable", "master_timeout", "verbose") - def get(self, repository, snapshot, params=None, headers=None): + async def get(self, repository, snapshot, params=None, headers=None): """ Returns information about a snapshot. - ``_ + ``_ :arg repository: A repository name :arg snapshot: A comma-separated list of snapshot names @@ -74,7 +74,7 @@ class SnapshotClient(NamespacedClient): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_snapshot", repository, snapshot), params=params, @@ -82,10 +82,10 @@ class SnapshotClient(NamespacedClient): ) @query_params("master_timeout", "timeout") - def delete_repository(self, repository, params=None, headers=None): + async def delete_repository(self, repository, params=None, headers=None): """ Deletes a repository. - ``_ + ``_ :arg repository: A comma-separated list of repository names :arg master_timeout: Explicit operation timeout for connection @@ -95,7 +95,7 @@ class SnapshotClient(NamespacedClient): if repository in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'repository'.") - return self.transport.perform_request( + return await self.transport.perform_request( "DELETE", _make_path("_snapshot", repository), params=params, @@ -103,10 +103,10 @@ class SnapshotClient(NamespacedClient): ) @query_params("local", "master_timeout") - def get_repository(self, repository=None, params=None, headers=None): + async def get_repository(self, repository=None, params=None, headers=None): """ Returns information about a repository. - ``_ + ``_ :arg repository: A comma-separated list of repository names :arg local: Return local information, do not retrieve the state @@ -114,15 +114,15 @@ class SnapshotClient(NamespacedClient): :arg master_timeout: Explicit operation timeout for connection to master node """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_snapshot", repository), params=params, headers=headers ) @query_params("master_timeout", "timeout", "verify") - def create_repository(self, repository, body, params=None, headers=None): + async def create_repository(self, repository, body, params=None, headers=None): """ Creates a repository. - ``_ + ``_ :arg repository: A repository name :arg body: The repository definition @@ -135,7 +135,7 @@ class SnapshotClient(NamespacedClient): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( + return await self.transport.perform_request( "PUT", _make_path("_snapshot", repository), params=params, @@ -144,10 +144,10 @@ class SnapshotClient(NamespacedClient): ) @query_params("master_timeout", "wait_for_completion") - def restore(self, repository, snapshot, body=None, params=None, headers=None): + async def restore(self, repository, snapshot, body=None, params=None, headers=None): """ Restores a snapshot. - ``_ + ``_ :arg repository: A repository name :arg snapshot: A snapshot name @@ -161,7 +161,7 @@ class SnapshotClient(NamespacedClient): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path("_snapshot", repository, snapshot, "_restore"), params=params, @@ -170,10 +170,10 @@ class SnapshotClient(NamespacedClient): ) @query_params("ignore_unavailable", "master_timeout") - def status(self, repository=None, snapshot=None, params=None, headers=None): + async def status(self, repository=None, snapshot=None, params=None, headers=None): """ Returns information about the status of a snapshot. - ``_ + ``_ :arg repository: A repository name :arg snapshot: A comma-separated list of snapshot names @@ -183,7 +183,7 @@ class SnapshotClient(NamespacedClient): :arg master_timeout: Explicit operation timeout for connection to master node """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_snapshot", repository, snapshot, "_status"), params=params, @@ -191,10 +191,10 @@ class SnapshotClient(NamespacedClient): ) @query_params("master_timeout", "timeout") - def verify_repository(self, repository, params=None, headers=None): + async def verify_repository(self, repository, params=None, headers=None): """ Verifies a repository. - ``_ + ``_ :arg repository: A repository name :arg master_timeout: Explicit operation timeout for connection @@ -204,7 +204,7 @@ class SnapshotClient(NamespacedClient): if repository in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'repository'.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path("_snapshot", repository, "_verify"), params=params, @@ -212,10 +212,10 @@ class SnapshotClient(NamespacedClient): ) @query_params("master_timeout", "timeout") - def cleanup_repository(self, repository, params=None, headers=None): + async def cleanup_repository(self, repository, params=None, headers=None): """ Removes stale data from repository. - ``_ + ``_ :arg repository: A repository name :arg master_timeout: Explicit operation timeout for connection @@ -225,7 +225,7 @@ class SnapshotClient(NamespacedClient): if repository in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'repository'.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path("_snapshot", repository, "_cleanup"), params=params, diff --git a/elasticsearch/_async/client/sql.py b/elasticsearch/_async/client/sql.py index e043fee3..1720fb6e 100644 --- a/elasticsearch/_async/client/sql.py +++ b/elasticsearch/_async/client/sql.py @@ -7,10 +7,10 @@ from .utils import NamespacedClient, query_params, SKIP_IN_PATH class SqlClient(NamespacedClient): @query_params() - def clear_cursor(self, body, params=None, headers=None): + async def clear_cursor(self, body, params=None, headers=None): """ Clears the SQL cursor - ``_ + ``_ :arg body: Specify the cursor value in the `cursor` element to clean the cursor. @@ -18,15 +18,15 @@ class SqlClient(NamespacedClient): if body in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'body'.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", "/_sql/close", params=params, headers=headers, body=body ) @query_params("format") - def query(self, body, params=None, headers=None): + async def query(self, body, params=None, headers=None): """ Executes a SQL request - ``_ + ``_ :arg body: Use the `query` element to start a query. Use the `cursor` element to continue a query. @@ -36,21 +36,21 @@ class SqlClient(NamespacedClient): if body in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'body'.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", "/_sql", params=params, headers=headers, body=body ) @query_params() - def translate(self, body, params=None, headers=None): + async def translate(self, body, params=None, headers=None): """ Translates SQL into Elasticsearch queries - ``_ + ``_ :arg body: Specify the query in the `query` element. """ if body in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'body'.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", "/_sql/translate", params=params, headers=headers, body=body ) diff --git a/elasticsearch/_async/client/ssl.py b/elasticsearch/_async/client/ssl.py index e23d4737..ce4e6560 100644 --- a/elasticsearch/_async/client/ssl.py +++ b/elasticsearch/_async/client/ssl.py @@ -7,12 +7,12 @@ from .utils import NamespacedClient, query_params class SslClient(NamespacedClient): @query_params() - def certificates(self, params=None, headers=None): + async def certificates(self, params=None, headers=None): """ Retrieves information about the X.509 certificates used to encrypt communications in the cluster. - ``_ + ``_ """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", "/_ssl/certificates", params=params, headers=headers ) diff --git a/elasticsearch/_async/client/tasks.py b/elasticsearch/_async/client/tasks.py index 426bc8c8..c6f4e654 100644 --- a/elasticsearch/_async/client/tasks.py +++ b/elasticsearch/_async/client/tasks.py @@ -2,6 +2,7 @@ # Elasticsearch B.V licenses this file to you under the Apache 2.0 License. # See the LICENSE file in the project root for more information +import warnings from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH @@ -15,10 +16,10 @@ class TasksClient(NamespacedClient): "timeout", "wait_for_completion", ) - def list(self, params=None, headers=None): + async def list(self, params=None, headers=None): """ Returns a list of tasks. - ``_ + ``_ :arg actions: A comma-separated list of actions that should be returned. Leave empty to return all. @@ -34,15 +35,15 @@ class TasksClient(NamespacedClient): :arg wait_for_completion: Wait for the matching tasks to complete (default: false) """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", "/_tasks", params=params, headers=headers ) @query_params("actions", "nodes", "parent_task_id", "wait_for_completion") - def cancel(self, task_id=None, params=None, headers=None): + async def cancel(self, task_id=None, params=None, headers=None): """ Cancels a task, if it can be cancelled through an API. - ``_ + ``_ :arg task_id: Cancel the task with specified task id (node_id:task_number) @@ -57,7 +58,7 @@ class TasksClient(NamespacedClient): cancellation of the task and its descendant tasks is completed. Defaults to false """ - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path("_tasks", task_id, "_cancel"), params=params, @@ -65,10 +66,10 @@ class TasksClient(NamespacedClient): ) @query_params("timeout", "wait_for_completion") - def get(self, task_id, params=None, headers=None): + async def get(self, task_id=None, params=None, headers=None): """ Returns information about a task. - ``_ + ``_ :arg task_id: Return the task with specified id (node_id:task_number) @@ -77,8 +78,13 @@ class TasksClient(NamespacedClient): complete (default: false) """ if task_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'task_id'.") + warnings.warn( + "Calling client.tasks.get() without a task_id is deprecated " + "and will be removed in v8.0. Use client.tasks.list() instead.", + category=DeprecationWarning, + stacklevel=3, + ) - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_tasks", task_id), params=params, headers=headers ) diff --git a/elasticsearch/_async/client/transform.py b/elasticsearch/_async/client/transform.py index 23159bbb..ca3b7d35 100644 --- a/elasticsearch/_async/client/transform.py +++ b/elasticsearch/_async/client/transform.py @@ -7,10 +7,10 @@ from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH class TransformClient(NamespacedClient): @query_params("force") - def delete_transform(self, transform_id, params=None, headers=None): + async def delete_transform(self, transform_id, params=None, headers=None): """ Deletes an existing transform. - ``_ + ``_ :arg transform_id: The id of the transform to delete :arg force: When `true`, the transform is deleted regardless of @@ -22,7 +22,7 @@ class TransformClient(NamespacedClient): "Empty value passed for a required argument 'transform_id'." ) - return self.transport.perform_request( + return await self.transport.perform_request( "DELETE", _make_path("_transform", transform_id), params=params, @@ -30,10 +30,10 @@ class TransformClient(NamespacedClient): ) @query_params("allow_no_match", "from_", "size") - def get_transform(self, transform_id=None, params=None, headers=None): + async def get_transform(self, transform_id=None, params=None, headers=None): """ Retrieves configuration information for transforms. - ``_ + ``_ :arg transform_id: The id or comma delimited list of id expressions of the transforms to get, '_all' or '*' implies get all @@ -41,7 +41,7 @@ class TransformClient(NamespacedClient): :arg allow_no_match: Whether to ignore if a wildcard expression matches no transforms. (This includes `_all` string or when no transforms have been specified) - :arg from\\_: skips a number of transform configs, defaults to 0 + :arg from_: skips a number of transform configs, defaults to 0 :arg size: specifies a max number of transforms to get, defaults to 100 """ @@ -49,7 +49,7 @@ class TransformClient(NamespacedClient): if "from_" in params: params["from"] = params.pop("from_") - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_transform", transform_id), params=params, @@ -57,17 +57,17 @@ class TransformClient(NamespacedClient): ) @query_params("allow_no_match", "from_", "size") - def get_transform_stats(self, transform_id, params=None, headers=None): + async def get_transform_stats(self, transform_id, params=None, headers=None): """ Retrieves usage information for transforms. - ``_ + ``_ :arg transform_id: The id of the transform for which to get stats. '_all' or '*' implies all transforms :arg allow_no_match: Whether to ignore if a wildcard expression matches no transforms. (This includes `_all` string or when no transforms have been specified) - :arg from\\_: skips a number of transform stats, defaults to 0 + :arg from_: skips a number of transform stats, defaults to 0 :arg size: specifies a max number of transform stats to get, defaults to 100 """ @@ -80,7 +80,7 @@ class TransformClient(NamespacedClient): "Empty value passed for a required argument 'transform_id'." ) - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_transform", transform_id, "_stats"), params=params, @@ -88,25 +88,25 @@ class TransformClient(NamespacedClient): ) @query_params() - def preview_transform(self, body, params=None, headers=None): + async def preview_transform(self, body, params=None, headers=None): """ Previews a transform. - ``_ + ``_ :arg body: The definition for the transform to preview """ if body in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'body'.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", "/_transform/_preview", params=params, headers=headers, body=body ) @query_params("defer_validation") - def put_transform(self, transform_id, body, params=None, headers=None): + async def put_transform(self, transform_id, body, params=None, headers=None): """ Instantiates a transform. - ``_ + ``_ :arg transform_id: The id of the new transform. :arg body: The transform definition @@ -117,7 +117,7 @@ class TransformClient(NamespacedClient): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( + return await self.transport.perform_request( "PUT", _make_path("_transform", transform_id), params=params, @@ -126,10 +126,10 @@ class TransformClient(NamespacedClient): ) @query_params("timeout") - def start_transform(self, transform_id, params=None, headers=None): + async def start_transform(self, transform_id, params=None, headers=None): """ Starts one or more transforms. - ``_ + ``_ :arg transform_id: The id of the transform to start :arg timeout: Controls the time to wait for the transform to @@ -140,7 +140,7 @@ class TransformClient(NamespacedClient): "Empty value passed for a required argument 'transform_id'." ) - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path("_transform", transform_id, "_start"), params=params, @@ -154,10 +154,10 @@ class TransformClient(NamespacedClient): "wait_for_checkpoint", "wait_for_completion", ) - def stop_transform(self, transform_id, params=None, headers=None): + async def stop_transform(self, transform_id, params=None, headers=None): """ Stops one or more transforms. - ``_ + ``_ :arg transform_id: The id of the transform to stop :arg allow_no_match: Whether to ignore if a wildcard expression @@ -177,7 +177,7 @@ class TransformClient(NamespacedClient): "Empty value passed for a required argument 'transform_id'." ) - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path("_transform", transform_id, "_stop"), params=params, @@ -185,10 +185,10 @@ class TransformClient(NamespacedClient): ) @query_params("defer_validation") - def update_transform(self, transform_id, body, params=None, headers=None): + async def update_transform(self, transform_id, body, params=None, headers=None): """ Updates certain properties of a transform. - ``_ + ``_ :arg transform_id: The id of the transform. :arg body: The update transform definition @@ -199,7 +199,7 @@ class TransformClient(NamespacedClient): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - return self.transport.perform_request( + return await self.transport.perform_request( "POST", _make_path("_transform", transform_id, "_update"), params=params, diff --git a/elasticsearch/_async/client/utils.py b/elasticsearch/_async/client/utils.py index 11082db4..f28944f3 100644 --- a/elasticsearch/_async/client/utils.py +++ b/elasticsearch/_async/client/utils.py @@ -2,129 +2,12 @@ # Elasticsearch B.V licenses this file to you under the Apache 2.0 License. # See the LICENSE file in the project root for more information -from __future__ import unicode_literals - -import weakref -from datetime import date, datetime -from functools import wraps -from ..compat import string_types, quote, PY2 - -# parts of URL to be omitted -SKIP_IN_PATH = (None, "", b"", [], ()) - - -def _escape(value): - """ - Escape a single value of a URL string or a query parameter. If it is a list - or tuple, turn it into a comma-separated string first. - """ - - # make sequences into comma-separated stings - if isinstance(value, (list, tuple)): - value = ",".join(value) - - # dates and datetimes into isoformat - elif isinstance(value, (date, datetime)): - value = value.isoformat() - - # make bools into true/false strings - elif isinstance(value, bool): - value = str(value).lower() - - # don't decode bytestrings - elif isinstance(value, bytes): - return value - - # encode strings to utf-8 - if isinstance(value, string_types): - if PY2 and isinstance(value, unicode): # noqa: F821 - return value.encode("utf-8") - if not PY2 and isinstance(value, str): - return value.encode("utf-8") - - return str(value) - - -def _make_path(*parts): - """ - Create a URL string from parts, omit all `None` values and empty strings. - Convert lists and tuples to comma separated values. - """ - # TODO: maybe only allow some parts to be lists/tuples ? - return "/" + "/".join( - # preserve ',' and '*' in url for nicer URLs in logs - quote(_escape(p), b",*") - for p in parts - if p not in SKIP_IN_PATH - ) - - -# parameters that apply to all methods -GLOBAL_PARAMS = ("pretty", "human", "error_trace", "format", "filter_path") - - -def query_params(*es_query_params): - """ - Decorator that pops all accepted parameters from method's kwargs and puts - them in the params argument. - """ - - def _wrapper(func): - @wraps(func) - def _wrapped(*args, **kwargs): - params = (kwargs.pop("params", None) or {}).copy() - headers = { - k.lower(): v - for k, v in (kwargs.pop("headers", None) or {}).copy().items() - } - - if "opaque_id" in kwargs: - headers["x-opaque-id"] = kwargs.pop("opaque_id") - - for p in es_query_params + GLOBAL_PARAMS: - if p in kwargs: - v = kwargs.pop(p) - if v is not None: - params[p] = _escape(v) - - # don't treat ignore, request_timeout, and opaque_id as other params to avoid escaping - for p in ("ignore", "request_timeout"): - if p in kwargs: - params[p] = kwargs.pop(p) - return func(*args, params=params, headers=headers, **kwargs) - - return _wrapped - - return _wrapper - - -def _bulk_body(serializer, body): - # if not passed in a string, serialize items and join by newline - if not isinstance(body, string_types): - body = "\n".join(map(serializer.dumps, body)) - - # bulk body must end with a newline - if isinstance(body, bytes): - if not body.endswith(b"\n"): - body += b"\n" - elif isinstance(body, string_types) and not body.endswith("\n"): - body += "\n" - - return body - - -class NamespacedClient(object): - def __init__(self, client): - self.client = client - - @property - def transport(self): - return self.client.transport - - -class AddonClient(NamespacedClient): - @classmethod - def infect_client(cls, client): - addon = cls(weakref.proxy(client)) - setattr(client, cls.namespace, addon) - return client +from ...client.utils import ( # noqa + _make_path, + _normalize_hosts, + _escape, + _bulk_body, + query_params, + SKIP_IN_PATH, + NamespacedClient, +) diff --git a/elasticsearch/_async/client/watcher.py b/elasticsearch/_async/client/watcher.py index 654c4b48..0f94c3c3 100644 --- a/elasticsearch/_async/client/watcher.py +++ b/elasticsearch/_async/client/watcher.py @@ -7,10 +7,10 @@ from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH class WatcherClient(NamespacedClient): @query_params() - def ack_watch(self, watch_id, action_id=None, params=None, headers=None): + async def ack_watch(self, watch_id, action_id=None, params=None, headers=None): """ Acknowledges a watch, manually throttling the execution of the watch's actions. - ``_ + ``_ :arg watch_id: Watch ID :arg action_id: A comma-separated list of the action ids to be @@ -19,7 +19,7 @@ class WatcherClient(NamespacedClient): if watch_id in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'watch_id'.") - return self.transport.perform_request( + return await self.transport.perform_request( "PUT", _make_path("_watcher", "watch", watch_id, "_ack", action_id), params=params, @@ -27,17 +27,17 @@ class WatcherClient(NamespacedClient): ) @query_params() - def activate_watch(self, watch_id, params=None, headers=None): + async def activate_watch(self, watch_id, params=None, headers=None): """ Activates a currently inactive watch. - ``_ + ``_ :arg watch_id: Watch ID """ if watch_id in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'watch_id'.") - return self.transport.perform_request( + return await self.transport.perform_request( "PUT", _make_path("_watcher", "watch", watch_id, "_activate"), params=params, @@ -45,17 +45,17 @@ class WatcherClient(NamespacedClient): ) @query_params() - def deactivate_watch(self, watch_id, params=None, headers=None): + async def deactivate_watch(self, watch_id, params=None, headers=None): """ Deactivates a currently active watch. - ``_ + ``_ :arg watch_id: Watch ID """ if watch_id in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'watch_id'.") - return self.transport.perform_request( + return await self.transport.perform_request( "PUT", _make_path("_watcher", "watch", watch_id, "_deactivate"), params=params, @@ -63,17 +63,17 @@ class WatcherClient(NamespacedClient): ) @query_params() - def delete_watch(self, id, params=None, headers=None): + async def delete_watch(self, id, params=None, headers=None): """ Removes a watch from Watcher. - ``_ + ``_ :arg id: Watch ID """ if id in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'id'.") - return self.transport.perform_request( + return await self.transport.perform_request( "DELETE", _make_path("_watcher", "watch", id), params=params, @@ -81,17 +81,17 @@ class WatcherClient(NamespacedClient): ) @query_params("debug") - def execute_watch(self, body=None, id=None, params=None, headers=None): + async def execute_watch(self, body=None, id=None, params=None, headers=None): """ Forces the execution of a stored watch. - ``_ + ``_ :arg body: Execution control :arg id: Watch ID :arg debug: indicates whether the watch should execute in debug mode """ - return self.transport.perform_request( + return await self.transport.perform_request( "PUT", _make_path("_watcher", "watch", id, "_execute"), params=params, @@ -100,25 +100,25 @@ class WatcherClient(NamespacedClient): ) @query_params() - def get_watch(self, id, params=None, headers=None): + async def get_watch(self, id, params=None, headers=None): """ Retrieves a watch by its ID. - ``_ + ``_ :arg id: Watch ID """ if id in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'id'.") - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_watcher", "watch", id), params=params, headers=headers ) @query_params("active", "if_primary_term", "if_seq_no", "version") - def put_watch(self, id, body=None, params=None, headers=None): + async def put_watch(self, id, body=None, params=None, headers=None): """ Creates a new watch, or updates an existing one. - ``_ + ``_ :arg id: Watch ID :arg body: The watch @@ -132,7 +132,7 @@ class WatcherClient(NamespacedClient): if id in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'id'.") - return self.transport.perform_request( + return await self.transport.perform_request( "PUT", _make_path("_watcher", "watch", id), params=params, @@ -141,20 +141,20 @@ class WatcherClient(NamespacedClient): ) @query_params() - def start(self, params=None, headers=None): + async def start(self, params=None, headers=None): """ Starts Watcher if it is not already running. - ``_ + ``_ """ - return self.transport.perform_request( + return await self.transport.perform_request( "POST", "/_watcher/_start", params=params, headers=headers ) @query_params("emit_stacktraces") - def stats(self, metric=None, params=None, headers=None): + async def stats(self, metric=None, params=None, headers=None): """ Retrieves the current Watcher metrics. - ``_ + ``_ :arg metric: Controls what additional stat metrics should be include in the response Valid choices: _all, queued_watches, @@ -162,7 +162,7 @@ class WatcherClient(NamespacedClient): :arg emit_stacktraces: Emits stack traces of currently running watches """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", _make_path("_watcher", "stats", metric), params=params, @@ -170,11 +170,11 @@ class WatcherClient(NamespacedClient): ) @query_params() - def stop(self, params=None, headers=None): + async def stop(self, params=None, headers=None): """ Stops Watcher if it is running. - ``_ + ``_ """ - return self.transport.perform_request( + return await self.transport.perform_request( "POST", "/_watcher/_stop", params=params, headers=headers ) diff --git a/elasticsearch/_async/client/xpack.py b/elasticsearch/_async/client/xpack.py index 61560fd4..d740c732 100644 --- a/elasticsearch/_async/client/xpack.py +++ b/elasticsearch/_async/client/xpack.py @@ -11,26 +11,26 @@ class XPackClient(NamespacedClient): # AUTO-GENERATED-API-DEFINITIONS # @query_params("categories") - def info(self, params=None, headers=None): + async def info(self, params=None, headers=None): """ Retrieves information about the installed X-Pack features. - ``_ + ``_ :arg categories: Comma-separated list of info categories. Can be any of: build, license, features """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", "/_xpack", params=params, headers=headers ) @query_params("master_timeout") - def usage(self, params=None, headers=None): + async def usage(self, params=None, headers=None): """ Retrieves usage information about the installed X-Pack features. - ``_ + ``_ :arg master_timeout: Specify timeout for watch write operation """ - return self.transport.perform_request( + return await self.transport.perform_request( "GET", "/_xpack/usage", params=params, headers=headers ) diff --git a/elasticsearch/client/__init__.py b/elasticsearch/client/__init__.py index 843567f3..d6b18800 100644 --- a/elasticsearch/client/__init__.py +++ b/elasticsearch/client/__init__.py @@ -6,9 +6,7 @@ from __future__ import unicode_literals import logging -from ..transport import Transport -from ..exceptions import TransportError -from ..compat import string_types, urlparse, unquote +from ..transport import Transport, TransportError from .indices import IndicesClient from .ingest import IngestClient from .cluster import ClusterClient diff --git a/test_elasticsearch/test_async/test_server/__init__.py b/test_elasticsearch/test_async/test_server/__init__.py index e69de29b..47633799 100644 --- a/test_elasticsearch/test_async/test_server/__init__.py +++ b/test_elasticsearch/test_async/test_server/__init__.py @@ -0,0 +1,4 @@ +# Licensed to Elasticsearch B.V under one or more agreements. +# Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +# See the LICENSE file in the project root for more information + diff --git a/test_elasticsearch/test_async/test_server/conftest.py b/test_elasticsearch/test_async/test_server/conftest.py index e69de29b..47633799 100644 --- a/test_elasticsearch/test_async/test_server/conftest.py +++ b/test_elasticsearch/test_async/test_server/conftest.py @@ -0,0 +1,4 @@ +# Licensed to Elasticsearch B.V under one or more agreements. +# Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +# See the LICENSE file in the project root for more information + diff --git a/test_elasticsearch/test_async/test_server/test_clients.py b/test_elasticsearch/test_async/test_server/test_clients.py index e69de29b..47633799 100644 --- a/test_elasticsearch/test_async/test_server/test_clients.py +++ b/test_elasticsearch/test_async/test_server/test_clients.py @@ -0,0 +1,4 @@ +# Licensed to Elasticsearch B.V under one or more agreements. +# Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +# See the LICENSE file in the project root for more information + diff --git a/test_elasticsearch/test_async/test_server/test_rest_api_spec.py b/test_elasticsearch/test_async/test_server/test_rest_api_spec.py index e69de29b..47633799 100644 --- a/test_elasticsearch/test_async/test_server/test_rest_api_spec.py +++ b/test_elasticsearch/test_async/test_server/test_rest_api_spec.py @@ -0,0 +1,4 @@ +# Licensed to Elasticsearch B.V under one or more agreements. +# Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +# See the LICENSE file in the project root for more information +