From 7c9ca8398a132dfeca7fd87641b872222547ef82 Mon Sep 17 00:00:00 2001 From: Seth Michael Larson Date: Wed, 10 Nov 2021 08:43:03 -0600 Subject: [PATCH 1/6] Switch to new API generator --- .coveragerc | 2 + elasticsearch/_async/client/__init__.py | 5476 ++++++++++------ elasticsearch/_async/client/__init__.pyi | 1197 ---- elasticsearch/_async/client/_base.py | 13 +- elasticsearch/_async/client/async_search.py | 645 +- elasticsearch/_async/client/async_search.pyi | 137 - elasticsearch/_async/client/autoscaling.py | 192 +- elasticsearch/_async/client/autoscaling.pyi | 92 - elasticsearch/_async/client/cat.py | 2546 +++++--- elasticsearch/_async/client/cat.pyi | 610 -- elasticsearch/_async/client/ccr.py | 864 ++- elasticsearch/_async/client/ccr.pyi | 249 - elasticsearch/_async/client/cluster.py | 1116 +++- elasticsearch/_async/client/cluster.pyi | 328 - .../_async/client/dangling_indices.py | 150 +- .../_async/client/dangling_indices.pyi | 80 - elasticsearch/_async/client/enrich.py | 231 +- elasticsearch/_async/client/enrich.pyi | 110 - elasticsearch/_async/client/eql.py | 286 +- elasticsearch/_async/client/eql.pyi | 98 - elasticsearch/_async/client/features.py | 78 +- elasticsearch/_async/client/features.pyi | 57 - elasticsearch/_async/client/fleet.py | 116 - elasticsearch/_async/client/fleet.pyi | 84 - elasticsearch/_async/client/graph.py | 83 +- elasticsearch/_async/client/graph.pyi | 44 - elasticsearch/_async/client/ilm.py | 496 +- elasticsearch/_async/client/ilm.pyi | 213 - elasticsearch/_async/client/indices.py | 4498 +++++++++----- elasticsearch/_async/client/indices.pyi | 1171 ---- elasticsearch/_async/client/ingest.py | 354 +- elasticsearch/_async/client/ingest.pyi | 134 - elasticsearch/_async/client/license.py | 281 +- elasticsearch/_async/client/license.pyi | 143 - elasticsearch/_async/client/logstash.py | 142 +- elasticsearch/_async/client/logstash.pyi | 76 - elasticsearch/_async/client/migration.py | 71 +- elasticsearch/_async/client/migration.pyi | 73 - elasticsearch/_async/client/ml.py | 5357 +++++++++++----- elasticsearch/_async/client/ml.pyi | 1398 ----- elasticsearch/_async/client/monitoring.py | 79 +- elasticsearch/_async/client/monitoring.pyi | 45 - elasticsearch/_async/client/nodes.py | 513 +- elasticsearch/_async/client/nodes.pyi | 169 - elasticsearch/_async/client/rollup.py | 537 +- elasticsearch/_async/client/rollup.pyi | 186 - .../_async/client/searchable_snapshots.py | 241 +- .../_async/client/searchable_snapshots.pyi | 101 - elasticsearch/_async/client/security.py | 2300 ++++--- elasticsearch/_async/client/security.pyi | 785 --- elasticsearch/_async/client/shutdown.py | 135 +- elasticsearch/_async/client/shutdown.pyi | 76 - elasticsearch/_async/client/slm.py | 408 +- elasticsearch/_async/client/slm.pyi | 173 - elasticsearch/_async/client/snapshot.py | 888 ++- elasticsearch/_async/client/snapshot.pyi | 274 - elasticsearch/_async/client/sql.py | 265 +- elasticsearch/_async/client/sql.pyi | 129 - elasticsearch/_async/client/ssl.py | 41 +- elasticsearch/_async/client/ssl.pyi | 40 - elasticsearch/_async/client/tasks.py | 238 +- elasticsearch/_async/client/tasks.pyi | 87 - elasticsearch/_async/client/text_structure.py | 194 +- .../_async/client/text_structure.pyi | 54 - elasticsearch/_async/client/transform.py | 666 +- elasticsearch/_async/client/transform.pyi | 196 - elasticsearch/_async/client/utils.py | 18 +- elasticsearch/_async/client/watcher.py | 619 +- elasticsearch/_async/client/watcher.pyi | 218 - elasticsearch/_async/client/xpack.py | 87 +- elasticsearch/_async/client/xpack.pyi | 62 - elasticsearch/_async/compat.py | 38 - elasticsearch/_async/helpers.py | 2 +- elasticsearch/_sync/client/__init__.py | 5500 +++++++++++------ elasticsearch/_sync/client/__init__.pyi | 1197 ---- elasticsearch/_sync/client/_base.py | 15 +- elasticsearch/_sync/client/async_search.py | 645 +- elasticsearch/_sync/client/async_search.pyi | 137 - elasticsearch/_sync/client/autoscaling.py | 192 +- elasticsearch/_sync/client/autoscaling.pyi | 92 - elasticsearch/_sync/client/cat.py | 2544 +++++--- elasticsearch/_sync/client/cat.pyi | 610 -- elasticsearch/_sync/client/ccr.py | 872 ++- elasticsearch/_sync/client/ccr.pyi | 249 - elasticsearch/_sync/client/cluster.py | 1124 +++- elasticsearch/_sync/client/cluster.pyi | 328 - .../_sync/client/dangling_indices.py | 150 +- .../_sync/client/dangling_indices.pyi | 80 - elasticsearch/_sync/client/enrich.py | 233 +- elasticsearch/_sync/client/enrich.pyi | 110 - elasticsearch/_sync/client/eql.py | 286 +- elasticsearch/_sync/client/eql.pyi | 98 - elasticsearch/_sync/client/features.py | 78 +- elasticsearch/_sync/client/features.pyi | 57 - elasticsearch/_sync/client/fleet.py | 116 - elasticsearch/_sync/client/fleet.pyi | 84 - elasticsearch/_sync/client/graph.py | 83 +- elasticsearch/_sync/client/graph.pyi | 44 - elasticsearch/_sync/client/ilm.py | 500 +- elasticsearch/_sync/client/ilm.pyi | 213 - elasticsearch/_sync/client/indices.py | 4512 +++++++++----- elasticsearch/_sync/client/indices.pyi | 1171 ---- elasticsearch/_sync/client/ingest.py | 358 +- elasticsearch/_sync/client/ingest.pyi | 134 - elasticsearch/_sync/client/license.py | 281 +- elasticsearch/_sync/client/license.pyi | 143 - elasticsearch/_sync/client/logstash.py | 142 +- elasticsearch/_sync/client/logstash.pyi | 76 - elasticsearch/_sync/client/migration.py | 71 +- elasticsearch/_sync/client/migration.pyi | 73 - elasticsearch/_sync/client/ml.py | 5277 +++++++++++----- elasticsearch/_sync/client/ml.pyi | 1398 ----- elasticsearch/_sync/client/monitoring.py | 79 +- elasticsearch/_sync/client/monitoring.pyi | 45 - elasticsearch/_sync/client/nodes.py | 513 +- elasticsearch/_sync/client/nodes.pyi | 169 - elasticsearch/_sync/client/rollup.py | 539 +- elasticsearch/_sync/client/rollup.pyi | 186 - .../_sync/client/searchable_snapshots.py | 243 +- .../_sync/client/searchable_snapshots.pyi | 101 - elasticsearch/_sync/client/security.py | 2302 ++++--- elasticsearch/_sync/client/security.pyi | 785 --- elasticsearch/_sync/client/shutdown.py | 135 +- elasticsearch/_sync/client/shutdown.pyi | 76 - elasticsearch/_sync/client/slm.py | 408 +- elasticsearch/_sync/client/slm.pyi | 173 - elasticsearch/_sync/client/snapshot.py | 896 ++- elasticsearch/_sync/client/snapshot.pyi | 274 - elasticsearch/_sync/client/sql.py | 269 +- elasticsearch/_sync/client/sql.pyi | 129 - elasticsearch/_sync/client/ssl.py | 41 +- elasticsearch/_sync/client/ssl.pyi | 40 - elasticsearch/_sync/client/tasks.py | 236 +- elasticsearch/_sync/client/tasks.pyi | 87 - elasticsearch/_sync/client/text_structure.py | 194 +- elasticsearch/_sync/client/text_structure.pyi | 54 - elasticsearch/_sync/client/transform.py | 670 +- elasticsearch/_sync/client/transform.pyi | 196 - elasticsearch/_sync/client/utils.py | 321 +- elasticsearch/_sync/client/watcher.py | 621 +- elasticsearch/_sync/client/watcher.pyi | 218 - elasticsearch/_sync/client/xpack.py | 85 +- elasticsearch/_sync/client/xpack.pyi | 62 - elasticsearch/compat.py | 12 +- elasticsearch/helpers/actions.py | 2 +- noxfile.py | 4 +- setup.cfg | 2 +- .../test_async/test_transport.py | 72 +- .../test_client/test_cluster.py | 2 +- .../test_client/test_indices.py | 10 +- .../test_client/test_options.py | 36 +- .../test_client/test_overrides.py | 17 +- test_elasticsearch/test_client/test_utils.py | 144 +- .../test_server/test_clients.py | 7 +- .../test_server/test_helpers.py | 44 +- test_elasticsearch/test_transport.py | 61 +- test_elasticsearch/utils.py | 4 +- utils/generate-api.py | 416 -- utils/run-black.py | 86 + utils/templates/base | 38 - utils/templates/base_pyi | 2 - utils/templates/example | 12 - utils/templates/func_params | 14 - utils/templates/func_params_pyi | 26 - .../templates/overrides/__init__/clear_scroll | 12 - utils/templates/overrides/__init__/create | 10 - utils/templates/overrides/__init__/delete | 8 - utils/templates/overrides/__init__/index | 11 - utils/templates/overrides/__init__/ping | 9 - utils/templates/overrides/__init__/scroll | 12 - utils/templates/overrides/__init__/update | 10 - utils/templates/overrides/cluster/state | 8 - utils/templates/overrides/cluster/stats | 5 - utils/templates/required | 11 - utils/templates/substitutions | 8 - utils/templates/url | 1 - 176 files changed, 42056 insertions(+), 37635 deletions(-) delete mode 100644 elasticsearch/_async/client/__init__.pyi delete mode 100644 elasticsearch/_async/client/async_search.pyi delete mode 100644 elasticsearch/_async/client/autoscaling.pyi delete mode 100644 elasticsearch/_async/client/cat.pyi delete mode 100644 elasticsearch/_async/client/ccr.pyi delete mode 100644 elasticsearch/_async/client/cluster.pyi delete mode 100644 elasticsearch/_async/client/dangling_indices.pyi delete mode 100644 elasticsearch/_async/client/enrich.pyi delete mode 100644 elasticsearch/_async/client/eql.pyi delete mode 100644 elasticsearch/_async/client/features.pyi delete mode 100644 elasticsearch/_async/client/fleet.py delete mode 100644 elasticsearch/_async/client/fleet.pyi delete mode 100644 elasticsearch/_async/client/graph.pyi delete mode 100644 elasticsearch/_async/client/ilm.pyi delete mode 100644 elasticsearch/_async/client/indices.pyi delete mode 100644 elasticsearch/_async/client/ingest.pyi delete mode 100644 elasticsearch/_async/client/license.pyi delete mode 100644 elasticsearch/_async/client/logstash.pyi delete mode 100644 elasticsearch/_async/client/migration.pyi delete mode 100644 elasticsearch/_async/client/ml.pyi delete mode 100644 elasticsearch/_async/client/monitoring.pyi delete mode 100644 elasticsearch/_async/client/nodes.pyi delete mode 100644 elasticsearch/_async/client/rollup.pyi delete mode 100644 elasticsearch/_async/client/searchable_snapshots.pyi delete mode 100644 elasticsearch/_async/client/security.pyi delete mode 100644 elasticsearch/_async/client/shutdown.pyi delete mode 100644 elasticsearch/_async/client/slm.pyi delete mode 100644 elasticsearch/_async/client/snapshot.pyi delete mode 100644 elasticsearch/_async/client/sql.pyi delete mode 100644 elasticsearch/_async/client/ssl.pyi delete mode 100644 elasticsearch/_async/client/tasks.pyi delete mode 100644 elasticsearch/_async/client/text_structure.pyi delete mode 100644 elasticsearch/_async/client/transform.pyi delete mode 100644 elasticsearch/_async/client/watcher.pyi delete mode 100644 elasticsearch/_async/client/xpack.pyi delete mode 100644 elasticsearch/_async/compat.py delete mode 100644 elasticsearch/_sync/client/__init__.pyi delete mode 100644 elasticsearch/_sync/client/async_search.pyi delete mode 100644 elasticsearch/_sync/client/autoscaling.pyi delete mode 100644 elasticsearch/_sync/client/cat.pyi delete mode 100644 elasticsearch/_sync/client/ccr.pyi delete mode 100644 elasticsearch/_sync/client/cluster.pyi delete mode 100644 elasticsearch/_sync/client/dangling_indices.pyi delete mode 100644 elasticsearch/_sync/client/enrich.pyi delete mode 100644 elasticsearch/_sync/client/eql.pyi delete mode 100644 elasticsearch/_sync/client/features.pyi delete mode 100644 elasticsearch/_sync/client/fleet.py delete mode 100644 elasticsearch/_sync/client/fleet.pyi delete mode 100644 elasticsearch/_sync/client/graph.pyi delete mode 100644 elasticsearch/_sync/client/ilm.pyi delete mode 100644 elasticsearch/_sync/client/indices.pyi delete mode 100644 elasticsearch/_sync/client/ingest.pyi delete mode 100644 elasticsearch/_sync/client/license.pyi delete mode 100644 elasticsearch/_sync/client/logstash.pyi delete mode 100644 elasticsearch/_sync/client/migration.pyi delete mode 100644 elasticsearch/_sync/client/ml.pyi delete mode 100644 elasticsearch/_sync/client/monitoring.pyi delete mode 100644 elasticsearch/_sync/client/nodes.pyi delete mode 100644 elasticsearch/_sync/client/rollup.pyi delete mode 100644 elasticsearch/_sync/client/searchable_snapshots.pyi delete mode 100644 elasticsearch/_sync/client/security.pyi delete mode 100644 elasticsearch/_sync/client/shutdown.pyi delete mode 100644 elasticsearch/_sync/client/slm.pyi delete mode 100644 elasticsearch/_sync/client/snapshot.pyi delete mode 100644 elasticsearch/_sync/client/sql.pyi delete mode 100644 elasticsearch/_sync/client/ssl.pyi delete mode 100644 elasticsearch/_sync/client/tasks.pyi delete mode 100644 elasticsearch/_sync/client/text_structure.pyi delete mode 100644 elasticsearch/_sync/client/transform.pyi delete mode 100644 elasticsearch/_sync/client/watcher.pyi delete mode 100644 elasticsearch/_sync/client/xpack.pyi delete mode 100644 utils/generate-api.py create mode 100644 utils/run-black.py delete mode 100644 utils/templates/base delete mode 100644 utils/templates/base_pyi delete mode 100644 utils/templates/example delete mode 100644 utils/templates/func_params delete mode 100644 utils/templates/func_params_pyi delete mode 100644 utils/templates/overrides/__init__/clear_scroll delete mode 100644 utils/templates/overrides/__init__/create delete mode 100644 utils/templates/overrides/__init__/delete delete mode 100644 utils/templates/overrides/__init__/index delete mode 100644 utils/templates/overrides/__init__/ping delete mode 100644 utils/templates/overrides/__init__/scroll delete mode 100644 utils/templates/overrides/__init__/update delete mode 100644 utils/templates/overrides/cluster/state delete mode 100644 utils/templates/overrides/cluster/stats delete mode 100644 utils/templates/required delete mode 100644 utils/templates/substitutions delete mode 100644 utils/templates/url diff --git a/.coveragerc b/.coveragerc index a7dff09b9..07a342fbc 100644 --- a/.coveragerc +++ b/.coveragerc @@ -5,6 +5,8 @@ omit = */lib_pypy/* */site-packages/* *.egg/* + elasticsearch/_async/client/ + elasticsearch/_sync/client/ test_elasticsearch/* [report] diff --git a/elasticsearch/_async/client/__init__.py b/elasticsearch/_async/client/__init__.py index 08240b124..fabcd509c 100644 --- a/elasticsearch/_async/client/__init__.py +++ b/elasticsearch/_async/client/__init__.py @@ -18,10 +18,29 @@ import logging import warnings -from typing import Any, Callable, Dict, Optional, Union +from typing import ( + Any, + Callable, + Collection, + Dict, + List, + Mapping, + Optional, + Tuple, + Type, + Union, +) -from elastic_transport import AsyncTransport, NodeConfig, TransportError -from elastic_transport.client_utils import DEFAULT +from elastic_transport import ( + AsyncTransport, + BaseNode, + NodeConfig, + NodePool, + NodeSelector, + Serializer, + TransportError, +) +from elastic_transport.client_utils import DEFAULT, DefaultType from ...serializer import DEFAULT_SERIALIZERS from ._base import ( @@ -39,7 +58,6 @@ from .enrich import EnrichClient from .eql import EqlClient from .features import FeaturesClient -from .fleet import FleetClient from .graph import GraphClient from .ilm import IlmClient from .indices import IndicesClient @@ -65,10 +83,10 @@ _TYPE_HOSTS, CLIENT_META_SERVICE, SKIP_IN_PATH, - _deprecated_options, - _make_path, + _quote, + _quote_query, + _rewrite_parameters, client_node_configs, - query_params, ) from .watcher import WatcherClient from .xpack import XPackClient @@ -116,59 +134,59 @@ def __init__( *, # API cloud_id: Optional[str] = None, - api_key=None, - basic_auth=None, - bearer_auth=None, - opaque_id=None, + api_key: Optional[Union[str, Tuple[str, str]]] = None, + basic_auth: Optional[Union[str, Tuple[str, str]]] = None, + bearer_auth: Optional[str] = None, + opaque_id: Optional[str] = None, # Node - headers=DEFAULT, - connections_per_node=DEFAULT, - http_compress=DEFAULT, - verify_certs=DEFAULT, - ca_certs=DEFAULT, - client_cert=DEFAULT, - client_key=DEFAULT, - ssl_assert_hostname=DEFAULT, - ssl_assert_fingerprint=DEFAULT, - ssl_version=DEFAULT, - ssl_context=DEFAULT, - ssl_show_warn=DEFAULT, + headers: Union[DefaultType, Mapping[str, str]] = DEFAULT, + connections_per_node: Union[DefaultType, int] = DEFAULT, + http_compress: Union[DefaultType, bool] = DEFAULT, + verify_certs: Union[DefaultType, bool] = DEFAULT, + ca_certs: Union[DefaultType, str] = DEFAULT, + client_cert: Union[DefaultType, str] = DEFAULT, + client_key: Union[DefaultType, str] = DEFAULT, + ssl_assert_hostname: Union[DefaultType, str] = DEFAULT, + ssl_assert_fingerprint: Union[DefaultType, str] = DEFAULT, + ssl_version: Union[DefaultType, int] = DEFAULT, + ssl_context: Union[DefaultType, Any] = DEFAULT, + ssl_show_warn: Union[DefaultType, bool] = DEFAULT, # Transport - transport_class=AsyncTransport, - request_timeout=DEFAULT, - node_class=DEFAULT, - node_pool_class=DEFAULT, - randomize_nodes_in_pool=DEFAULT, - node_selector_class=DEFAULT, - dead_node_backoff_factor=DEFAULT, - max_dead_node_backoff=DEFAULT, - serializers=DEFAULT, - default_mimetype="application/json", - max_retries=DEFAULT, - retry_on_status=DEFAULT, - retry_on_timeout=DEFAULT, - sniff_on_start=DEFAULT, - sniff_before_requests=DEFAULT, - sniff_on_node_failure=DEFAULT, - sniff_timeout=DEFAULT, - min_delay_between_sniffing=DEFAULT, + transport_class: Type[AsyncTransport] = AsyncTransport, + request_timeout: Union[DefaultType, None, float] = DEFAULT, + node_class: Union[DefaultType, Type[BaseNode]] = DEFAULT, + node_pool_class: Union[DefaultType, Type[NodePool]] = DEFAULT, + randomize_nodes_in_pool: Union[DefaultType, bool] = DEFAULT, + node_selector_class: Union[DefaultType, Type[NodeSelector]] = DEFAULT, + dead_node_backoff_factor: Union[DefaultType, float] = DEFAULT, + max_dead_node_backoff: Union[DefaultType, float] = DEFAULT, + serializers: Union[DefaultType, Mapping[str, Serializer]] = DEFAULT, + default_mimetype: str = "application/json", + max_retries: Union[DefaultType, int] = DEFAULT, + retry_on_status: Union[DefaultType, int, Collection[int]] = DEFAULT, + retry_on_timeout: Union[DefaultType, bool] = DEFAULT, + sniff_on_start: Union[DefaultType, bool] = DEFAULT, + sniff_before_requests: Union[DefaultType, bool] = DEFAULT, + sniff_on_node_failure: Union[DefaultType, bool] = DEFAULT, + sniff_timeout: Union[DefaultType, None, float] = DEFAULT, + min_delay_between_sniffing: Union[DefaultType, None, float] = DEFAULT, sniffed_node_callback: Optional[ Callable[[Dict[str, Any], NodeConfig], Optional[NodeConfig]] ] = None, - meta_header=DEFAULT, + meta_header: Union[DefaultType, bool] = DEFAULT, # Deprecated - timeout=DEFAULT, - randomize_hosts=DEFAULT, + timeout: Union[DefaultType, None, float] = DEFAULT, + randomize_hosts: Union[DefaultType, bool] = DEFAULT, host_info_callback: Optional[ Callable[ [Dict[str, Any], Dict[str, Union[str, int]]], Optional[Dict[str, Union[str, int]]], ] ] = None, - sniffer_timeout=DEFAULT, - sniff_on_connection_fail=DEFAULT, - http_auth=DEFAULT, - maxsize=DEFAULT, + sniffer_timeout: Union[DefaultType, None, float] = DEFAULT, + sniff_on_connection_fail: Union[DefaultType, bool] = DEFAULT, + http_auth: Union[DefaultType, Any] = DEFAULT, + maxsize: Union[DefaultType, int] = DEFAULT, # Internal use only _transport: Optional[AsyncTransport] = None, ) -> None: @@ -303,7 +321,7 @@ def __init__( ssl_context=ssl_context, ssl_show_warn=ssl_show_warn, ) - transport_kwargs = {} + transport_kwargs: Dict[str, Any] = {} if node_class is not DEFAULT: transport_kwargs["node_class"] = node_class if node_pool_class is not DEFAULT: @@ -348,15 +366,17 @@ def __init__( # These are set per-request so are stored separately. self._request_timeout = request_timeout self._max_retries = max_retries - self._retry_on_status = retry_on_status self._retry_on_timeout = retry_on_timeout + if isinstance(retry_on_status, int): + retry_on_status = (retry_on_status,) + self._retry_on_status = retry_on_status else: super().__init__(_transport) if headers is not DEFAULT and headers is not None: self._headers.update(headers) - if opaque_id is not DEFAULT and opaque_id is not None: + if opaque_id is not DEFAULT and opaque_id is not None: # type: ignore[comparison-overlap] self._headers["x-opaque-id"] = opaque_id self._headers = resolve_auth_headers( self._headers, @@ -383,7 +403,6 @@ def __init__( self.dangling_indices = DanglingIndicesClient(self) self.enrich = EnrichClient(self) self.eql = EqlClient(self) - self.fleet = FleetClient(self) self.graph = GraphClient(self) self.ilm = IlmClient(self) self.license = LicenseClient(self) @@ -402,1974 +421,3907 @@ def __init__( self.transform = TransformClient(self) self.watcher = WatcherClient(self) - def __repr__(self): + def __repr__(self) -> str: try: # get a list of all connections - cons = self.transport.hosts + nodes = [node.base_url for node in self.transport.node_pool.all()] # truncate to 5 if there are too many - if len(cons) > 5: - cons = cons[:5] + ["..."] - return f"<{self.__class__.__name__}({cons})>" + if len(nodes) > 5: + nodes = nodes[:5] + ["..."] + return f"<{self.__class__.__name__}({nodes})>" except Exception: # probably operating on custom transport and connection_pool, ignore return super().__repr__() - async def __aenter__(self): - if hasattr(self.transport, "_async_call"): - await self.transport._async_call() + async def __aenter__(self) -> "AsyncElasticsearch": + try: + # All this to avoid a Mypy error when using unasync. + await getattr(self.transport, "_async_call")() + except AttributeError: + pass return self - async def __aexit__(self, *_): + async def __aexit__(self, *_: Any) -> None: await self.close() - async def close(self): + async def close(self) -> None: """Closes the Transport and all internal connections""" await self.transport.close() - # AUTO-GENERATED-API-DEFINITIONS # - @query_params() - async def ping(self, params=None, headers=None): + @_rewrite_parameters() + async def ping( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> bool: """ - Returns whether the cluster is running. + Returns basic information about the cluster. - ``_ + ``_ """ - client, params = _deprecated_options(self, params) + __path = "/" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} try: - await client._perform_request("HEAD", "/", params=params, headers=headers) - return True + resp = await self._perform_request("HEAD", __target, headers=__headers) + return bool(resp) except TransportError: return False - @query_params() - async def info(self, params=None, headers=None): - """ - Returns basic information about the cluster. - - ``_ - """ - client, params = _deprecated_options(self, params) - return await client._perform_request("GET", "/", params=params, headers=headers) + # AUTO-GENERATED-API-DEFINITIONS # - @query_params( - "pipeline", - "refresh", - "routing", - "timeout", - "version", - "version_type", - "wait_for_active_shards", + @_rewrite_parameters( + body_name="operations", + parameter_aliases={ + "_source": "source", + "_source_excludes": "source_excludes", + "_source_includes": "source_includes", + }, ) - async def create(self, index, id, body, doc_type=None, params=None, headers=None): + async def bulk( + self, + *, + operations: List[Any], + index: Optional[Any] = None, + type: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pipeline: Optional[str] = None, + pretty: Optional[bool] = None, + refresh: Optional[Any] = None, + require_alias: Optional[bool] = None, + routing: Optional[Any] = None, + source: Optional[Union[Any, bool]] = None, + source_excludes: Optional[Any] = None, + source_includes: Optional[Any] = None, + timeout: Optional[Any] = None, + wait_for_active_shards: Optional[Any] = None, + ) -> Any: """ - Creates a new document in the index. Returns a 409 response when a document - with a same ID already exists in the index. + Allows to perform multiple index/update/delete operations in a single request. - ``_ + ``_ - :arg index: The name of the index - :arg id: Document ID - :arg body: The document - :arg doc_type: The type of the document - :arg pipeline: The pipeline id to preprocess incoming documents - with - :arg refresh: If `true` then refresh the affected shards to make - this operation visible to search, if `wait_for` then wait for a refresh - to make this operation visible to search, if `false` (the default) then - do nothing with refreshes. Valid choices: true, false, wait_for - :arg routing: Specific routing value - :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 - :arg wait_for_active_shards: Sets the number of shard copies - that must be active before proceeding with the index operation. Defaults - to 1, meaning the primary shard only. Set to `all` for all shard copies, - otherwise set to any non-negative value less than or equal to the total - number of copies for the shard (number of replicas + 1) - """ - client, params = _deprecated_options(self, params) - for param in (index, id, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - if doc_type in SKIP_IN_PATH: - path = _make_path(index, "_create", id) + :param operations: + :param index: Default index for items which don't provide one + :param type: Default document type for items which don't provide one + :param pipeline: The pipeline id to preprocess incoming documents with + :param refresh: If `true` then refresh the affected shards to make this operation + visible to search, if `wait_for` then wait for a refresh to make this operation + visible to search, if `false` (the default) then do nothing with refreshes. + :param require_alias: Sets require_alias for all incoming documents. Defaults + to unset (false) + :param routing: Specific routing value + :param source: True or false to return the _source field or not, or default list + of fields to return, can be overridden on each sub-request + :param source_excludes: Default list of fields to exclude from the returned _source + field, can be overridden on each sub-request + :param source_includes: Default list of fields to extract and return from the + _source field, can be overridden on each sub-request + :param timeout: Explicit operation timeout + :param wait_for_active_shards: Sets the number of shard copies that must be active + before proceeding with the bulk operation. Defaults to 1, meaning the primary + shard only. Set to `all` for all shard copies, otherwise set to any non-negative + value less than or equal to the total number of copies for the shard (number + of replicas + 1) + """ + if operations is None: + raise ValueError("Empty value passed for parameter 'operations'") + if index not in SKIP_IN_PATH and type not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/{_quote(type)}/_bulk" + elif index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_bulk" + else: + __path = "/_bulk" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pipeline is not None: + __query["pipeline"] = pipeline + if pretty is not None: + __query["pretty"] = pretty + if refresh is not None: + __query["refresh"] = refresh + if require_alias is not None: + __query["require_alias"] = require_alias + if routing is not None: + __query["routing"] = routing + if source is not None: + __query["_source"] = source + if source_excludes is not None: + __query["_source_excludes"] = source_excludes + if source_includes is not None: + __query["_source_includes"] = source_includes + if timeout is not None: + __query["timeout"] = timeout + if wait_for_active_shards is not None: + __query["wait_for_active_shards"] = wait_for_active_shards + __body = operations + if __query: + __target = f"{__path}?{_quote_query(__query)}" else: - path = _make_path(index, doc_type, id, "_create") - - return await client._perform_request( - "POST" if id in SKIP_IN_PATH else "PUT", - path, - params=params, - headers=headers, - body=body, + __target = __path + __headers = { + "accept": "application/json", + "content-type": "application/x-ndjson", + } + return await self._perform_request( + "PUT", __target, headers=__headers, body=__body ) - @query_params( - "if_primary_term", - "if_seq_no", - "op_type", - "pipeline", - "refresh", - "require_alias", - "routing", - "timeout", - "version", - "version_type", - "wait_for_active_shards", + @_rewrite_parameters( + body_fields=True, ) - async def index(self, index, body, id=None, params=None, headers=None): + async def clear_scroll( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + scroll_id: Optional[Any] = None, + ) -> Any: """ - Creates or updates a document in an index. + Explicitly clears the search context for a scroll. - ``_ + ``_ - :arg index: The name of the index - :arg body: 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 - term - :arg if_seq_no: only perform the index operation if the last - operation that has changed the document has the specified sequence - number - :arg op_type: Explicit operation type. Defaults to `index` for - requests with an explicit document ID, and to `create`for requests - without an explicit document ID Valid choices: index, create - :arg pipeline: The pipeline id to preprocess incoming documents - with - :arg refresh: If `true` then refresh the affected shards to make - this operation visible to search, if `wait_for` then wait for a refresh - to make this operation visible to search, if `false` (the default) then - do nothing with refreshes. Valid choices: true, false, wait_for - :arg require_alias: When true, requires destination to be an - alias. Default is false - :arg routing: Specific routing value - :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 - :arg wait_for_active_shards: Sets the number of shard copies - that must be active before proceeding with the index operation. Defaults - to 1, meaning the primary shard only. Set to `all` for all shard copies, - otherwise set to any non-negative value less than or equal to the total - number of copies for the shard (number of replicas + 1) - """ - client, params = _deprecated_options(self, params) - for param in (index, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "POST" if id in SKIP_IN_PATH else "PUT", - _make_path(index, "_doc", id), - params=params, - headers=headers, - body=body, + :param scroll_id: + """ + __path = "/_search/scroll" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if scroll_id is not None: + __body["scroll_id"] = scroll_id + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "DELETE", __target, headers=__headers, body=__body ) - @query_params( - "_source", - "_source_excludes", - "_source_includes", - "pipeline", - "refresh", - "require_alias", - "routing", - "timeout", - "wait_for_active_shards", + @_rewrite_parameters( + body_fields=True, ) - async def bulk(self, body, index=None, doc_type=None, params=None, headers=None): + async def close_point_in_time( + self, + *, + id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Allows to perform multiple index/update/delete operations in a single request. + Close a point in time - ``_ + ``_ - :arg body: The operation definition and data (action-data - pairs), separated by newlines - :arg index: Default index for items which don't provide one - :arg doc_type: Default document type for items which don't - provide one - :arg _source: True or false to return the _source field or not, - or default list of fields to return, can be overridden on each sub- - request - :arg _source_excludes: Default list of fields to exclude from - the returned _source field, can be overridden on each sub-request - :arg _source_includes: Default list of fields to extract and - return from the _source field, can be overridden on each sub-request - :arg pipeline: The pipeline id to preprocess incoming documents - with - :arg refresh: If `true` then refresh the affected shards to make - this operation visible to search, if `wait_for` then wait for a refresh - to make this operation visible to search, if `false` (the default) then - do nothing with refreshes. Valid choices: true, false, wait_for - :arg require_alias: Sets require_alias for all incoming - documents. Defaults to unset (false) - :arg routing: Specific routing value - :arg timeout: Explicit operation timeout - :arg wait_for_active_shards: Sets the number of shard copies - that must be active before proceeding with the bulk operation. Defaults - to 1, meaning the primary shard only. Set to `all` for all shard copies, - otherwise set to any non-negative value less than or equal to the total - number of copies for the shard (number of replicas + 1) - """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - headers["content-type"] = "application/x-ndjson" - return await client._perform_request( - "POST", - _make_path(index, doc_type, "_bulk"), - params=params, - headers=headers, - body=body, + :param id: + """ + if id is None: + raise ValueError("Empty value passed for parameter 'id'") + __path = "/_pit" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if id is not None: + __body["id"] = id + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "DELETE", __target, headers=__headers, body=__body ) - @query_params() - async def clear_scroll(self, body=None, scroll_id=None, params=None, headers=None): + @_rewrite_parameters( + body_fields=True, + ) + async def count( + self, + *, + index: Optional[Any] = None, + allow_no_indices: Optional[bool] = None, + analyze_wildcard: Optional[bool] = None, + analyzer: Optional[str] = None, + default_operator: Optional[Any] = None, + df: Optional[str] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_throttled: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + lenient: Optional[bool] = None, + min_score: Optional[float] = None, + preference: Optional[str] = None, + pretty: Optional[bool] = None, + q: Optional[str] = None, + query: Optional[Any] = None, + routing: Optional[Any] = None, + terminate_after: Optional[int] = None, + ) -> Any: """ - Explicitly clears the search context for a scroll. + Returns number of documents matching a query. - ``_ + ``_ - :arg body: A comma-separated list of scroll IDs to clear if none - was specified via the scroll_id parameter - :arg scroll_id: A comma-separated list of scroll IDs to clear + :param index: A comma-separated list of indices to restrict the results + :param 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) + :param analyze_wildcard: Specify whether wildcard and prefix queries should be + analyzed (default: false) + :param analyzer: The analyzer to use for the query string + :param default_operator: The default operator for query string query (AND or + OR) + :param df: The field to use as default where no field prefix is given in the + query string + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param ignore_throttled: Whether specified concrete, expanded or aliased indices + should be ignored when throttled + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param lenient: Specify whether format-based query failures (such as providing + text to a numeric field) should be ignored + :param min_score: Include only documents with a specific `_score` value in the + result + :param preference: Specify the node or shard the operation should be performed + on (default: random) + :param q: Query in the Lucene query string syntax + :param query: + :param routing: A comma-separated list of specific routing values + :param terminate_after: The maximum count for each shard, upon reaching which + the query execution will terminate early """ - client, params = _deprecated_options(self, params) - if scroll_id in SKIP_IN_PATH and body in SKIP_IN_PATH: - raise ValueError("You need to supply scroll_id or body.") - elif scroll_id and not body: - body = {"scroll_id": [scroll_id]} - elif scroll_id: - params["scroll_id"] = scroll_id - - return await client._perform_request( - "DELETE", "/_search/scroll", params=params, headers=headers, body=body + if index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_count" + else: + __path = "/_count" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if analyze_wildcard is not None: + __query["analyze_wildcard"] = analyze_wildcard + if analyzer is not None: + __query["analyzer"] = analyzer + if default_operator is not None: + __query["default_operator"] = default_operator + if df is not None: + __query["df"] = df + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_throttled is not None: + __query["ignore_throttled"] = ignore_throttled + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if lenient is not None: + __query["lenient"] = lenient + if min_score is not None: + __query["min_score"] = min_score + if preference is not None: + __query["preference"] = preference + if pretty is not None: + __query["pretty"] = pretty + if q is not None: + __query["q"] = q + if query is not None: + __body["query"] = query + if routing is not None: + __query["routing"] = routing + if terminate_after is not None: + __query["terminate_after"] = terminate_after + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "POST", __target, headers=__headers, body=__body ) - @query_params( - "allow_no_indices", - "analyze_wildcard", - "analyzer", - "default_operator", - "df", - "expand_wildcards", - "ignore_throttled", - "ignore_unavailable", - "lenient", - "min_score", - "preference", - "q", - "routing", - "terminate_after", + @_rewrite_parameters( + body_name="document", ) - async def count(self, body=None, index=None, params=None, headers=None): + async def create( + self, + *, + index: Any, + id: Any, + document: Any, + type: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pipeline: Optional[str] = None, + pretty: Optional[bool] = None, + refresh: Optional[Any] = None, + routing: Optional[Any] = None, + timeout: Optional[Any] = None, + version: Optional[Any] = None, + version_type: Optional[Any] = None, + wait_for_active_shards: Optional[Any] = None, + ) -> Any: """ - Returns number of documents matching a query. + Creates a new document in the index. Returns a 409 response when a document with + a same ID already exists in the index. - ``_ + ``_ - :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 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 analyze_wildcard: Specify whether wildcard and prefix - queries should be analyzed (default: false) - :arg analyzer: The analyzer to use for the query string - :arg default_operator: The default operator for query string - query (AND or OR) Valid choices: AND, OR Default: OR - :arg df: The field to use as default where no field prefix is - given in the query string - :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_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 lenient: Specify whether format-based query failures (such - as providing text to a numeric field) should be ignored - :arg min_score: Include only documents with a specific `_score` - value in the result - :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 routing: A comma-separated list of specific routing values - :arg terminate_after: The maximum count for each shard, upon - reaching which the query execution will terminate early - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "POST", - _make_path(index, "_count"), - params=params, - headers=headers, - body=body, + :param index: The name of the index + :param id: Document ID + :param document: + :param type: The type of the document + :param pipeline: The pipeline id to preprocess incoming documents with + :param refresh: If `true` then refresh the affected shards to make this operation + visible to search, if `wait_for` then wait for a refresh to make this operation + visible to search, if `false` (the default) then do nothing with refreshes. + :param routing: Specific routing value + :param timeout: Explicit operation timeout + :param version: Explicit version number for concurrency control + :param version_type: Specific version type + :param wait_for_active_shards: Sets the number of shard copies that must be active + before proceeding with the index operation. Defaults to 1, meaning the primary + shard only. Set to `all` for all shard copies, otherwise set to any non-negative + value less than or equal to the total number of copies for the shard (number + of replicas + 1) + """ + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + if id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'id'") + if document is None: + raise ValueError("Empty value passed for parameter 'document'") + if ( + index not in SKIP_IN_PATH + and type not in SKIP_IN_PATH + and id not in SKIP_IN_PATH + ): + __path = f"/{_quote(index)}/{_quote(type)}/{_quote(id)}/_create" + elif index not in SKIP_IN_PATH and id not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_create/{_quote(id)}" + else: + raise ValueError("Couldn't find a path for the given parameters") + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pipeline is not None: + __query["pipeline"] = pipeline + if pretty is not None: + __query["pretty"] = pretty + if refresh is not None: + __query["refresh"] = refresh + if routing is not None: + __query["routing"] = routing + if timeout is not None: + __query["timeout"] = timeout + if version is not None: + __query["version"] = version + if version_type is not None: + __query["version_type"] = version_type + if wait_for_active_shards is not None: + __query["wait_for_active_shards"] = wait_for_active_shards + __body = document + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "PUT", __target, headers=__headers, body=__body ) - @query_params( - "if_primary_term", - "if_seq_no", - "refresh", - "routing", - "timeout", - "version", - "version_type", - "wait_for_active_shards", - ) - async def delete(self, index, id, doc_type=None, params=None, headers=None): + @_rewrite_parameters() + async def delete( + self, + *, + index: Any, + id: Any, + type: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + if_primary_term: Optional[int] = None, + if_seq_no: Optional[Any] = None, + pretty: Optional[bool] = None, + refresh: Optional[Any] = None, + routing: Optional[Any] = None, + timeout: Optional[Any] = None, + version: Optional[Any] = None, + version_type: Optional[Any] = None, + wait_for_active_shards: Optional[Any] = None, + ) -> Any: """ Removes a document from the index. ``_ - :arg index: The name of the index - :arg id: The document ID - :arg doc_type: The type of the document - :arg if_primary_term: only perform the delete operation if the - last operation that has changed the document has the specified primary - term - :arg if_seq_no: only perform the delete operation if the last - operation that has changed the document has the specified sequence - number - :arg refresh: If `true` then refresh the affected shards to make - this operation visible to search, if `wait_for` then wait for a refresh - to make this operation visible to search, if `false` (the default) then - do nothing with refreshes. Valid choices: true, false, wait_for - :arg routing: Specific routing value - :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 - :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 - shard copies, otherwise set to any non-negative value less than or equal - to the total number of copies for the shard (number of replicas + 1) - """ - client, params = _deprecated_options(self, params) - for param in (index, id): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - if doc_type in SKIP_IN_PATH: - doc_type = "_doc" - - return await client._perform_request( - "DELETE", _make_path(index, doc_type, id), params=params, headers=headers - ) - - @query_params( - "_source", - "_source_excludes", - "_source_includes", - "allow_no_indices", - "analyze_wildcard", - "analyzer", - "conflicts", - "default_operator", - "df", - "expand_wildcards", - "from_", - "ignore_unavailable", - "lenient", - "max_docs", - "preference", - "q", - "refresh", - "request_cache", - "requests_per_second", - "routing", - "scroll", - "scroll_size", - "search_timeout", - "search_type", - "slices", - "sort", - "stats", - "terminate_after", - "timeout", - "version", - "wait_for_active_shards", - "wait_for_completion", + :param index: The name of the index + :param id: The document ID + :param type: The type of the document + :param if_primary_term: only perform the delete operation if the last operation + that has changed the document has the specified primary term + :param if_seq_no: only perform the delete operation if the last operation that + has changed the document has the specified sequence number + :param refresh: If `true` then refresh the affected shards to make this operation + visible to search, if `wait_for` then wait for a refresh to make this operation + visible to search, if `false` (the default) then do nothing with refreshes. + :param routing: Specific routing value + :param timeout: Explicit operation timeout + :param version: Explicit version number for concurrency control + :param version_type: Specific version type + :param 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 shard copies, otherwise set to any non-negative + value less than or equal to the total number of copies for the shard (number + of replicas + 1) + """ + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + if id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'id'") + if ( + index not in SKIP_IN_PATH + and type not in SKIP_IN_PATH + and id not in SKIP_IN_PATH + ): + __path = f"/{_quote(index)}/{_quote(type)}/{_quote(id)}" + elif index not in SKIP_IN_PATH and id not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_doc/{_quote(id)}" + else: + raise ValueError("Couldn't find a path for the given parameters") + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if if_primary_term is not None: + __query["if_primary_term"] = if_primary_term + if if_seq_no is not None: + __query["if_seq_no"] = if_seq_no + if pretty is not None: + __query["pretty"] = pretty + if refresh is not None: + __query["refresh"] = refresh + if routing is not None: + __query["routing"] = routing + if timeout is not None: + __query["timeout"] = timeout + if version is not None: + __query["version"] = version + if version_type is not None: + __query["version_type"] = version_type + if wait_for_active_shards is not None: + __query["wait_for_active_shards"] = wait_for_active_shards + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + parameter_aliases={ + "_source": "source", + "_source_excludes": "source_excludes", + "_source_includes": "source_includes", + "from": "from_", + }, ) - async def delete_by_query(self, index, body, params=None, headers=None): + async def delete_by_query( + self, + *, + index: Any, + allow_no_indices: Optional[bool] = None, + analyze_wildcard: Optional[bool] = None, + analyzer: Optional[str] = None, + conflicts: Optional[Any] = None, + default_operator: Optional[Any] = None, + df: Optional[str] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + from_: Optional[int] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + lenient: Optional[bool] = None, + max_docs: Optional[int] = None, + preference: Optional[str] = None, + pretty: Optional[bool] = None, + q: Optional[str] = None, + query: Optional[Any] = None, + refresh: Optional[bool] = None, + request_cache: Optional[bool] = None, + requests_per_second: Optional[int] = None, + routing: Optional[Any] = None, + scroll: Optional[Any] = None, + scroll_size: Optional[int] = None, + search_timeout: Optional[Any] = None, + search_type: Optional[Any] = None, + size: Optional[int] = None, + slice: Optional[Any] = None, + slices: Optional[int] = None, + sort: Optional[List[str]] = None, + source: Optional[Union[Any, bool]] = None, + source_excludes: Optional[Any] = None, + source_includes: Optional[Any] = None, + stats: Optional[List[str]] = None, + terminate_after: Optional[int] = None, + timeout: Optional[Any] = None, + version: Optional[bool] = None, + wait_for_active_shards: Optional[Any] = None, + wait_for_completion: Optional[bool] = None, + ) -> Any: """ 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 _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 - returned _source field - :arg _source_includes: A list of fields to extract and return - from the _source field - :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 analyze_wildcard: Specify whether wildcard and prefix - queries should be analyzed (default: false) - :arg analyzer: The analyzer to use for the query string - :arg conflicts: What to do when the delete by query hits version - conflicts? Valid choices: abort, proceed Default: abort - :arg default_operator: The default operator for query string - query (AND or OR) Valid choices: AND, OR Default: OR - :arg df: The field to use as default where no field prefix is - given in the query string - :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 ignore_unavailable: Whether specified concrete indices - should be ignored when unavailable (missing or closed) - :arg lenient: Specify whether format-based query failures (such - as providing text to a numeric field) should be ignored - :arg max_docs: Maximum number of documents to process (default: - all documents) - :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 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- - requests per second. -1 means no throttle. - :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 scroll_size: Size on the scroll request powering the delete - by query Default: 100 - :arg search_timeout: Explicit timeout for each search request. - Defaults to no timeout. - :arg search_type: Search operation type Valid choices: - query_then_fetch, dfs_query_then_fetch - :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 - :arg sort: A comma-separated list of : pairs - :arg stats: Specific 'tag' of the request for logging and - statistical purposes - :arg terminate_after: The maximum number of documents to collect - for each shard, upon reaching which the query execution will terminate - early. - :arg timeout: Time each individual bulk request should wait for - shards that are unavailable. Default: 1m - :arg version: Specify whether to return document version as part - of a hit - :arg wait_for_active_shards: Sets the number of shard copies - that must be active before proceeding with the delete by query - operation. Defaults to 1, meaning the primary shard only. Set to `all` - for all shard copies, otherwise set to any non-negative value less than - or equal to the total number of copies for the shard (number of replicas - + 1) - :arg wait_for_completion: Should the request should block until - the delete by query is complete. Default: True - """ - client, params = _deprecated_options(self, params) - if params and "from_" in params: - params["from"] = params.pop("from_") - - for param in (index, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "POST", - _make_path(index, "_delete_by_query"), - params=params, - headers=headers, - body=body, + :param index: A comma-separated list of index names to search; use `_all` or + empty string to perform the operation on all indices + :param 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) + :param analyze_wildcard: Specify whether wildcard and prefix queries should be + analyzed (default: false) + :param analyzer: The analyzer to use for the query string + :param conflicts: What to do when the delete by query hits version conflicts? + :param default_operator: The default operator for query string query (AND or + OR) + :param df: The field to use as default where no field prefix is given in the + query string + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param from_: Starting offset (default: 0) + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param lenient: Specify whether format-based query failures (such as providing + text to a numeric field) should be ignored + :param max_docs: + :param preference: Specify the node or shard the operation should be performed + on (default: random) + :param q: Query in the Lucene query string syntax + :param query: + :param refresh: Should the affected indexes be refreshed? + :param request_cache: Specify if request cache should be used for this request + or not, defaults to index level setting + :param requests_per_second: The throttle for this request in sub-requests per + second. -1 means no throttle. + :param routing: A comma-separated list of specific routing values + :param scroll: Specify how long a consistent view of the index should be maintained + for scrolled search + :param scroll_size: Size on the scroll request powering the delete by query + :param search_timeout: Explicit timeout for each search request. Defaults to + no timeout. + :param search_type: Search operation type + :param size: + :param slice: + :param 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`. + :param sort: A comma-separated list of : pairs + :param source: True or false to return the _source field or not, or a list of + fields to return + :param source_excludes: A list of fields to exclude from the returned _source + field + :param source_includes: A list of fields to extract and return from the _source + field + :param stats: Specific 'tag' of the request for logging and statistical purposes + :param terminate_after: The maximum number of documents to collect for each shard, + upon reaching which the query execution will terminate early. + :param timeout: Time each individual bulk request should wait for shards that + are unavailable. + :param version: Specify whether to return document version as part of a hit + :param wait_for_active_shards: Sets the number of shard copies that must be active + before proceeding with the delete by query operation. Defaults to 1, meaning + the primary shard only. Set to `all` for all shard copies, otherwise set + to any non-negative value less than or equal to the total number of copies + for the shard (number of replicas + 1) + :param wait_for_completion: Should the request should block until the delete + by query is complete. + """ + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + __path = f"/{_quote(index)}/_delete_by_query" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if analyze_wildcard is not None: + __query["analyze_wildcard"] = analyze_wildcard + if analyzer is not None: + __query["analyzer"] = analyzer + if conflicts is not None: + __query["conflicts"] = conflicts + if default_operator is not None: + __query["default_operator"] = default_operator + if df is not None: + __query["df"] = df + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if from_ is not None: + __query["from"] = from_ + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if lenient is not None: + __query["lenient"] = lenient + if max_docs is not None: + __body["max_docs"] = max_docs + if preference is not None: + __query["preference"] = preference + if pretty is not None: + __query["pretty"] = pretty + if q is not None: + __query["q"] = q + if query is not None: + __body["query"] = query + if refresh is not None: + __query["refresh"] = refresh + if request_cache is not None: + __query["request_cache"] = request_cache + if requests_per_second is not None: + __query["requests_per_second"] = requests_per_second + if routing is not None: + __query["routing"] = routing + if scroll is not None: + __query["scroll"] = scroll + if scroll_size is not None: + __query["scroll_size"] = scroll_size + if search_timeout is not None: + __query["search_timeout"] = search_timeout + if search_type is not None: + __query["search_type"] = search_type + if size is not None: + __query["size"] = size + if slice is not None: + __body["slice"] = slice + if slices is not None: + __query["slices"] = slices + if sort is not None: + __query["sort"] = sort + if source is not None: + __query["_source"] = source + if source_excludes is not None: + __query["_source_excludes"] = source_excludes + if source_includes is not None: + __query["_source_includes"] = source_includes + if stats is not None: + __query["stats"] = stats + if terminate_after is not None: + __query["terminate_after"] = terminate_after + if timeout is not None: + __query["timeout"] = timeout + if version is not None: + __query["version"] = version + if wait_for_active_shards is not None: + __query["wait_for_active_shards"] = wait_for_active_shards + if wait_for_completion is not None: + __query["wait_for_completion"] = wait_for_completion + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "POST", __target, headers=__headers, body=__body ) - @query_params("requests_per_second") - async def delete_by_query_rethrottle(self, task_id, params=None, headers=None): + @_rewrite_parameters() + async def delete_by_query_rethrottle( + self, + *, + task_id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + requests_per_second: Optional[int] = None, + ) -> Any: """ - Changes the number of requests per second for a particular Delete By Query - operation. + 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 - floating sub-requests per second. -1 means set no throttle. + :param task_id: The task id to rethrottle + :param requests_per_second: The throttle to set on this request in floating sub-requests + per second. -1 means set no throttle. """ - client, params = _deprecated_options(self, params) if task_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'task_id'.") - - return await client._perform_request( - "POST", - _make_path("_delete_by_query", task_id, "_rethrottle"), - params=params, - headers=headers, - ) + raise ValueError("Empty value passed for parameter 'task_id'") + __path = f"/_delete_by_query/{_quote(task_id)}/_rethrottle" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if requests_per_second is not None: + __query["requests_per_second"] = requests_per_second + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) - @query_params("master_timeout", "timeout") - async def delete_script(self, id, params=None, headers=None): + @_rewrite_parameters() + async def delete_script( + self, + *, + id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ Deletes a script. ``_ - :arg id: Script ID - :arg master_timeout: Specify timeout for connection to master - :arg timeout: Explicit operation timeout + :param id: Script ID + :param master_timeout: Specify timeout for connection to master + :param timeout: Explicit operation timeout """ - client, params = _deprecated_options(self, params) if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'id'.") - - return await client._perform_request( - "DELETE", _make_path("_scripts", id), params=params, headers=headers - ) - - @query_params( - "_source", - "_source_excludes", - "_source_includes", - "preference", - "realtime", - "refresh", - "routing", - "stored_fields", - "version", - "version_type", + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/_scripts/{_quote(id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters( + parameter_aliases={ + "_source": "source", + "_source_excludes": "source_excludes", + "_source_includes": "source_includes", + }, ) - async def exists(self, index, id, params=None, headers=None): + async def exists( + self, + *, + index: Any, + id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + preference: Optional[str] = None, + pretty: Optional[bool] = None, + realtime: Optional[bool] = None, + refresh: Optional[bool] = None, + routing: Optional[Any] = None, + source: Optional[Union[Any, bool]] = None, + source_excludes: Optional[Any] = None, + source_includes: Optional[Any] = None, + stored_fields: Optional[Any] = None, + version: Optional[Any] = None, + version_type: Optional[Any] = None, + ) -> Any: """ Returns information about whether a document exists in an index. ``_ - :arg index: The name of the index - :arg id: The document ID - :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 - returned _source field - :arg _source_includes: A list of fields to extract and return - from the _source field - :arg preference: Specify the node or shard the operation should - be performed on (default: random) - :arg realtime: Specify whether to perform the operation in - realtime or search mode - :arg refresh: Refresh the shard containing the document before - performing the operation - :arg routing: Specific routing value - :arg stored_fields: A comma-separated list of stored fields to - return in the response - :arg version: Explicit version number for concurrency control - :arg version_type: Specific version type Valid choices: - internal, external, external_gte - """ - client, params = _deprecated_options(self, params) - for param in (index, id): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "HEAD", _make_path(index, "_doc", id), params=params, headers=headers - ) - - @query_params( - "_source", - "_source_excludes", - "_source_includes", - "preference", - "realtime", - "refresh", - "routing", - "version", - "version_type", + :param index: The name of the index + :param id: The document ID + :param preference: Specify the node or shard the operation should be performed + on (default: random) + :param realtime: Specify whether to perform the operation in realtime or search + mode + :param refresh: Refresh the shard containing the document before performing the + operation + :param routing: Specific routing value + :param source: True or false to return the _source field or not, or a list of + fields to return + :param source_excludes: A list of fields to exclude from the returned _source + field + :param source_includes: A list of fields to extract and return from the _source + field + :param stored_fields: A comma-separated list of stored fields to return in the + response + :param version: Explicit version number for concurrency control + :param version_type: Specific version type + """ + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + if id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/{_quote(index)}/_doc/{_quote(id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if preference is not None: + __query["preference"] = preference + if pretty is not None: + __query["pretty"] = pretty + if realtime is not None: + __query["realtime"] = realtime + if refresh is not None: + __query["refresh"] = refresh + if routing is not None: + __query["routing"] = routing + if source is not None: + __query["_source"] = source + if source_excludes is not None: + __query["_source_excludes"] = source_excludes + if source_includes is not None: + __query["_source_includes"] = source_includes + if stored_fields is not None: + __query["stored_fields"] = stored_fields + if version is not None: + __query["version"] = version + if version_type is not None: + __query["version_type"] = version_type + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("HEAD", __target, headers=__headers) + + @_rewrite_parameters( + parameter_aliases={ + "_source": "source", + "_source_excludes": "source_excludes", + "_source_includes": "source_includes", + }, ) - async def exists_source(self, index, id, doc_type=None, params=None, headers=None): + async def exists_source( + self, + *, + index: Any, + id: Any, + type: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + preference: Optional[str] = None, + pretty: Optional[bool] = None, + realtime: Optional[bool] = None, + refresh: Optional[bool] = None, + routing: Optional[Any] = None, + source: Optional[Union[Any, bool]] = None, + source_excludes: Optional[Any] = None, + source_includes: Optional[Any] = None, + version: Optional[Any] = None, + version_type: Optional[Any] = None, + ) -> Any: """ Returns information about whether a document source exists in an index. ``_ - :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 - returned _source field - :arg _source_includes: A list of fields to extract and return - from the _source field - :arg preference: Specify the node or shard the operation should - be performed on (default: random) - :arg realtime: Specify whether to perform the operation in - realtime or search mode - :arg refresh: Refresh the shard containing the document before - performing the operation - :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 - """ - client, params = _deprecated_options(self, params) - for param in (index, id): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "HEAD", - _make_path(index, doc_type, id, "_source"), - params=params, - headers=headers, - ) - - @query_params( - "_source", - "_source_excludes", - "_source_includes", - "analyze_wildcard", - "analyzer", - "default_operator", - "df", - "lenient", - "preference", - "q", - "routing", - "stored_fields", + :param index: The name of the index + :param id: The document ID + :param type: The type of the document; deprecated and optional starting with + 7.0 + :param preference: Specify the node or shard the operation should be performed + on (default: random) + :param realtime: Specify whether to perform the operation in realtime or search + mode + :param refresh: Refresh the shard containing the document before performing the + operation + :param routing: Specific routing value + :param source: True or false to return the _source field or not, or a list of + fields to return + :param source_excludes: A list of fields to exclude from the returned _source + field + :param source_includes: A list of fields to extract and return from the _source + field + :param version: Explicit version number for concurrency control + :param version_type: Specific version type + """ + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + if id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'id'") + if ( + index not in SKIP_IN_PATH + and type not in SKIP_IN_PATH + and id not in SKIP_IN_PATH + ): + __path = f"/{_quote(index)}/{_quote(type)}/{_quote(id)}/_source" + elif index not in SKIP_IN_PATH and id not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_source/{_quote(id)}" + else: + raise ValueError("Couldn't find a path for the given parameters") + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if preference is not None: + __query["preference"] = preference + if pretty is not None: + __query["pretty"] = pretty + if realtime is not None: + __query["realtime"] = realtime + if refresh is not None: + __query["refresh"] = refresh + if routing is not None: + __query["routing"] = routing + if source is not None: + __query["_source"] = source + if source_excludes is not None: + __query["_source_excludes"] = source_excludes + if source_includes is not None: + __query["_source_includes"] = source_includes + if version is not None: + __query["version"] = version + if version_type is not None: + __query["version_type"] = version_type + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("HEAD", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + parameter_aliases={ + "_source": "source", + "_source_excludes": "source_excludes", + "_source_includes": "source_includes", + }, ) - async def explain(self, index, id, body=None, params=None, headers=None): + async def explain( + self, + *, + index: Any, + id: Any, + analyze_wildcard: Optional[bool] = None, + analyzer: Optional[str] = None, + default_operator: Optional[Any] = None, + df: Optional[str] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + lenient: Optional[bool] = None, + preference: Optional[str] = None, + pretty: Optional[bool] = None, + q: Optional[str] = None, + query: Optional[Any] = None, + routing: Optional[Any] = None, + source: Optional[Union[Any, bool]] = None, + source_excludes: Optional[Any] = None, + source_includes: Optional[Any] = None, + stored_fields: Optional[Any] = None, + ) -> Any: """ 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 _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 - returned _source field - :arg _source_includes: A list of fields to extract and return - from the _source field - :arg analyze_wildcard: Specify whether wildcards and prefix - queries in the query string query should be analyzed (default: false) - :arg analyzer: The analyzer for the query string query - :arg default_operator: The default operator for query string - query (AND or OR) Valid choices: AND, OR Default: OR - :arg df: The default field for query string query (default: - _all) - :arg lenient: Specify whether format-based query failures (such - as providing text to a numeric field) should be ignored - :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 routing: Specific routing value - :arg stored_fields: A comma-separated list of stored fields to - return in the response - """ - client, params = _deprecated_options(self, params) - for param in (index, id): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "POST", - _make_path(index, "_explain", id), - params=params, - headers=headers, - body=body, + :param index: The name of the index + :param id: The document ID + :param analyze_wildcard: Specify whether wildcards and prefix queries in the + query string query should be analyzed (default: false) + :param analyzer: The analyzer for the query string query + :param default_operator: The default operator for query string query (AND or + OR) + :param df: The default field for query string query (default: _all) + :param lenient: Specify whether format-based query failures (such as providing + text to a numeric field) should be ignored + :param preference: Specify the node or shard the operation should be performed + on (default: random) + :param q: Query in the Lucene query string syntax + :param query: + :param routing: Specific routing value + :param source: True or false to return the _source field or not, or a list of + fields to return + :param source_excludes: A list of fields to exclude from the returned _source + field + :param source_includes: A list of fields to extract and return from the _source + field + :param stored_fields: A comma-separated list of stored fields to return in the + response + """ + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + if id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/{_quote(index)}/_explain/{_quote(id)}" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if analyze_wildcard is not None: + __query["analyze_wildcard"] = analyze_wildcard + if analyzer is not None: + __query["analyzer"] = analyzer + if default_operator is not None: + __query["default_operator"] = default_operator + if df is not None: + __query["df"] = df + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if lenient is not None: + __query["lenient"] = lenient + if preference is not None: + __query["preference"] = preference + if pretty is not None: + __query["pretty"] = pretty + if q is not None: + __query["q"] = q + if query is not None: + __body["query"] = query + if routing is not None: + __query["routing"] = routing + if source is not None: + __query["_source"] = source + if source_excludes is not None: + __query["_source_excludes"] = source_excludes + if source_includes is not None: + __query["_source_includes"] = source_includes + if stored_fields is not None: + __query["stored_fields"] = stored_fields + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "POST", __target, headers=__headers, body=__body ) - @query_params( - "allow_no_indices", - "expand_wildcards", - "fields", - "ignore_unavailable", - "include_unmapped", + @_rewrite_parameters( + body_fields=True, ) - async def field_caps(self, body=None, index=None, params=None, headers=None): + async def field_caps( + self, + *, + index: Optional[Any] = None, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + fields: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + include_unmapped: Optional[bool] = None, + index_filter: Optional[Any] = None, + pretty: Optional[bool] = None, + runtime_mappings: Optional[Any] = None, + ) -> Any: """ - Returns the information about the capabilities of fields among multiple - indices. + Returns the information about the capabilities of fields among multiple indices. ``_ - :arg body: An index filter specified with the Query DSL - :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 fields: A comma-separated list of field names - :arg ignore_unavailable: Whether specified concrete indices - should be ignored when unavailable (missing or closed) - :arg include_unmapped: Indicates whether unmapped fields should - be included in the response. - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "POST", - _make_path(index, "_field_caps"), - params=params, - headers=headers, - body=body, + :param index: A comma-separated list of index names; use `_all` or empty string + to perform the operation on all indices + :param 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) + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param fields: A comma-separated list of field names + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param include_unmapped: Indicates whether unmapped fields should be included + in the response. + :param index_filter: + :param runtime_mappings: + """ + if index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_field_caps" + else: + __path = "/_field_caps" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if fields is not None: + __query["fields"] = fields + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if include_unmapped is not None: + __query["include_unmapped"] = include_unmapped + if index_filter is not None: + __body["index_filter"] = index_filter + if pretty is not None: + __query["pretty"] = pretty + if runtime_mappings is not None: + __body["runtime_mappings"] = runtime_mappings + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "POST", __target, headers=__headers, body=__body ) - @query_params( - "_source", - "_source_excludes", - "_source_includes", - "preference", - "realtime", - "refresh", - "routing", - "stored_fields", - "version", - "version_type", + @_rewrite_parameters( + parameter_aliases={ + "_source": "source", + "_source_excludes": "source_excludes", + "_source_includes": "source_includes", + }, ) - async def get(self, index, id, params=None, headers=None): + async def get( + self, + *, + index: Any, + id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + preference: Optional[str] = None, + pretty: Optional[bool] = None, + realtime: Optional[bool] = None, + refresh: Optional[bool] = None, + routing: Optional[Any] = None, + source: Optional[Union[Any, bool]] = None, + source_excludes: Optional[Any] = None, + source_includes: Optional[Any] = None, + stored_fields: Optional[Any] = None, + version: Optional[Any] = None, + version_type: Optional[Any] = None, + ) -> Any: """ Returns a document. ``_ - :arg index: The name of the index - :arg id: The document ID - :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 - returned _source field - :arg _source_includes: A list of fields to extract and return - from the _source field - :arg preference: Specify the node or shard the operation should - be performed on (default: random) - :arg realtime: Specify whether to perform the operation in - realtime or search mode - :arg refresh: Refresh the shard containing the document before - performing the operation - :arg routing: Specific routing value - :arg stored_fields: A comma-separated list of stored fields to - return in the response - :arg version: Explicit version number for concurrency control - :arg version_type: Specific version type Valid choices: - internal, external, external_gte - """ - client, params = _deprecated_options(self, params) - for param in (index, id): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "GET", _make_path(index, "_doc", id), params=params, headers=headers - ) + :param index: Name of the index that contains the document. + :param id: Unique identifier of the document. + :param preference: Specifies the node or shard the operation should be performed + on. Random by default. + :param realtime: Boolean) If true, the request is real-time as opposed to near-real-time. + :param refresh: If true, Elasticsearch refreshes the affected shards to make + this operation visible to search. If false, do nothing with refreshes. + :param routing: Target the specified primary shard. + :param source: True or false to return the _source field or not, or a list of + fields to return. + :param source_excludes: A comma-separated list of source fields to exclude in + the response. + :param source_includes: A comma-separated list of source fields to include in + the response. + :param stored_fields: A comma-separated list of stored fields to return in the + response + :param version: Explicit version number for concurrency control. The specified + version must match the current version of the document for the request to + succeed. + :param version_type: Specific version type: internal, external, external_gte. + """ + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + if id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/{_quote(index)}/_doc/{_quote(id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if preference is not None: + __query["preference"] = preference + if pretty is not None: + __query["pretty"] = pretty + if realtime is not None: + __query["realtime"] = realtime + if refresh is not None: + __query["refresh"] = refresh + if routing is not None: + __query["routing"] = routing + if source is not None: + __query["_source"] = source + if source_excludes is not None: + __query["_source_excludes"] = source_excludes + if source_includes is not None: + __query["_source_includes"] = source_includes + if stored_fields is not None: + __query["stored_fields"] = stored_fields + if version is not None: + __query["version"] = version + if version_type is not None: + __query["version_type"] = version_type + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) - @query_params("master_timeout") - async def get_script(self, id, params=None, headers=None): + @_rewrite_parameters() + async def get_script( + self, + *, + id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Returns a script. ``_ - :arg id: Script ID - :arg master_timeout: Specify timeout for connection to master + :param id: Script ID + :param master_timeout: Specify timeout for connection to master """ - client, params = _deprecated_options(self, params) if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'id'.") - - return await client._perform_request( - "GET", _make_path("_scripts", id), params=params, headers=headers - ) + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/_scripts/{_quote(id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) - @query_params( - "_source", - "_source_excludes", - "_source_includes", - "preference", - "realtime", - "refresh", - "routing", - "version", - "version_type", - ) - async def get_source(self, index, id, params=None, headers=None): + @_rewrite_parameters() + async def get_script_context( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Returns the source of a document. + Returns all script contexts. - ``_ + ``_ + """ + __path = "/_script_context" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) - :arg index: The name of the index - :arg id: The document ID - :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 - returned _source field - :arg _source_includes: A list of fields to extract and return - from the _source field - :arg preference: Specify the node or shard the operation should - be performed on (default: random) - :arg realtime: Specify whether to perform the operation in - realtime or search mode - :arg refresh: Refresh the shard containing the document before - performing the operation - :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 - """ - client, params = _deprecated_options(self, params) - for param in (index, id): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "GET", _make_path(index, "_source", id), params=params, headers=headers - ) + @_rewrite_parameters() + async def get_script_languages( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: + """ + Returns available script types, languages and contexts - @query_params( - "_source", - "_source_excludes", - "_source_includes", - "preference", - "realtime", - "refresh", - "routing", - "stored_fields", + ``_ + """ + __path = "/_script_language" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + parameter_aliases={ + "_source": "source", + "_source_excludes": "source_excludes", + "_source_includes": "source_includes", + }, ) - async def mget(self, body, index=None, params=None, headers=None): + async def get_source( + self, + *, + index: Any, + id: Any, + preference: Optional[str] = None, + realtime: Optional[bool] = None, + refresh: Optional[bool] = None, + routing: Optional[Any] = None, + source: Optional[Union[Any, bool]] = None, + source_excludes: Optional[Any] = None, + source_includes: Optional[Any] = None, + stored_fields: Optional[Any] = None, + version: Optional[Any] = None, + version_type: Optional[Any] = None, + ) -> Any: """ - Allows to get multiple documents in one request. + Returns the source of a document. - ``_ + ``_ - :arg body: Document identifiers; can be either `docs` - (containing full document information) or `ids` (when index is provided - in the URL. - :arg index: The name of the index - :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 - returned _source field - :arg _source_includes: A list of fields to extract and return - from the _source field - :arg preference: Specify the node or shard the operation should - be performed on (default: random) - :arg realtime: Specify whether to perform the operation in - realtime or search mode - :arg refresh: Refresh the shard containing the document before - performing the operation - :arg routing: Specific routing value - :arg stored_fields: A comma-separated list of stored fields to - return in the response - """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return await client._perform_request( - "POST", - _make_path(index, "_mget"), - params=params, - headers=headers, - body=body, - ) + :param index: Name of the index that contains the document. + :param id: Unique identifier of the document. + :param preference: Specifies the node or shard the operation should be performed + on. Random by default. + :param realtime: Boolean) If true, the request is real-time as opposed to near-real-time. + :param refresh: If true, Elasticsearch refreshes the affected shards to make + this operation visible to search. If false, do nothing with refreshes. + :param routing: Target the specified primary shard. + :param source: True or false to return the _source field or not, or a list of + fields to return. + :param source_excludes: A comma-separated list of source fields to exclude in + the response. + :param source_includes: A comma-separated list of source fields to include in + the response. + :param stored_fields: + :param version: Explicit version number for concurrency control. The specified + version must match the current version of the document for the request to + succeed. + :param version_type: Specific version type: internal, external, external_gte. + """ + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + if id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/{_quote(index)}/_source/{_quote(id)}" + __query: Dict[str, Any] = {} + if preference is not None: + __query["preference"] = preference + if realtime is not None: + __query["realtime"] = realtime + if refresh is not None: + __query["refresh"] = refresh + if routing is not None: + __query["routing"] = routing + if source is not None: + __query["_source"] = source + if source_excludes is not None: + __query["_source_excludes"] = source_excludes + if source_includes is not None: + __query["_source_includes"] = source_includes + if stored_fields is not None: + __query["stored_fields"] = stored_fields + if version is not None: + __query["version"] = version + if version_type is not None: + __query["version_type"] = version_type + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) - @query_params( - "ccs_minimize_roundtrips", - "max_concurrent_searches", - "max_concurrent_shard_requests", - "pre_filter_shard_size", - "rest_total_hits_as_int", - "search_type", - "typed_keys", + @_rewrite_parameters( + body_name="document", ) - async def msearch(self, body, index=None, params=None, headers=None): + async def index( + self, + *, + index: Any, + document: Any, + id: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + if_primary_term: Optional[int] = None, + if_seq_no: Optional[Any] = None, + op_type: Optional[Any] = None, + pipeline: Optional[str] = None, + pretty: Optional[bool] = None, + refresh: Optional[Any] = None, + require_alias: Optional[bool] = None, + routing: Optional[Any] = None, + timeout: Optional[Any] = None, + version: Optional[Any] = None, + version_type: Optional[Any] = None, + wait_for_active_shards: Optional[Any] = None, + ) -> Any: """ - Allows to execute several search operations in one request. + Creates or updates a document in an index. - ``_ + ``_ - :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 max_concurrent_shard_requests: The number of concurrent - shard requests each sub search executes concurrently per node. This - value should be used to limit the impact of the search on the cluster in - order to limit the number of concurrent shard requests Default: 5 - :arg pre_filter_shard_size: A threshold that enforces a pre- - filter roundtrip to prefilter search shards based on query rewriting if - the number of shards the search request expands to exceeds the - threshold. This filter roundtrip can limit the number of shards - significantly if for instance a shard can not match any documents based - on its rewrite method ie. if date filters are mandatory to match but the - shard bounds and the query are disjoint. - :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, dfs_query_then_fetch - :arg typed_keys: Specify whether aggregation and suggester names - should be prefixed by their respective types in the response - """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - headers["content-type"] = "application/x-ndjson" - return await client._perform_request( - "POST", - _make_path(index, "_msearch"), - params=params, - headers=headers, - body=body, + :param index: The name of the index + :param document: + :param id: Document ID + :param if_primary_term: only perform the index operation if the last operation + that has changed the document has the specified primary term + :param if_seq_no: only perform the index operation if the last operation that + has changed the document has the specified sequence number + :param op_type: Explicit operation type. Defaults to `index` for requests with + an explicit document ID, and to `create`for requests without an explicit + document ID + :param pipeline: The pipeline id to preprocess incoming documents with + :param refresh: If `true` then refresh the affected shards to make this operation + visible to search, if `wait_for` then wait for a refresh to make this operation + visible to search, if `false` (the default) then do nothing with refreshes. + :param require_alias: When true, requires destination to be an alias. Default + is false + :param routing: Specific routing value + :param timeout: Explicit operation timeout + :param version: Explicit version number for concurrency control + :param version_type: Specific version type + :param wait_for_active_shards: Sets the number of shard copies that must be active + before proceeding with the index operation. Defaults to 1, meaning the primary + shard only. Set to `all` for all shard copies, otherwise set to any non-negative + value less than or equal to the total number of copies for the shard (number + of replicas + 1) + """ + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + if document is None: + raise ValueError("Empty value passed for parameter 'document'") + if index not in SKIP_IN_PATH and id not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_doc/{_quote(id)}" + __method = "PUT" + elif index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_doc" + __method = "POST" + else: + raise ValueError("Couldn't find a path for the given parameters") + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if if_primary_term is not None: + __query["if_primary_term"] = if_primary_term + if if_seq_no is not None: + __query["if_seq_no"] = if_seq_no + if op_type is not None: + __query["op_type"] = op_type + if pipeline is not None: + __query["pipeline"] = pipeline + if pretty is not None: + __query["pretty"] = pretty + if refresh is not None: + __query["refresh"] = refresh + if require_alias is not None: + __query["require_alias"] = require_alias + if routing is not None: + __query["routing"] = routing + if timeout is not None: + __query["timeout"] = timeout + if version is not None: + __query["version"] = version + if version_type is not None: + __query["version_type"] = version_type + if wait_for_active_shards is not None: + __query["wait_for_active_shards"] = wait_for_active_shards + __body = document + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + __method, __target, headers=__headers, body=__body ) - @query_params("master_timeout", "timeout") - async def put_script(self, id, body, context=None, params=None, headers=None): + @_rewrite_parameters() + async def info( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Creates or updates a script. - - ``_ - - :arg id: Script ID - :arg body: The document - :arg context: Context name to compile script against - :arg master_timeout: Specify timeout for connection to master - :arg timeout: Explicit operation timeout - """ - client, params = _deprecated_options(self, params) - for param in (id, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "PUT", - _make_path("_scripts", id, context), - params=params, - headers=headers, - body=body, - ) + Returns basic information about the cluster. - @query_params( - "allow_no_indices", "expand_wildcards", "ignore_unavailable", "search_type" + ``_ + """ + __path = "/" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + parameter_aliases={"_source": "source"}, + ignore_deprecated_options=True, ) - async def rank_eval(self, body, index=None, params=None, headers=None): + async def knn_search( + self, + *, + index: Any, + knn: Any, + docvalue_fields: Optional[Union[Any, List[Any]]] = None, + error_trace: Optional[bool] = None, + fields: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + routing: Optional[Any] = None, + source: Optional[Union[Any, bool]] = None, + stored_fields: Optional[Any] = None, + ) -> Any: """ - Allows to evaluate the quality of ranked search results over a set of typical - search queries + Performs a kNN search. - ``_ + ``_ - :arg body: The ranking evaluation search definition, including - search requests, document ratings and ranking metric definition. - :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 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 search_type: Search operation type Valid choices: - query_then_fetch, dfs_query_then_fetch - """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return await client._perform_request( - "POST", - _make_path(index, "_rank_eval"), - params=params, - headers=headers, - body=body, + :param index: A comma-separated list of index names to search; use `_all` or + to perform the operation on all indices + :param knn: kNN query to execute + :param docvalue_fields: The request returns doc values for field names matching + these patterns in the hits.fields property of the response. Accepts wildcard + (*) patterns. + :param fields: The request returns values for field names matching these patterns + in the hits.fields property of the response. Accepts wildcard (*) patterns. + :param routing: A comma-separated list of specific routing values + :param source: Indicates which source fields are returned for matching documents. + These fields are returned in the hits._source property of the search response. + :param stored_fields: List of stored fields to return as part of a hit. If no + fields are specified, no stored fields are included in the response. If this + field is specified, the _source parameter defaults to false. You can pass + _source: true to return both source fields and stored fields in the search + response. + """ + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + if knn is None: + raise ValueError("Empty value passed for parameter 'knn'") + __path = f"/{_quote(index)}/_knn_search" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if knn is not None: + __body["knn"] = knn + if docvalue_fields is not None: + __body["docvalue_fields"] = docvalue_fields + if error_trace is not None: + __query["error_trace"] = error_trace + if fields is not None: + __body["fields"] = fields + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if routing is not None: + __query["routing"] = routing + if source is not None: + __body["_source"] = source + if stored_fields is not None: + __body["stored_fields"] = stored_fields + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "POST", __target, headers=__headers, body=__body ) - @query_params( - "max_docs", - "refresh", - "requests_per_second", - "scroll", - "slices", - "timeout", - "wait_for_active_shards", - "wait_for_completion", + @_rewrite_parameters( + body_fields=True, + parameter_aliases={ + "_source": "source", + "_source_excludes": "source_excludes", + "_source_includes": "source_includes", + }, ) - async def reindex(self, body, params=None, headers=None): + async def mget( + self, + *, + index: Optional[Any] = None, + docs: Optional[List[Any]] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ids: Optional[List[Any]] = None, + preference: Optional[str] = None, + pretty: Optional[bool] = None, + realtime: Optional[bool] = None, + refresh: Optional[bool] = None, + routing: Optional[Any] = None, + source: Optional[Union[Any, bool]] = None, + source_excludes: Optional[Any] = None, + source_includes: Optional[Any] = None, + stored_fields: Optional[Any] = None, + ) -> Any: """ - 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. + Allows to get multiple documents in one request. - ``_ + ``_ - :arg body: The search definition using the Query DSL and the - prototype for the index request. - :arg max_docs: Maximum number of documents to process (default: - all documents) - :arg refresh: Should the affected indexes be refreshed? - :arg requests_per_second: The throttle to set on this request in - sub-requests per second. -1 means no throttle. - :arg scroll: Control how long to keep the search context alive - Default: 5m - :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 - :arg timeout: Time each individual bulk request should wait for - shards that are unavailable. Default: 1m - :arg wait_for_active_shards: Sets the number of shard copies - that must be active before proceeding with the reindex operation. - Defaults to 1, meaning the primary shard only. Set to `all` for all - shard copies, otherwise set to any non-negative value less than or equal - to the total number of copies for the shard (number of replicas + 1) - :arg wait_for_completion: Should the request should block until - the reindex is complete. Default: True - """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return await client._perform_request( - "POST", "/_reindex", params=params, headers=headers, body=body + :param index: The name of the index + :param docs: + :param ids: + :param preference: Specify the node or shard the operation should be performed + on (default: random) + :param realtime: Specify whether to perform the operation in realtime or search + mode + :param refresh: Refresh the shard containing the document before performing the + operation + :param routing: Specific routing value + :param source: True or false to return the _source field or not, or a list of + fields to return + :param source_excludes: A list of fields to exclude from the returned _source + field + :param source_includes: A list of fields to extract and return from the _source + field + :param stored_fields: A comma-separated list of stored fields to return in the + response + """ + if index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_mget" + else: + __path = "/_mget" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if docs is not None: + __body["docs"] = docs + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ids is not None: + __body["ids"] = ids + if preference is not None: + __query["preference"] = preference + if pretty is not None: + __query["pretty"] = pretty + if realtime is not None: + __query["realtime"] = realtime + if refresh is not None: + __query["refresh"] = refresh + if routing is not None: + __query["routing"] = routing + if source is not None: + __query["_source"] = source + if source_excludes is not None: + __query["_source_excludes"] = source_excludes + if source_includes is not None: + __query["_source_includes"] = source_includes + if stored_fields is not None: + __query["stored_fields"] = stored_fields + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "POST", __target, headers=__headers, body=__body ) - @query_params("requests_per_second") - async def reindex_rethrottle(self, task_id, params=None, headers=None): + @_rewrite_parameters( + body_name="searches", + ) + async def msearch( + self, + *, + searches: List[Any], + index: Optional[Any] = None, + allow_no_indices: Optional[bool] = None, + ccs_minimize_roundtrips: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_throttled: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + max_concurrent_searches: Optional[int] = None, + max_concurrent_shard_requests: Optional[int] = None, + pre_filter_shard_size: Optional[int] = None, + pretty: Optional[bool] = None, + rest_total_hits_as_int: Optional[bool] = None, + search_type: Optional[Any] = None, + typed_keys: Optional[bool] = None, + ) -> Any: """ - Changes the number of requests per second for a particular Reindex operation. + Allows to execute several search operations in one request. - ``_ + ``_ - :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. + :param searches: + :param index: Comma-separated list of data streams, indices, and index aliases + to search. + :param allow_no_indices: If false, the request returns an error if any wildcard + expression, index alias, or _all value targets only missing or closed indices. + This behavior applies even if the request targets other open indices. For + example, a request targeting foo*,bar* returns an error if an index starts + with foo but no index starts with bar. + :param ccs_minimize_roundtrips: If true, network roundtrips between the coordinating + node and remote clusters are minimized for cross-cluster search requests. + :param expand_wildcards: Type of index that wildcard expressions can match. If + the request can target data streams, this argument determines whether wildcard + expressions match hidden data streams. + :param ignore_throttled: If true, concrete, expanded or aliased indices are ignored + when frozen. + :param ignore_unavailable: If true, missing or closed indices are not included + in the response. + :param max_concurrent_searches: Maximum number of concurrent searches the multi + search API can execute. + :param max_concurrent_shard_requests: Maximum number of concurrent shard requests + that each sub-search request executes per node. + :param pre_filter_shard_size: Defines a threshold that enforces a pre-filter + roundtrip to prefilter search shards based on query rewriting if the number + of shards the search request expands to exceeds the threshold. This filter + roundtrip can limit the number of shards significantly if for instance a + shard can not match any documents based on its rewrite method i.e., if date + filters are mandatory to match but the shard bounds and the query are disjoint. + :param rest_total_hits_as_int: If true, hits.total are returned as an integer + in the response. Defaults to false, which returns an object. + :param search_type: Indicates whether global term and document frequencies should + be used when scoring returned documents. + :param typed_keys: Specifies whether aggregation and suggester names should be + prefixed by their respective types in the response. """ - client, params = _deprecated_options(self, params) - if task_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'task_id'.") - - return await client._perform_request( - "POST", - _make_path("_reindex", task_id, "_rethrottle"), - params=params, - headers=headers, + if searches is None: + raise ValueError("Empty value passed for parameter 'searches'") + if index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_msearch" + else: + __path = "/_msearch" + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if ccs_minimize_roundtrips is not None: + __query["ccs_minimize_roundtrips"] = ccs_minimize_roundtrips + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_throttled is not None: + __query["ignore_throttled"] = ignore_throttled + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if max_concurrent_searches is not None: + __query["max_concurrent_searches"] = max_concurrent_searches + if max_concurrent_shard_requests is not None: + __query["max_concurrent_shard_requests"] = max_concurrent_shard_requests + if pre_filter_shard_size is not None: + __query["pre_filter_shard_size"] = pre_filter_shard_size + if pretty is not None: + __query["pretty"] = pretty + if rest_total_hits_as_int is not None: + __query["rest_total_hits_as_int"] = rest_total_hits_as_int + if search_type is not None: + __query["search_type"] = search_type + if typed_keys is not None: + __query["typed_keys"] = typed_keys + __body = searches + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = { + "accept": "application/json", + "content-type": "application/x-ndjson", + } + return await self._perform_request( + "POST", __target, headers=__headers, body=__body ) - @query_params() - async def render_search_template( - self, body=None, id=None, params=None, headers=None - ): + @_rewrite_parameters( + body_name="search_templates", + ) + async def msearch_template( + self, + *, + search_templates: List[Any], + index: Optional[Any] = None, + ccs_minimize_roundtrips: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + max_concurrent_searches: Optional[int] = None, + pretty: Optional[bool] = None, + rest_total_hits_as_int: Optional[bool] = None, + search_type: Optional[Any] = None, + typed_keys: Optional[bool] = None, + ) -> Any: """ - Allows to use the Mustache language to pre-render a search definition. - - ``_ + Allows to execute several search template operations in one request. - :arg body: The search definition template and its params - :arg id: The id of the stored search template + ``_ + + :param search_templates: + :param index: A comma-separated list of index names to use as default + :param ccs_minimize_roundtrips: Indicates whether network round-trips should + be minimized as part of cross-cluster search requests execution + :param max_concurrent_searches: Controls the maximum number of concurrent searches + the multi search api will execute + :param rest_total_hits_as_int: Indicates whether hits.total should be rendered + as an integer or an object in the rest search response + :param search_type: Search operation type + :param typed_keys: Specify whether aggregation and suggester names should be + prefixed by their respective types in the response """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "POST", - _make_path("_render", "template", id), - params=params, - headers=headers, - body=body, + if search_templates is None: + raise ValueError("Empty value passed for parameter 'search_templates'") + if index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_msearch/template" + else: + __path = "/_msearch/template" + __query: Dict[str, Any] = {} + if ccs_minimize_roundtrips is not None: + __query["ccs_minimize_roundtrips"] = ccs_minimize_roundtrips + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if max_concurrent_searches is not None: + __query["max_concurrent_searches"] = max_concurrent_searches + if pretty is not None: + __query["pretty"] = pretty + if rest_total_hits_as_int is not None: + __query["rest_total_hits_as_int"] = rest_total_hits_as_int + if search_type is not None: + __query["search_type"] = search_type + if typed_keys is not None: + __query["typed_keys"] = typed_keys + __body = search_templates + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = { + "accept": "application/json", + "content-type": "application/x-ndjson", + } + return await self._perform_request( + "POST", __target, headers=__headers, body=__body ) - @query_params() - async def scripts_painless_execute(self, body=None, params=None, headers=None): + @_rewrite_parameters( + body_fields=True, + ) + async def mtermvectors( + self, + *, + index: Optional[Any] = None, + docs: Optional[List[Any]] = None, + error_trace: Optional[bool] = None, + field_statistics: Optional[bool] = None, + fields: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ids: Optional[List[Any]] = None, + offsets: Optional[bool] = None, + payloads: Optional[bool] = None, + positions: Optional[bool] = None, + preference: Optional[str] = None, + pretty: Optional[bool] = None, + realtime: Optional[bool] = None, + routing: Optional[Any] = None, + term_statistics: Optional[bool] = None, + version: Optional[Any] = None, + version_type: Optional[Any] = None, + ) -> Any: """ - Allows an arbitrary script to be executed and a result to be returned - - ``_ - - .. warning:: + Returns multiple termvectors in one request. - This API is **experimental** so may include breaking changes - or be removed in a future version + ``_ - :arg body: The script to execute + :param index: The index in which the document resides. + :param docs: + :param 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". + :param fields: A comma-separated list of fields to return. Applies to all returned + documents unless otherwise specified in body "params" or "docs". + :param ids: + :param offsets: Specifies if term offsets should be returned. Applies to all + returned documents unless otherwise specified in body "params" or "docs". + :param payloads: Specifies if term payloads should be returned. Applies to all + returned documents unless otherwise specified in body "params" or "docs". + :param positions: Specifies if term positions should be returned. Applies to + all returned documents unless otherwise specified in body "params" or "docs". + :param 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". + :param realtime: Specifies if requests are real-time as opposed to near-real-time + (default: true). + :param routing: Specific routing value. Applies to all returned documents unless + otherwise specified in body "params" or "docs". + :param 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". + :param version: Explicit version number for concurrency control + :param version_type: Specific version type """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "POST", - "/_scripts/painless/_execute", - params=params, - headers=headers, - body=body, + if index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_mtermvectors" + else: + __path = "/_mtermvectors" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if docs is not None: + __body["docs"] = docs + if error_trace is not None: + __query["error_trace"] = error_trace + if field_statistics is not None: + __query["field_statistics"] = field_statistics + if fields is not None: + __query["fields"] = fields + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ids is not None: + __body["ids"] = ids + if offsets is not None: + __query["offsets"] = offsets + if payloads is not None: + __query["payloads"] = payloads + if positions is not None: + __query["positions"] = positions + if preference is not None: + __query["preference"] = preference + if pretty is not None: + __query["pretty"] = pretty + if realtime is not None: + __query["realtime"] = realtime + if routing is not None: + __query["routing"] = routing + if term_statistics is not None: + __query["term_statistics"] = term_statistics + if version is not None: + __query["version"] = version + if version_type is not None: + __query["version_type"] = version_type + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "POST", __target, headers=__headers, body=__body ) - @query_params("rest_total_hits_as_int", "scroll") - async def scroll(self, body=None, scroll_id=None, params=None, headers=None): + @_rewrite_parameters() + async def open_point_in_time( + self, + *, + index: Any, + keep_alive: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Allows to retrieve a large numbers of results from a single search request. + Open a point in time that can be used in subsequent searches - ``_ + ``_ - :arg body: The scroll ID if not passed by URL or query - parameter. - :arg scroll_id: The scroll ID for scrolled search - :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 scroll: Specify how long a consistent view of the index - should be maintained for scrolled search - """ - client, params = _deprecated_options(self, params) - if scroll_id in SKIP_IN_PATH and body in SKIP_IN_PATH: - raise ValueError("You need to supply scroll_id or body.") - elif scroll_id and not body: - body = {"scroll_id": scroll_id} - elif scroll_id: - params["scroll_id"] = scroll_id - - return await client._perform_request( - "POST", "/_search/scroll", params=params, headers=headers, body=body - ) + :param index: A comma-separated list of index names to open point in time; use + `_all` or empty string to perform the operation on all indices + :param keep_alive: Specific the time to live for the point in time + """ + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + if keep_alive is None: + raise ValueError("Empty value passed for parameter 'keep_alive'") + __path = f"/{_quote(index)}/_pit" + __query: Dict[str, Any] = {} + if keep_alive is not None: + __query["keep_alive"] = keep_alive + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) - @query_params( - "_source", - "_source_excludes", - "_source_includes", - "allow_no_indices", - "allow_partial_search_results", - "analyze_wildcard", - "analyzer", - "batched_reduce_size", - "ccs_minimize_roundtrips", - "default_operator", - "df", - "docvalue_fields", - "expand_wildcards", - "explain", - "from_", - "ignore_throttled", - "ignore_unavailable", - "lenient", - "max_concurrent_shard_requests", - "min_compatible_shard_node", - "pre_filter_shard_size", - "preference", - "q", - "request_cache", - "rest_total_hits_as_int", - "routing", - "scroll", - "search_type", - "seq_no_primary_term", - "size", - "sort", - "stats", - "stored_fields", - "suggest_field", - "suggest_mode", - "suggest_size", - "suggest_text", - "terminate_after", - "timeout", - "track_scores", - "track_total_hits", - "typed_keys", - "version", + @_rewrite_parameters( + body_fields=True, ) - async def search(self, body=None, index=None, params=None, headers=None): + async def put_script( + self, + *, + id: Any, + context: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + script: Optional[Any] = None, + timeout: Optional[Any] = None, + ) -> Any: """ - Returns results matching a query. + Creates or updates a script. - ``_ + ``_ - :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 _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 - returned _source field - :arg _source_includes: A list of fields to extract and return - from the _source field - :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 allow_partial_search_results: Indicate if an error should - be returned if there is a partial search failure or timeout Default: - True - :arg analyze_wildcard: Specify whether wildcard and prefix - queries should be analyzed (default: false) - :arg analyzer: The analyzer to use for the query string - :arg batched_reduce_size: The number of shard results that - should be reduced at once on the coordinating node. This value should be - used as a protection mechanism to reduce the memory overhead per search - request if the potential number of shards in the request can be large. - Default: 512 - :arg ccs_minimize_roundtrips: Indicates whether network round- - trips should be minimized as part of cross-cluster search requests - execution Default: true - :arg default_operator: The default operator for query string - query (AND or OR) Valid choices: AND, OR Default: OR - :arg df: The field to use as default where no field prefix is - given in the query string - :arg docvalue_fields: A comma-separated list of fields to return - as the docvalue representation of a field for each hit - :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 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 - should be ignored when unavailable (missing or closed) - :arg lenient: Specify whether format-based query failures (such - as providing text to a numeric field) should be ignored - :arg max_concurrent_shard_requests: The number of concurrent - shard requests per node this search executes concurrently. This value - should be used to limit the impact of the search on the cluster in order - to limit the number of concurrent shard requests Default: 5 - :arg min_compatible_shard_node: The minimum compatible version - that all shards involved in search should have for this request to be - successful - :arg pre_filter_shard_size: A threshold that enforces a pre- - filter roundtrip to prefilter search shards based on query rewriting if - the number of shards the search request expands to exceeds the - threshold. This filter roundtrip can limit the number of shards - significantly if for instance a shard can not match any documents based - on its rewrite method ie. if date filters are mandatory to match but the - shard bounds and the query are disjoint. - :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 request_cache: Specify if request cache should be used for - this request or not, defaults to index level setting - :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, dfs_query_then_fetch - :arg seq_no_primary_term: Specify whether to return sequence - number and primary term of the last modification of each hit - :arg size: Number of hits to return (default: 10) - :arg sort: A comma-separated list of : pairs - :arg stats: Specific 'tag' of the request for logging and - statistical purposes - :arg stored_fields: A comma-separated list of stored fields to - return as part of a hit - :arg suggest_field: Specify which field to use for suggestions - :arg suggest_mode: Specify suggest mode Valid choices: missing, - popular, always Default: missing - :arg suggest_size: How many suggestions to return in response - :arg suggest_text: The source text for which the suggestions - should be returned - :arg terminate_after: The maximum number of documents to collect - for each shard, upon reaching which the query execution will terminate - early. - :arg timeout: Explicit operation timeout - :arg track_scores: Whether to calculate and return scores even - if they are not used for sorting - :arg track_total_hits: Indicate if the number of documents that - match the query should be tracked. A number can also be specified, to - accurately track the total hit count up to the number. - :arg typed_keys: Specify whether aggregation and suggester names - should be prefixed by their respective types in the response - :arg version: Specify whether to return document version as part - of a hit - """ - client, params = _deprecated_options(self, params) - if params and "from_" in params: - params["from"] = params.pop("from_") - - return await client._perform_request( - "POST", - _make_path(index, "_search"), - params=params, - headers=headers, - body=body, + :param id: Script ID + :param context: Script context + :param master_timeout: Specify timeout for connection to master + :param script: + :param timeout: Explicit operation timeout + """ + if id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'id'") + if id not in SKIP_IN_PATH and context not in SKIP_IN_PATH: + __path = f"/_scripts/{_quote(id)}/{_quote(context)}" + elif id not in SKIP_IN_PATH: + __path = f"/_scripts/{_quote(id)}" + else: + raise ValueError("Couldn't find a path for the given parameters") + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if script is not None: + __body["script"] = script + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "PUT", __target, headers=__headers, body=__body ) - @query_params( - "allow_no_indices", - "expand_wildcards", - "ignore_unavailable", - "local", - "preference", - "routing", + @_rewrite_parameters( + body_fields=True, ) - async def search_shards(self, index=None, params=None, headers=None): + async def rank_eval( + self, + *, + index: Any, + requests: List[Any], + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + metric: Optional[Any] = None, + pretty: Optional[bool] = None, + search_type: Optional[str] = None, + ) -> Any: """ - Returns information about the indices and shards that a search request would be - executed against. + Allows to evaluate the quality of ranked search results over a set of typical + search queries - ``_ + ``_ - :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 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 local: Return local information, do not retrieve the state - from master node (default: false) - :arg preference: Specify the node or shard the operation should - be performed on (default: random) - :arg routing: Specific routing value - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", _make_path(index, "_search_shards"), params=params, headers=headers + :param index: Comma-separated list of data streams, indices, and index aliases + used to limit the request. Wildcard (`*`) expressions are supported. To target + all data streams and indices in a cluster, omit this parameter or use `_all` + or `*`. + :param requests: A set of typical search requests, together with their provided + ratings. + :param allow_no_indices: If `false`, the request returns an error if any wildcard + expression, index alias, or `_all` value targets only missing or closed indices. + This behavior applies even if the request targets other open indices. For + example, a request targeting `foo*,bar*` returns an error if an index starts + with `foo` but no index starts with `bar`. + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param ignore_unavailable: If `true`, missing or closed indices are not included + in the response. + :param metric: Definition of the evaluation metric to calculate. + :param search_type: Search operation type + """ + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + if requests is None: + raise ValueError("Empty value passed for parameter 'requests'") + if index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_rank_eval" + else: + __path = "/_rank_eval" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if requests is not None: + __body["requests"] = requests + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if metric is not None: + __body["metric"] = metric + if pretty is not None: + __query["pretty"] = pretty + if search_type is not None: + __query["search_type"] = search_type + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "POST", __target, headers=__headers, body=__body ) - @query_params( - "_source", - "_source_excludes", - "_source_includes", - "if_primary_term", - "if_seq_no", - "lang", - "refresh", - "require_alias", - "retry_on_conflict", - "routing", - "timeout", - "wait_for_active_shards", + @_rewrite_parameters( + body_fields=True, ) - async def update(self, index, id, body, doc_type=None, params=None, headers=None): + async def reindex( + self, + *, + conflicts: Optional[Any] = None, + dest: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + max_docs: Optional[int] = None, + pretty: Optional[bool] = None, + refresh: Optional[bool] = None, + requests_per_second: Optional[int] = None, + require_alias: Optional[bool] = None, + script: Optional[Any] = None, + scroll: Optional[Any] = None, + size: Optional[int] = None, + slices: Optional[int] = None, + source: Optional[Any] = None, + timeout: Optional[Any] = None, + wait_for_active_shards: Optional[Any] = None, + wait_for_completion: Optional[bool] = None, + ) -> Any: """ - Updates a document with a script or partial document. + 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 index: The name of the index - :arg id: Document ID - :arg body: The request definition requires either `script` or - partial `doc` - :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 - returned _source field - :arg _source_includes: A list of fields to extract and return - from the _source field - :arg if_primary_term: only perform the update operation if the - last operation that has changed the document has the specified primary - term - :arg if_seq_no: only perform the update operation if the last - operation that has changed the document has the specified sequence - number - :arg lang: The script language (default: painless) - :arg refresh: If `true` then refresh the affected shards to make - this operation visible to search, if `wait_for` then wait for a refresh - to make this operation visible to search, if `false` (the default) then - do nothing with refreshes. Valid choices: true, false, wait_for - :arg require_alias: When true, requires destination is an alias. - Default is false - :arg retry_on_conflict: Specify how many times should the - operation be retried when a conflict occurs (default: 0) - :arg routing: Specific routing value - :arg timeout: Explicit operation timeout - :arg wait_for_active_shards: Sets the number of shard copies - that must be active before proceeding with the update operation. - Defaults to 1, meaning the primary shard only. Set to `all` for all - shard copies, otherwise set to any non-negative value less than or equal - to the total number of copies for the shard (number of replicas + 1) - """ - client, params = _deprecated_options(self, params) - for param in (index, id, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - if doc_type in SKIP_IN_PATH: - path = _make_path(index, "_update", id) + :param conflicts: + :param dest: + :param max_docs: + :param refresh: Should the affected indexes be refreshed? + :param requests_per_second: The throttle to set on this request in sub-requests + per second. -1 means no throttle. + :param require_alias: + :param script: + :param scroll: Control how long to keep the search context alive + :param size: + :param 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`. + :param source: + :param timeout: Time each individual bulk request should wait for shards that + are unavailable. + :param wait_for_active_shards: Sets the number of shard copies that must be active + before proceeding with the reindex operation. Defaults to 1, meaning the + primary shard only. Set to `all` for all shard copies, otherwise set to any + non-negative value less than or equal to the total number of copies for the + shard (number of replicas + 1) + :param wait_for_completion: Should the request should block until the reindex + is complete. + """ + __path = "/_reindex" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if conflicts is not None: + __body["conflicts"] = conflicts + if dest is not None: + __body["dest"] = dest + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if max_docs is not None: + __body["max_docs"] = max_docs + if pretty is not None: + __query["pretty"] = pretty + if refresh is not None: + __query["refresh"] = refresh + if requests_per_second is not None: + __query["requests_per_second"] = requests_per_second + if require_alias is not None: + __query["require_alias"] = require_alias + if script is not None: + __body["script"] = script + if scroll is not None: + __query["scroll"] = scroll + if size is not None: + __body["size"] = size + if slices is not None: + __query["slices"] = slices + if source is not None: + __body["source"] = source + if timeout is not None: + __query["timeout"] = timeout + if wait_for_active_shards is not None: + __query["wait_for_active_shards"] = wait_for_active_shards + if wait_for_completion is not None: + __query["wait_for_completion"] = wait_for_completion + if __query: + __target = f"{__path}?{_quote_query(__query)}" else: - path = _make_path(index, doc_type, id, "_update") - - return await client._perform_request( - "POST", path, params=params, headers=headers, body=body + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "POST", __target, headers=__headers, body=__body ) - @query_params("requests_per_second") - async def update_by_query_rethrottle(self, task_id, params=None, headers=None): + @_rewrite_parameters() + async def reindex_rethrottle( + self, + *, + task_id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + requests_per_second: Optional[int] = None, + ) -> Any: """ - Changes the number of requests per second for a particular Update By Query - operation. + 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 - floating sub-requests per second. -1 means set no throttle. + :param task_id: The task id to rethrottle + :param requests_per_second: The throttle to set on this request in floating sub-requests + per second. -1 means set no throttle. """ - client, params = _deprecated_options(self, params) if task_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'task_id'.") - - return await client._perform_request( - "POST", - _make_path("_update_by_query", task_id, "_rethrottle"), - params=params, - headers=headers, - ) + raise ValueError("Empty value passed for parameter 'task_id'") + __path = f"/_reindex/{_quote(task_id)}/_rethrottle" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if requests_per_second is not None: + __query["requests_per_second"] = requests_per_second + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) - @query_params() - async def get_script_context(self, params=None, headers=None): + @_rewrite_parameters( + body_fields=True, + ignore_deprecated_options={"params"}, + ) + async def render_search_template( + self, + *, + id: Optional[Any] = None, + error_trace: Optional[bool] = None, + file: Optional[str] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + params: Optional[Dict[str, Any]] = None, + pretty: Optional[bool] = None, + source: Optional[str] = None, + ) -> Any: """ - Returns all script contexts. + Allows to use the Mustache language to pre-render a search definition. - ``_ - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", "/_script_context", params=params, headers=headers - ) + ``_ - @query_params() - async def get_script_languages(self, params=None, headers=None): + :param id: The id of the stored search template + :param file: + :param params: + :param source: """ - Returns available script types, languages and contexts - - ``_ - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", "/_script_language", params=params, headers=headers + if id not in SKIP_IN_PATH: + __path = f"/_render/template/{_quote(id)}" + else: + __path = "/_render/template" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if file is not None: + __body["file"] = file + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if params is not None: + __body["params"] = params + if pretty is not None: + __query["pretty"] = pretty + if source is not None: + __body["source"] = source + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "POST", __target, headers=__headers, body=__body ) - @query_params( - "ccs_minimize_roundtrips", - "max_concurrent_searches", - "rest_total_hits_as_int", - "search_type", - "typed_keys", + @_rewrite_parameters( + body_fields=True, ) - async def msearch_template(self, body, index=None, params=None, headers=None): + async def scripts_painless_execute( + self, + *, + context: Optional[str] = None, + context_setup: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + script: Optional[Any] = None, + ) -> Any: """ - Allows to execute several search template operations in one request. + Allows an arbitrary script to be executed and a result to be returned - ``_ + ``_ - :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, dfs_query_then_fetch - :arg typed_keys: Specify whether aggregation and suggester names - should be prefixed by their respective types in the response - """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - headers["content-type"] = "application/x-ndjson" - return await client._perform_request( - "POST", - _make_path(index, "_msearch", "template"), - params=params, - headers=headers, - body=body, + :param context: + :param context_setup: + :param script: + """ + __path = "/_scripts/painless/_execute" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if context is not None: + __body["context"] = context + if context_setup is not None: + __body["context_setup"] = context_setup + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if script is not None: + __body["script"] = script + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "POST", __target, headers=__headers, body=__body ) - @query_params( - "field_statistics", - "fields", - "ids", - "offsets", - "payloads", - "positions", - "preference", - "realtime", - "routing", - "term_statistics", - "version", - "version_type", + @_rewrite_parameters( + body_fields=True, ) - async def mtermvectors(self, body=None, index=None, params=None, headers=None): + async def scroll( + self, + *, + scroll_id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + rest_total_hits_as_int: Optional[bool] = None, + scroll: Optional[Any] = None, + ) -> Any: """ - Returns multiple termvectors in one request. + Allows to retrieve a large numbers of results from a single search 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 - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "POST", - _make_path(index, "_mtermvectors"), - params=params, - headers=headers, - body=body, + :param scroll_id: Scroll ID of the search. + :param rest_total_hits_as_int: If true, the API response’s hit.total property + is returned as an integer. If false, the API response’s hit.total property + is returned as an object. + :param scroll: Period to retain the search context for scrolling. + """ + if scroll_id is None: + raise ValueError("Empty value passed for parameter 'scroll_id'") + __path = "/_search/scroll" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if scroll_id is not None: + __body["scroll_id"] = scroll_id + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if rest_total_hits_as_int is not None: + __query["rest_total_hits_as_int"] = rest_total_hits_as_int + if scroll is not None: + __body["scroll"] = scroll + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "POST", __target, 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", + @_rewrite_parameters( + body_fields=True, + parameter_aliases={ + "_source": "source", + "_source_excludes": "source_excludes", + "_source_includes": "source_includes", + "from": "from_", + }, ) - async def search_template(self, body, index=None, params=None, headers=None): + async def search( + self, + *, + index: Optional[Any] = None, + aggregations: Optional[Dict[str, Any]] = None, + allow_no_indices: Optional[bool] = None, + allow_partial_search_results: Optional[bool] = None, + analyze_wildcard: Optional[bool] = None, + analyzer: Optional[str] = None, + batched_reduce_size: Optional[int] = None, + ccs_minimize_roundtrips: Optional[bool] = None, + collapse: Optional[Any] = None, + default_operator: Optional[Any] = None, + df: Optional[str] = None, + docvalue_fields: Optional[Union[Any, List[Any]]] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + explain: Optional[bool] = None, + fields: Optional[List[Any]] = None, + filter_path: Optional[Union[List[str], str]] = None, + from_: Optional[int] = None, + highlight: Optional[Any] = None, + human: Optional[bool] = None, + ignore_throttled: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + indices_boost: Optional[List[Dict[Any, float]]] = None, + lenient: Optional[bool] = None, + max_concurrent_shard_requests: Optional[int] = None, + min_compatible_shard_node: Optional[Any] = None, + min_score: Optional[float] = None, + pit: Optional[Any] = None, + post_filter: Optional[Any] = None, + pre_filter_shard_size: Optional[int] = None, + preference: Optional[str] = None, + pretty: Optional[bool] = None, + profile: Optional[bool] = None, + q: Optional[str] = None, + query: Optional[Any] = None, + request_cache: Optional[bool] = None, + rescore: Optional[Union[Any, List[Any]]] = None, + rest_total_hits_as_int: Optional[bool] = None, + routing: Optional[Any] = None, + runtime_mappings: Optional[Any] = None, + script_fields: Optional[Dict[str, Any]] = None, + scroll: Optional[Any] = None, + search_after: Optional[Any] = None, + search_type: Optional[Any] = None, + seq_no_primary_term: Optional[bool] = None, + size: Optional[int] = None, + slice: Optional[Any] = None, + sort: Optional[Any] = None, + source: Optional[Union[Any, bool]] = None, + source_excludes: Optional[Any] = None, + source_includes: Optional[Any] = None, + stats: Optional[List[str]] = None, + stored_fields: Optional[Any] = None, + suggest: Optional[Union[Any, Dict[str, Any]]] = None, + suggest_field: Optional[Any] = None, + suggest_mode: Optional[Any] = None, + suggest_size: Optional[int] = None, + suggest_text: Optional[str] = None, + terminate_after: Optional[int] = None, + timeout: Optional[str] = None, + track_scores: Optional[bool] = None, + track_total_hits: Optional[Union[bool, int]] = None, + typed_keys: Optional[bool] = None, + version: Optional[bool] = None, + ) -> Any: """ - Allows to use the Mustache language to pre-render a search definition. + Returns results matching a query. - ``_ + ``_ - :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, dfs_query_then_fetch - :arg typed_keys: Specify whether aggregation and suggester names - should be prefixed by their respective types in the response - """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return await client._perform_request( - "POST", - _make_path(index, "_search", "template"), - params=params, - headers=headers, - body=body, + :param index: A comma-separated list of index names to search; use `_all` or + empty string to perform the operation on all indices + :param aggregations: + :param 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) + :param allow_partial_search_results: Indicate if an error should be returned + if there is a partial search failure or timeout + :param analyze_wildcard: Specify whether wildcard and prefix queries should be + analyzed (default: false) + :param analyzer: The analyzer to use for the query string + :param batched_reduce_size: The number of shard results that should be reduced + at once on the coordinating node. This value should be used as a protection + mechanism to reduce the memory overhead per search request if the potential + number of shards in the request can be large. + :param ccs_minimize_roundtrips: Indicates whether network round-trips should + be minimized as part of cross-cluster search requests execution + :param collapse: + :param default_operator: The default operator for query string query (AND or + OR) + :param df: The field to use as default where no field prefix is given in the + query string + :param docvalue_fields: Array of wildcard (*) patterns. The request returns doc + values for field names matching these patterns in the hits.fields property + of the response. + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param explain: If true, returns detailed information about score computation + as part of a hit. + :param fields: Array of wildcard (*) patterns. The request returns values for + field names matching these patterns in the hits.fields property of the response. + :param from_: Starting document offset. By default, you cannot page through more + than 10,000 hits using the from and size parameters. To page through more + hits, use the search_after parameter. + :param highlight: + :param ignore_throttled: Whether specified concrete, expanded or aliased indices + should be ignored when throttled + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param indices_boost: Boosts the _score of documents from specified indices. + :param lenient: Specify whether format-based query failures (such as providing + text to a numeric field) should be ignored + :param max_concurrent_shard_requests: The number of concurrent shard requests + per node this search executes concurrently. This value should be used to + limit the impact of the search on the cluster in order to limit the number + of concurrent shard requests + :param min_compatible_shard_node: The minimum compatible version that all shards + involved in search should have for this request to be successful + :param min_score: Minimum _score for matching documents. Documents with a lower + _score are not included in the search results. + :param pit: Limits the search to a point in time (PIT). If you provide a PIT, + you cannot specify an in the request path. + :param post_filter: + :param pre_filter_shard_size: A threshold that enforces a pre-filter roundtrip + to prefilter search shards based on query rewriting if the number of shards + the search request expands to exceeds the threshold. This filter roundtrip + can limit the number of shards significantly if for instance a shard can + not match any documents based on its rewrite method ie. if date filters are + mandatory to match but the shard bounds and the query are disjoint. + :param preference: Specify the node or shard the operation should be performed + on (default: random) + :param profile: + :param q: Query in the Lucene query string syntax + :param query: Defines the search definition using the Query DSL. + :param request_cache: Specify if request cache should be used for this request + or not, defaults to index level setting + :param rescore: + :param rest_total_hits_as_int: Indicates whether hits.total should be rendered + as an integer or an object in the rest search response + :param routing: A comma-separated list of specific routing values + :param runtime_mappings: Defines one or more runtime fields in the search request. + These fields take precedence over mapped fields with the same name. + :param script_fields: Retrieve a script evaluation (based on different fields) + for each hit. + :param scroll: Specify how long a consistent view of the index should be maintained + for scrolled search + :param search_after: + :param search_type: Search operation type + :param seq_no_primary_term: If true, returns sequence number and primary term + of the last modification of each hit. See Optimistic concurrency control. + :param size: The number of hits to return. By default, you cannot page through + more than 10,000 hits using the from and size parameters. To page through + more hits, use the search_after parameter. + :param slice: + :param sort: + :param source: Indicates which source fields are returned for matching documents. + These fields are returned in the hits._source property of the search response. + :param source_excludes: A list of fields to exclude from the returned _source + field + :param source_includes: A list of fields to extract and return from the _source + field + :param stats: Stats groups to associate with the search. Each group maintains + a statistics aggregation for its associated searches. You can retrieve these + stats using the indices stats API. + :param stored_fields: List of stored fields to return as part of a hit. If no + fields are specified, no stored fields are included in the response. If this + field is specified, the _source parameter defaults to false. You can pass + _source: true to return both source fields and stored fields in the search + response. + :param suggest: + :param suggest_field: Specifies which field to use for suggestions. + :param suggest_mode: Specify suggest mode + :param suggest_size: How many suggestions to return in response + :param suggest_text: The source text for which the suggestions should be returned. + :param terminate_after: Maximum number of documents to collect for each shard. + If a query reaches this limit, Elasticsearch terminates the query early. + Elasticsearch collects documents before sorting. Defaults to 0, which does + not terminate query execution early. + :param timeout: Specifies the period of time to wait for a response from each + shard. If no response is received before the timeout expires, the request + fails and returns an error. Defaults to no timeout. + :param track_scores: If true, calculate and return document scores, even if the + scores are not used for sorting. + :param track_total_hits: Number of hits matching the query to count accurately. + If true, the exact number of hits is returned at the cost of some performance. + If false, the response does not include the total number of hits matching + the query. Defaults to 10,000 hits. + :param typed_keys: Specify whether aggregation and suggester names should be + prefixed by their respective types in the response + :param version: If true, returns document version as part of a hit. + """ + if index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_search" + else: + __path = "/_search" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if aggregations is not None: + __body["aggregations"] = aggregations + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if allow_partial_search_results is not None: + __query["allow_partial_search_results"] = allow_partial_search_results + if analyze_wildcard is not None: + __query["analyze_wildcard"] = analyze_wildcard + if analyzer is not None: + __query["analyzer"] = analyzer + if batched_reduce_size is not None: + __query["batched_reduce_size"] = batched_reduce_size + if ccs_minimize_roundtrips is not None: + __query["ccs_minimize_roundtrips"] = ccs_minimize_roundtrips + if collapse is not None: + __body["collapse"] = collapse + if default_operator is not None: + __query["default_operator"] = default_operator + if df is not None: + __query["df"] = df + if docvalue_fields is not None: + __body["docvalue_fields"] = docvalue_fields + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if explain is not None: + __body["explain"] = explain + if fields is not None: + __body["fields"] = fields + if filter_path is not None: + __query["filter_path"] = filter_path + if from_ is not None: + __body["from"] = from_ + if highlight is not None: + __body["highlight"] = highlight + if human is not None: + __query["human"] = human + if ignore_throttled is not None: + __query["ignore_throttled"] = ignore_throttled + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if indices_boost is not None: + __body["indices_boost"] = indices_boost + if lenient is not None: + __query["lenient"] = lenient + if max_concurrent_shard_requests is not None: + __query["max_concurrent_shard_requests"] = max_concurrent_shard_requests + if min_compatible_shard_node is not None: + __query["min_compatible_shard_node"] = min_compatible_shard_node + if min_score is not None: + __body["min_score"] = min_score + if pit is not None: + __body["pit"] = pit + if post_filter is not None: + __body["post_filter"] = post_filter + if pre_filter_shard_size is not None: + __query["pre_filter_shard_size"] = pre_filter_shard_size + if preference is not None: + __query["preference"] = preference + if pretty is not None: + __query["pretty"] = pretty + if profile is not None: + __body["profile"] = profile + if q is not None: + __query["q"] = q + if query is not None: + __body["query"] = query + if request_cache is not None: + __query["request_cache"] = request_cache + if rescore is not None: + __body["rescore"] = rescore + if rest_total_hits_as_int is not None: + __query["rest_total_hits_as_int"] = rest_total_hits_as_int + if routing is not None: + __query["routing"] = routing + if runtime_mappings is not None: + __body["runtime_mappings"] = runtime_mappings + if script_fields is not None: + __body["script_fields"] = script_fields + if scroll is not None: + __query["scroll"] = scroll + if search_after is not None: + __body["search_after"] = search_after + if search_type is not None: + __query["search_type"] = search_type + if seq_no_primary_term is not None: + __body["seq_no_primary_term"] = seq_no_primary_term + if size is not None: + __body["size"] = size + if slice is not None: + __body["slice"] = slice + if sort is not None: + __body["sort"] = sort + if source is not None: + __body["_source"] = source + if source_excludes is not None: + __query["_source_excludes"] = source_excludes + if source_includes is not None: + __query["_source_includes"] = source_includes + if stats is not None: + __body["stats"] = stats + if stored_fields is not None: + __body["stored_fields"] = stored_fields + if suggest is not None: + __body["suggest"] = suggest + if suggest_field is not None: + __query["suggest_field"] = suggest_field + if suggest_mode is not None: + __query["suggest_mode"] = suggest_mode + if suggest_size is not None: + __query["suggest_size"] = suggest_size + if suggest_text is not None: + __query["suggest_text"] = suggest_text + if terminate_after is not None: + __body["terminate_after"] = terminate_after + if timeout is not None: + __body["timeout"] = timeout + if track_scores is not None: + __body["track_scores"] = track_scores + if track_total_hits is not None: + __body["track_total_hits"] = track_total_hits + if typed_keys is not None: + __query["typed_keys"] = typed_keys + if version is not None: + __body["version"] = version + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "POST", __target, headers=__headers, body=__body ) - @query_params( - "field_statistics", - "fields", - "offsets", - "payloads", - "positions", - "preference", - "realtime", - "routing", - "term_statistics", - "version", - "version_type", + @_rewrite_parameters( + body_fields=True, ) - async def termvectors(self, index, body=None, id=None, params=None, headers=None): + async def search_mvt( + self, + *, + index: Any, + field: Any, + zoom: Any, + x: Any, + y: Any, + aggs: Optional[Dict[str, Any]] = None, + error_trace: Optional[bool] = None, + exact_bounds: Optional[bool] = None, + extent: Optional[int] = None, + fields: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + grid_precision: Optional[int] = None, + grid_type: Optional[Any] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + query: Optional[Any] = None, + runtime_mappings: Optional[Any] = None, + size: Optional[int] = None, + sort: Optional[Any] = None, + ) -> Any: """ - Returns information and statistics about terms in the fields of a particular - document. + Searches a vector tile for geospatial values. Returns results as a binary Mapbox + vector tile. - ``_ + ``_ - :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 - """ - client, params = _deprecated_options(self, params) + :param index: Comma-separated list of data streams, indices, or aliases to search + :param field: Field containing geospatial data to return + :param zoom: Zoom level for the vector tile to search + :param x: X coordinate for the vector tile to search + :param y: Y coordinate for the vector tile to search + :param aggs: Sub-aggregations for the geotile_grid. Supports the following aggregation + types: - avg - cardinality - max - min - sum + :param exact_bounds: If false, the meta layer’s feature is the bounding box of + the tile. If true, the meta layer’s feature is a bounding box resulting from + a geo_bounds aggregation. The aggregation runs on values that intersect + the // tile with wrap_longitude set to false. The resulting bounding + box may be larger than the vector tile. + :param extent: Size, in pixels, of a side of the tile. Vector tiles are square + with equal sides. + :param fields: Fields to return in the `hits` layer. Supports wildcards (`*`). + This parameter does not support fields with array values. Fields with array + values may return inconsistent results. + :param grid_precision: Additional zoom levels available through the aggs layer. + For example, if is 7 and grid_precision is 8, you can zoom in up to + level 15. Accepts 0-8. If 0, results don’t include the aggs layer. + :param grid_type: Determines the geometry type for features in the aggs layer. + In the aggs layer, each feature represents a geotile_grid cell. If 'grid' + each feature is a Polygon of the cells bounding box. If 'point' each feature + is a Point that is the centroid of the cell. + :param query: Query DSL used to filter documents for the search. + :param runtime_mappings: Defines one or more runtime fields in the search request. + These fields take precedence over mapped fields with the same name. + :param size: Maximum number of features to return in the hits layer. Accepts + 0-10000. If 0, results don’t include the hits layer. + :param sort: Sorts features in the hits layer. By default, the API calculates + a bounding box for each feature. It sorts features based on this box’s diagonal + length, from longest to shortest. + """ if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return await client._perform_request( - "POST", - _make_path(index, "_termvectors", id), - params=params, - headers=headers, - body=body, + raise ValueError("Empty value passed for parameter 'index'") + if field in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'field'") + if zoom in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'zoom'") + if x in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'x'") + if y in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'y'") + __path = f"/{_quote(index)}/_mvt/{_quote(field)}/{_quote(zoom)}/{_quote(x)}/{_quote(y)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if aggs is not None: + __body["aggs"] = aggs + if error_trace is not None: + __query["error_trace"] = error_trace + if exact_bounds is not None: + __body["exact_bounds"] = exact_bounds + if extent is not None: + __body["extent"] = extent + if fields is not None: + __body["fields"] = fields + if filter_path is not None: + __query["filter_path"] = filter_path + if grid_precision is not None: + __body["grid_precision"] = grid_precision + if grid_type is not None: + __body["grid_type"] = grid_type + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if query is not None: + __body["query"] = query + if runtime_mappings is not None: + __body["runtime_mappings"] = runtime_mappings + if size is not None: + __body["size"] = size + if sort is not None: + __body["sort"] = sort + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/vnd.mapbox-vector-tile"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "POST", __target, headers=__headers, body=__body ) - @query_params( - "_source", - "_source_excludes", - "_source_includes", - "allow_no_indices", - "analyze_wildcard", - "analyzer", - "conflicts", - "default_operator", - "df", - "expand_wildcards", - "from_", - "ignore_unavailable", - "lenient", - "max_docs", - "pipeline", - "preference", - "q", - "refresh", - "request_cache", - "requests_per_second", - "routing", - "scroll", - "scroll_size", - "search_timeout", - "search_type", - "slices", - "sort", - "stats", - "terminate_after", - "timeout", - "version", - "version_type", - "wait_for_active_shards", - "wait_for_completion", - ) - async def update_by_query(self, index, body=None, params=None, headers=None): + @_rewrite_parameters() + async def search_shards( + self, + *, + index: Optional[Any] = None, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + local: Optional[bool] = None, + preference: Optional[str] = None, + pretty: Optional[bool] = None, + routing: Optional[Any] = None, + ) -> Any: """ - Performs an update on every document in the index without changing the source, - for example to pick up a mapping change. + 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 - :arg body: The search definition using the Query DSL - :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 - returned _source field - :arg _source_includes: A list of fields to extract and return - from the _source field - :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 analyze_wildcard: Specify whether wildcard and prefix - queries should be analyzed (default: false) - :arg analyzer: The analyzer to use for the query string - :arg conflicts: What to do when the update by query hits version - conflicts? Valid choices: abort, proceed Default: abort - :arg default_operator: The default operator for query string - query (AND or OR) Valid choices: AND, OR Default: OR - :arg df: The field to use as default where no field prefix is - given in the query string - :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 ignore_unavailable: Whether specified concrete indices - should be ignored when unavailable (missing or closed) - :arg lenient: Specify whether format-based query failures (such - as providing text to a numeric field) should be ignored - :arg max_docs: Maximum number of documents to process (default: - all documents) - :arg pipeline: Ingest pipeline to set on index requests made by - this action. (default: none) - :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 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 to set on this request in - sub-requests per second. -1 means no throttle. - :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 scroll_size: Size on the scroll request powering the update - by query Default: 100 - :arg search_timeout: Explicit timeout for each search request. - Defaults to no timeout. - :arg search_type: Search operation type Valid choices: - query_then_fetch, dfs_query_then_fetch - :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 - :arg sort: A comma-separated list of : pairs - :arg stats: Specific 'tag' of the request for logging and - statistical purposes - :arg terminate_after: The maximum number of documents to collect - for each shard, upon reaching which the query execution will terminate - early. - :arg timeout: Time each individual bulk request should wait for - shards that are unavailable. Default: 1m - :arg version: Specify whether to return document version as part - of a hit - :arg version_type: Should the document increment the version - number (internal) on hit or not (reindex) - :arg wait_for_active_shards: Sets the number of shard copies - that must be active before proceeding with the update by query - operation. Defaults to 1, meaning the primary shard only. Set to `all` - for all shard copies, otherwise set to any non-negative value less than - or equal to the total number of copies for the shard (number of replicas - + 1) - :arg wait_for_completion: Should the request should block until - the update by query operation is complete. Default: True - """ - client, params = _deprecated_options(self, params) - if params and "from_" in params: - params["from"] = params.pop("from_") + ``_ - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return await client._perform_request( - "POST", - _make_path(index, "_update_by_query"), - params=params, - headers=headers, - body=body, - ) + :param index: A comma-separated list of index names to search; use `_all` or + empty string to perform the operation on all indices + :param 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) + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param local: Return local information, do not retrieve the state from master + node (default: false) + :param preference: Specify the node or shard the operation should be performed + on (default: random) + :param routing: Specific routing value + """ + if index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_search_shards" + else: + __path = "/_search_shards" + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if local is not None: + __query["local"] = local + if preference is not None: + __query["preference"] = preference + if pretty is not None: + __query["pretty"] = pretty + if routing is not None: + __query["routing"] = routing + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) - @query_params() - async def close_point_in_time(self, body=None, params=None, headers=None): + @_rewrite_parameters( + body_fields=True, + ignore_deprecated_options={"params"}, + ) + async def search_template( + self, + *, + index: Optional[Any] = None, + allow_no_indices: Optional[bool] = None, + ccs_minimize_roundtrips: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + explain: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + id: Optional[Any] = None, + ignore_throttled: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + params: Optional[Dict[str, Any]] = None, + preference: Optional[str] = None, + pretty: Optional[bool] = None, + profile: Optional[bool] = None, + rest_total_hits_as_int: Optional[bool] = None, + routing: Optional[Any] = None, + scroll: Optional[Any] = None, + search_type: Optional[Any] = None, + source: Optional[str] = None, + typed_keys: Optional[bool] = None, + ) -> Any: """ - Close a point in time + Allows to use the Mustache language to pre-render a search definition. - ``_ + ``_ + + :param index: Comma-separated list of data streams, indices, and aliases to search. + Supports wildcards (*). + :param 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) + :param ccs_minimize_roundtrips: Indicates whether network round-trips should + be minimized as part of cross-cluster search requests execution + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param explain: + :param id: ID of the search template to use. If no source is specified, this + parameter is required. + :param ignore_throttled: Whether specified concrete, expanded or aliased indices + should be ignored when throttled + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param params: + :param preference: Specify the node or shard the operation should be performed + on (default: random) + :param profile: + :param rest_total_hits_as_int: If true, hits.total are rendered as an integer + in the response. + :param routing: Custom value used to route operations to a specific shard. + :param scroll: Specifies how long a consistent view of the index should be maintained + for scrolled search. + :param search_type: The type of the search operation. + :param source: An inline search template. Supports the same parameters as the + search API's request body. Also supports Mustache variables. If no id is + specified, this parameter is required. + :param typed_keys: Specify whether aggregation and suggester names should be + prefixed by their respective types in the response + """ + if index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_search/template" + else: + __path = "/_search/template" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if ccs_minimize_roundtrips is not None: + __query["ccs_minimize_roundtrips"] = ccs_minimize_roundtrips + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if explain is not None: + __body["explain"] = explain + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if id is not None: + __body["id"] = id + if ignore_throttled is not None: + __query["ignore_throttled"] = ignore_throttled + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if params is not None: + __body["params"] = params + if preference is not None: + __query["preference"] = preference + if pretty is not None: + __query["pretty"] = pretty + if profile is not None: + __body["profile"] = profile + if rest_total_hits_as_int is not None: + __query["rest_total_hits_as_int"] = rest_total_hits_as_int + if routing is not None: + __query["routing"] = routing + if scroll is not None: + __query["scroll"] = scroll + if search_type is not None: + __query["search_type"] = search_type + if source is not None: + __body["source"] = source + if typed_keys is not None: + __query["typed_keys"] = typed_keys + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "POST", __target, headers=__headers, body=__body + ) - :arg body: a point-in-time id to close + @_rewrite_parameters( + body_fields=True, + ) + async def terms_enum( + self, + *, + index: Any, + field: Any, + case_insensitive: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + index_filter: Optional[Any] = None, + pretty: Optional[bool] = None, + search_after: Optional[str] = None, + size: Optional[int] = None, + string: Optional[str] = None, + timeout: Optional[Any] = None, + ) -> Any: """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "DELETE", "/_pit", params=params, headers=headers, body=body + The terms enum API can be used to discover terms in the index that begin with + the provided string. It is designed for low-latency look-ups used in auto-complete + scenarios. + + ``_ + + :param index: Comma-separated list of data streams, indices, and index aliases + to search. Wildcard (*) expressions are supported. + :param field: The string to match at the start of indexed terms. If not provided, + all terms in the field are considered. + :param case_insensitive: When true the provided search string is matched against + index terms without case sensitivity. + :param index_filter: Allows to filter an index shard if the provided query rewrites + to match_none. + :param search_after: + :param size: How many matching terms to return. + :param string: The string after which terms in the index should be returned. + Allows for a form of pagination if the last result from one request is passed + as the search_after parameter for a subsequent request. + :param timeout: The maximum length of time to spend collecting results. Defaults + to "1s" (one second). If the timeout is exceeded the complete flag set to + false in the response and the results may be partial or empty. + """ + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + if field is None: + raise ValueError("Empty value passed for parameter 'field'") + __path = f"/{_quote(index)}/_terms_enum" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if field is not None: + __body["field"] = field + if case_insensitive is not None: + __body["case_insensitive"] = case_insensitive + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if index_filter is not None: + __body["index_filter"] = index_filter + if pretty is not None: + __query["pretty"] = pretty + if search_after is not None: + __body["search_after"] = search_after + if size is not None: + __body["size"] = size + if string is not None: + __body["string"] = string + if timeout is not None: + __body["timeout"] = timeout + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "POST", __target, headers=__headers, body=__body ) - @query_params( - "expand_wildcards", "ignore_unavailable", "keep_alive", "preference", "routing" + @_rewrite_parameters( + body_fields=True, ) - async def open_point_in_time(self, index, params=None, headers=None): + async def termvectors( + self, + *, + index: Any, + id: Optional[Any] = None, + doc: Optional[Any] = None, + error_trace: Optional[bool] = None, + field_statistics: Optional[bool] = None, + fields: Optional[Any] = None, + filter: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + offsets: Optional[bool] = None, + payloads: Optional[bool] = None, + per_field_analyzer: Optional[Dict[Any, str]] = None, + positions: Optional[bool] = None, + preference: Optional[str] = None, + pretty: Optional[bool] = None, + realtime: Optional[bool] = None, + routing: Optional[Any] = None, + term_statistics: Optional[bool] = None, + version: Optional[Any] = None, + version_type: Optional[Any] = None, + ) -> Any: """ - Open a point in time that can be used in subsequent searches + Returns information and statistics about terms in the fields of a particular + document. - ``_ + ``_ - :arg index: A comma-separated list of index names to open point - in time; use `_all` or empty string to perform the operation on all - indices - :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 keep_alive: Specific the time to live for the point in time - :arg preference: Specify the node or shard the operation should - be performed on (default: random) - :arg routing: Specific routing value - """ - client, params = _deprecated_options(self, params) + :param index: The index in which the document resides. + :param id: The id of the document, when not specified a doc param should be supplied. + :param doc: + :param field_statistics: Specifies if document count, sum of document frequencies + and sum of total term frequencies should be returned. + :param fields: A comma-separated list of fields to return. + :param filter: + :param offsets: Specifies if term offsets should be returned. + :param payloads: Specifies if term payloads should be returned. + :param per_field_analyzer: + :param positions: Specifies if term positions should be returned. + :param preference: Specify the node or shard the operation should be performed + on (default: random). + :param realtime: Specifies if request is real-time as opposed to near-real-time + (default: true). + :param routing: Specific routing value. + :param term_statistics: Specifies if total term frequency and document frequency + should be returned. + :param version: Explicit version number for concurrency control + :param version_type: Specific version type + """ if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return await client._perform_request( - "POST", _make_path(index, "_pit"), params=params, headers=headers + raise ValueError("Empty value passed for parameter 'index'") + if index not in SKIP_IN_PATH and id not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_termvectors/{_quote(id)}" + elif index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_termvectors" + else: + raise ValueError("Couldn't find a path for the given parameters") + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if doc is not None: + __body["doc"] = doc + if error_trace is not None: + __query["error_trace"] = error_trace + if field_statistics is not None: + __query["field_statistics"] = field_statistics + if fields is not None: + __query["fields"] = fields + if filter is not None: + __body["filter"] = filter + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if offsets is not None: + __query["offsets"] = offsets + if payloads is not None: + __query["payloads"] = payloads + if per_field_analyzer is not None: + __body["per_field_analyzer"] = per_field_analyzer + if positions is not None: + __query["positions"] = positions + if preference is not None: + __query["preference"] = preference + if pretty is not None: + __query["pretty"] = pretty + if realtime is not None: + __query["realtime"] = realtime + if routing is not None: + __query["routing"] = routing + if term_statistics is not None: + __query["term_statistics"] = term_statistics + if version is not None: + __query["version"] = version + if version_type is not None: + __query["version_type"] = version_type + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "POST", __target, headers=__headers, body=__body ) - @query_params() - async def terms_enum(self, index, body=None, params=None, headers=None): + @_rewrite_parameters( + body_fields=True, + parameter_aliases={ + "_source": "source", + "_source_excludes": "source_excludes", + "_source_includes": "source_includes", + }, + ) + async def update( + self, + *, + index: Any, + id: Any, + type: Optional[Any] = None, + detect_noop: Optional[bool] = None, + doc: Optional[Any] = None, + doc_as_upsert: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + if_primary_term: Optional[int] = None, + if_seq_no: Optional[Any] = None, + lang: Optional[str] = None, + pretty: Optional[bool] = None, + refresh: Optional[Any] = None, + require_alias: Optional[bool] = None, + retry_on_conflict: Optional[int] = None, + routing: Optional[Any] = None, + script: Optional[Any] = None, + scripted_upsert: Optional[bool] = None, + source: Optional[Union[Any, bool]] = None, + source_excludes: Optional[Any] = None, + source_includes: Optional[Any] = None, + timeout: Optional[Any] = None, + upsert: Optional[Any] = None, + wait_for_active_shards: Optional[Any] = None, + ) -> Any: """ - The terms enum API can be used to discover terms in the index that begin with - the provided string. It is designed for low-latency look-ups used in auto- - complete scenarios. + Updates a document with a script or partial document. - ``_ + ``_ - :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: field name, string which is the prefix expected in - matching terms, timeout and size for max number of results + :param index: The name of the index + :param id: Document ID + :param type: The type of the document + :param detect_noop: Set to false to disable setting 'result' in the response + to 'noop' if no change to the document occurred. + :param doc: A partial update to an existing document. + :param doc_as_upsert: Set to true to use the contents of 'doc' as the value of + 'upsert' + :param if_primary_term: Only perform the operation if the document has this primary + term. + :param if_seq_no: Only perform the operation if the document has this sequence + number. + :param lang: The script language. + :param refresh: If 'true', Elasticsearch refreshes the affected shards to make + this operation visible to search, if 'wait_for' then wait for a refresh to + make this operation visible to search, if 'false' do nothing with refreshes. + :param require_alias: If true, the destination must be an index alias. + :param retry_on_conflict: Specify how many times should the operation be retried + when a conflict occurs. + :param routing: Custom value used to route operations to a specific shard. + :param script: Script to execute to update the document. + :param scripted_upsert: Set to true to execute the script whether or not the + document exists. + :param source: Set to false to disable source retrieval. You can also specify + a comma-separated list of the fields you want to retrieve. + :param source_excludes: Specify the source fields you want to exclude. + :param source_includes: Specify the source fields you want to retrieve. + :param timeout: Period to wait for dynamic mapping updates and active shards. + This guarantees Elasticsearch waits for at least the timeout before failing. + The actual wait time could be longer, particularly when multiple waits occur. + :param upsert: If the document does not already exist, the contents of 'upsert' + are inserted as a new document. If the document exists, the 'script' is executed. + :param wait_for_active_shards: The number of shard copies that must be active + before proceeding with the operations. Set to 'all' or any positive integer + up to the total number of shards in the index (number_of_replicas+1). Defaults + to 1 meaning the primary shard. """ - client, params = _deprecated_options(self, params) if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return await client._perform_request( - "POST", - _make_path(index, "_terms_enum"), - params=params, - headers=headers, - body=body, + raise ValueError("Empty value passed for parameter 'index'") + if id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'id'") + if ( + index not in SKIP_IN_PATH + and type not in SKIP_IN_PATH + and id not in SKIP_IN_PATH + ): + __path = f"/{_quote(index)}/{_quote(type)}/{_quote(id)}/_update" + elif index not in SKIP_IN_PATH and id not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_update/{_quote(id)}" + else: + raise ValueError("Couldn't find a path for the given parameters") + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if detect_noop is not None: + __body["detect_noop"] = detect_noop + if doc is not None: + __body["doc"] = doc + if doc_as_upsert is not None: + __body["doc_as_upsert"] = doc_as_upsert + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if if_primary_term is not None: + __query["if_primary_term"] = if_primary_term + if if_seq_no is not None: + __query["if_seq_no"] = if_seq_no + if lang is not None: + __query["lang"] = lang + if pretty is not None: + __query["pretty"] = pretty + if refresh is not None: + __query["refresh"] = refresh + if require_alias is not None: + __query["require_alias"] = require_alias + if retry_on_conflict is not None: + __query["retry_on_conflict"] = retry_on_conflict + if routing is not None: + __query["routing"] = routing + if script is not None: + __body["script"] = script + if scripted_upsert is not None: + __body["scripted_upsert"] = scripted_upsert + if source is not None: + __body["_source"] = source + if source_excludes is not None: + __query["_source_excludes"] = source_excludes + if source_includes is not None: + __query["_source_includes"] = source_includes + if timeout is not None: + __query["timeout"] = timeout + if upsert is not None: + __body["upsert"] = upsert + if wait_for_active_shards is not None: + __query["wait_for_active_shards"] = wait_for_active_shards + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "POST", __target, headers=__headers, body=__body ) - @query_params( - "exact_bounds", - "extent", - "grid_precision", - "grid_type", - "size", - "track_total_hits", + @_rewrite_parameters( + body_fields=True, + parameter_aliases={ + "_source": "source", + "_source_excludes": "source_excludes", + "_source_includes": "source_includes", + "from": "from_", + }, ) - async def search_mvt( - self, index, field, zoom, x, y, body=None, params=None, headers=None - ): + async def update_by_query( + self, + *, + index: Any, + allow_no_indices: Optional[bool] = None, + analyze_wildcard: Optional[bool] = None, + analyzer: Optional[str] = None, + conflicts: Optional[Any] = None, + default_operator: Optional[Any] = None, + df: Optional[str] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + from_: Optional[int] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + lenient: Optional[bool] = None, + max_docs: Optional[int] = None, + pipeline: Optional[str] = None, + preference: Optional[str] = None, + pretty: Optional[bool] = None, + query: Optional[Any] = None, + refresh: Optional[bool] = None, + request_cache: Optional[bool] = None, + requests_per_second: Optional[int] = None, + routing: Optional[Any] = None, + script: Optional[Any] = None, + scroll: Optional[Any] = None, + scroll_size: Optional[int] = None, + search_timeout: Optional[Any] = None, + search_type: Optional[Any] = None, + size: Optional[int] = None, + slice: Optional[Any] = None, + slices: Optional[int] = None, + sort: Optional[List[str]] = None, + source: Optional[Union[Any, bool]] = None, + source_excludes: Optional[Any] = None, + source_includes: Optional[Any] = None, + stats: Optional[List[str]] = None, + terminate_after: Optional[int] = None, + timeout: Optional[Any] = None, + version: Optional[bool] = None, + version_type: Optional[bool] = None, + wait_for_active_shards: Optional[Any] = None, + wait_for_completion: Optional[bool] = None, + ) -> Any: """ - Searches a vector tile for geospatial values. Returns results as a binary - Mapbox vector tile. + Performs an update on every document in the index without changing the source, + for example to pick up a mapping change. - ``_ + ``_ - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - - :arg index: Comma-separated list of data streams, indices, or - aliases to search - :arg field: Field containing geospatial data to return - :arg zoom: Zoom level for the vector tile to search - :arg x: X coordinate for the vector tile to search - :arg y: Y coordinate for the vector tile to search - :arg body: Search request body. - :arg exact_bounds: If false, the meta layer's feature is the - bounding box of the tile. If true, the meta layer's feature is a - bounding box resulting from a `geo_bounds` aggregation. - :arg extent: Size, in pixels, of a side of the vector tile. - Default: 4096 - :arg grid_precision: Additional zoom levels available through - the aggs layer. Accepts 0-8. Default: 8 - :arg grid_type: Determines the geometry type for features in the - aggs layer. Valid choices: grid, point, centroid Default: grid - :arg size: Maximum number of features to return in the hits - layer. Accepts 0-10000. Default: 10000 - :arg track_total_hits: Indicate if the number of documents that - match the query should be tracked. A number can also be specified, to - accurately track the total hit count up to the number. - """ - client, params = _deprecated_options(self, params) - for param in (index, field, zoom, x, y): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "POST", - _make_path(index, "_mvt", field, zoom, x, y), - params=params, - headers=headers, - body=body, + :param index: A comma-separated list of index names to search; use `_all` or + empty string to perform the operation on all indices + :param 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) + :param analyze_wildcard: Specify whether wildcard and prefix queries should be + analyzed (default: false) + :param analyzer: The analyzer to use for the query string + :param conflicts: + :param default_operator: The default operator for query string query (AND or + OR) + :param df: The field to use as default where no field prefix is given in the + query string + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param from_: Starting offset (default: 0) + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param lenient: Specify whether format-based query failures (such as providing + text to a numeric field) should be ignored + :param max_docs: + :param pipeline: Ingest pipeline to set on index requests made by this action. + (default: none) + :param preference: Specify the node or shard the operation should be performed + on (default: random) + :param query: + :param refresh: Should the affected indexes be refreshed? + :param request_cache: Specify if request cache should be used for this request + or not, defaults to index level setting + :param requests_per_second: The throttle to set on this request in sub-requests + per second. -1 means no throttle. + :param routing: A comma-separated list of specific routing values + :param script: + :param scroll: Specify how long a consistent view of the index should be maintained + for scrolled search + :param scroll_size: Size on the scroll request powering the update by query + :param search_timeout: Explicit timeout for each search request. Defaults to + no timeout. + :param search_type: Search operation type + :param size: + :param slice: + :param 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`. + :param sort: A comma-separated list of : pairs + :param source: True or false to return the _source field or not, or a list of + fields to return + :param source_excludes: A list of fields to exclude from the returned _source + field + :param source_includes: A list of fields to extract and return from the _source + field + :param stats: Specific 'tag' of the request for logging and statistical purposes + :param terminate_after: The maximum number of documents to collect for each shard, + upon reaching which the query execution will terminate early. + :param timeout: Time each individual bulk request should wait for shards that + are unavailable. + :param version: Specify whether to return document version as part of a hit + :param version_type: Should the document increment the version number (internal) + on hit or not (reindex) + :param wait_for_active_shards: Sets the number of shard copies that must be active + before proceeding with the update by query operation. Defaults to 1, meaning + the primary shard only. Set to `all` for all shard copies, otherwise set + to any non-negative value less than or equal to the total number of copies + for the shard (number of replicas + 1) + :param wait_for_completion: Should the request should block until the update + by query operation is complete. + """ + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + __path = f"/{_quote(index)}/_update_by_query" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if analyze_wildcard is not None: + __query["analyze_wildcard"] = analyze_wildcard + if analyzer is not None: + __query["analyzer"] = analyzer + if conflicts is not None: + __body["conflicts"] = conflicts + if default_operator is not None: + __query["default_operator"] = default_operator + if df is not None: + __query["df"] = df + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if from_ is not None: + __query["from"] = from_ + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if lenient is not None: + __query["lenient"] = lenient + if max_docs is not None: + __body["max_docs"] = max_docs + if pipeline is not None: + __query["pipeline"] = pipeline + if preference is not None: + __query["preference"] = preference + if pretty is not None: + __query["pretty"] = pretty + if query is not None: + __body["query"] = query + if refresh is not None: + __query["refresh"] = refresh + if request_cache is not None: + __query["request_cache"] = request_cache + if requests_per_second is not None: + __query["requests_per_second"] = requests_per_second + if routing is not None: + __query["routing"] = routing + if script is not None: + __body["script"] = script + if scroll is not None: + __query["scroll"] = scroll + if scroll_size is not None: + __query["scroll_size"] = scroll_size + if search_timeout is not None: + __query["search_timeout"] = search_timeout + if search_type is not None: + __query["search_type"] = search_type + if size is not None: + __query["size"] = size + if slice is not None: + __body["slice"] = slice + if slices is not None: + __query["slices"] = slices + if sort is not None: + __query["sort"] = sort + if source is not None: + __query["_source"] = source + if source_excludes is not None: + __query["_source_excludes"] = source_excludes + if source_includes is not None: + __query["_source_includes"] = source_includes + if stats is not None: + __query["stats"] = stats + if terminate_after is not None: + __query["terminate_after"] = terminate_after + if timeout is not None: + __query["timeout"] = timeout + if version is not None: + __query["version"] = version + if version_type is not None: + __query["version_type"] = version_type + if wait_for_active_shards is not None: + __query["wait_for_active_shards"] = wait_for_active_shards + if wait_for_completion is not None: + __query["wait_for_completion"] = wait_for_completion + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "POST", __target, headers=__headers, body=__body ) - @query_params("routing") - async def knn_search(self, index, body=None, params=None, headers=None): + @_rewrite_parameters() + async def update_by_query_rethrottle( + self, + *, + task_id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + requests_per_second: Optional[int] = None, + ) -> Any: """ - Performs a kNN search. - - ``_ + Changes the number of requests per second for a particular Update By Query operation. - .. warning:: + ``_ - This API is **experimental** so may include breaking changes - or be removed in a future version - - :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 - :arg routing: A comma-separated list of specific routing values + :param task_id: The task id to rethrottle + :param requests_per_second: The throttle to set on this request in floating sub-requests + per second. -1 means set no throttle. """ - client, params = _deprecated_options(self, params) - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return await client._perform_request( - "POST", - _make_path(index, "_knn_search"), - params=params, - headers=headers, - body=body, - ) + if task_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'task_id'") + __path = f"/_update_by_query/{_quote(task_id)}/_rethrottle" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if requests_per_second is not None: + __query["requests_per_second"] = requests_per_second + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) diff --git a/elasticsearch/_async/client/__init__.pyi b/elasticsearch/_async/client/__init__.pyi deleted file mode 100644 index 4be0c79bd..000000000 --- a/elasticsearch/_async/client/__init__.pyi +++ /dev/null @@ -1,1197 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -import logging -from typing import Any, Collection, MutableMapping, Optional, Tuple, Type, Union - -from elastic_transport import AsyncTransport, HeadApiResponse, ObjectApiResponse - -from ._base import BaseClient -from .async_search import AsyncSearchClient -from .autoscaling import AutoscalingClient -from .cat import CatClient -from .ccr import CcrClient -from .cluster import ClusterClient -from .dangling_indices import DanglingIndicesClient -from .enrich import EnrichClient -from .eql import EqlClient -from .features import FeaturesClient -from .fleet import FleetClient -from .graph import GraphClient -from .ilm import IlmClient -from .indices import IndicesClient -from .ingest import IngestClient -from .license import LicenseClient -from .migration import MigrationClient -from .ml import MlClient -from .monitoring import MonitoringClient -from .nodes import NodesClient -from .rollup import RollupClient -from .searchable_snapshots import SearchableSnapshotsClient -from .security import SecurityClient -from .shutdown import ShutdownClient -from .slm import SlmClient -from .snapshot import SnapshotClient -from .sql import SqlClient -from .ssl import SslClient -from .tasks import TasksClient -from .text_structure import TextStructureClient -from .transform import TransformClient -from .watcher import WatcherClient -from .xpack import XPackClient - -logger: logging.Logger - -class AsyncElasticsearch(BaseClient): - transport: AsyncTransport - - async_search: AsyncSearchClient - autoscaling: AutoscalingClient - cat: CatClient - cluster: ClusterClient - indices: IndicesClient - ingest: IngestClient - nodes: NodesClient - snapshot: SnapshotClient - tasks: TasksClient - - xpack: XPackClient - ccr: CcrClient - dangling_indices: DanglingIndicesClient - enrich: EnrichClient - eql: EqlClient - features: FeaturesClient - fleet: FleetClient - graph: GraphClient - ilm: IlmClient - license: LicenseClient - migration: MigrationClient - ml: MlClient - monitoring: MonitoringClient - rollup: RollupClient - searchable_snapshots: SearchableSnapshotsClient - security: SecurityClient - slm: SlmClient - shutdown: ShutdownClient - sql: SqlClient - ssl: SslClient - text_structure: TextStructureClient - transform: TransformClient - watcher: WatcherClient - def __init__( - self, - hosts: Any = ..., - transport_class: Type[AsyncTransport] = ..., - **kwargs: Any, - ) -> None: ... - def __repr__(self) -> str: ... - async def __aenter__(self) -> "AsyncElasticsearch": ... - async def __aexit__(self, *_: Any) -> None: ... - async def close(self) -> None: ... - # AUTO-GENERATED-API-DEFINITIONS # - async def ping( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> HeadApiResponse: ... - async def info( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def create( - self, - index: Any, - id: Any, - *, - body: Any, - doc_type: Optional[Any] = ..., - pipeline: Optional[Any] = ..., - refresh: Optional[Any] = ..., - routing: Optional[Any] = ..., - timeout: Optional[Any] = ..., - version: Optional[Any] = ..., - version_type: Optional[Any] = ..., - wait_for_active_shards: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def index( - self, - index: Any, - *, - body: Any, - id: Optional[Any] = ..., - if_primary_term: Optional[Any] = ..., - if_seq_no: Optional[Any] = ..., - op_type: Optional[Any] = ..., - pipeline: Optional[Any] = ..., - refresh: Optional[Any] = ..., - require_alias: Optional[Any] = ..., - routing: Optional[Any] = ..., - timeout: Optional[Any] = ..., - version: Optional[Any] = ..., - version_type: Optional[Any] = ..., - wait_for_active_shards: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def bulk( - self, - *, - body: Any, - index: Optional[Any] = ..., - doc_type: Optional[Any] = ..., - _source: Optional[Any] = ..., - _source_excludes: Optional[Any] = ..., - _source_includes: Optional[Any] = ..., - pipeline: Optional[Any] = ..., - refresh: Optional[Any] = ..., - require_alias: Optional[Any] = ..., - routing: Optional[Any] = ..., - timeout: Optional[Any] = ..., - wait_for_active_shards: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def clear_scroll( - self, - *, - body: Optional[Any] = ..., - scroll_id: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def count( - self, - *, - body: Optional[Any] = ..., - index: Optional[Any] = ..., - allow_no_indices: Optional[Any] = ..., - analyze_wildcard: Optional[Any] = ..., - analyzer: Optional[Any] = ..., - default_operator: Optional[Any] = ..., - df: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - ignore_throttled: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - lenient: Optional[Any] = ..., - min_score: Optional[Any] = ..., - preference: Optional[Any] = ..., - q: Optional[Any] = ..., - routing: Optional[Any] = ..., - terminate_after: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def delete( - self, - index: Any, - id: Any, - *, - doc_type: Optional[Any] = ..., - if_primary_term: Optional[Any] = ..., - if_seq_no: Optional[Any] = ..., - refresh: Optional[Any] = ..., - routing: Optional[Any] = ..., - timeout: Optional[Any] = ..., - version: Optional[Any] = ..., - version_type: Optional[Any] = ..., - wait_for_active_shards: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def delete_by_query( - self, - index: Any, - *, - body: Any, - _source: Optional[Any] = ..., - _source_excludes: Optional[Any] = ..., - _source_includes: Optional[Any] = ..., - allow_no_indices: Optional[Any] = ..., - analyze_wildcard: Optional[Any] = ..., - analyzer: Optional[Any] = ..., - conflicts: Optional[Any] = ..., - default_operator: Optional[Any] = ..., - df: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - from_: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - lenient: Optional[Any] = ..., - max_docs: Optional[Any] = ..., - preference: Optional[Any] = ..., - q: Optional[Any] = ..., - refresh: Optional[Any] = ..., - request_cache: Optional[Any] = ..., - requests_per_second: Optional[Any] = ..., - routing: Optional[Any] = ..., - scroll: Optional[Any] = ..., - scroll_size: Optional[Any] = ..., - search_timeout: Optional[Any] = ..., - search_type: Optional[Any] = ..., - slices: Optional[Any] = ..., - sort: Optional[Any] = ..., - stats: Optional[Any] = ..., - terminate_after: Optional[Any] = ..., - timeout: Optional[Any] = ..., - version: Optional[Any] = ..., - wait_for_active_shards: Optional[Any] = ..., - wait_for_completion: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def delete_by_query_rethrottle( - self, - task_id: Any, - *, - requests_per_second: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def delete_script( - self, - id: Any, - *, - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def exists( - self, - index: Any, - id: Any, - *, - _source: Optional[Any] = ..., - _source_excludes: Optional[Any] = ..., - _source_includes: Optional[Any] = ..., - preference: Optional[Any] = ..., - realtime: Optional[Any] = ..., - refresh: Optional[Any] = ..., - routing: Optional[Any] = ..., - stored_fields: Optional[Any] = ..., - version: Optional[Any] = ..., - version_type: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> HeadApiResponse: ... - async def exists_source( - self, - index: Any, - id: Any, - *, - doc_type: Optional[Any] = ..., - _source: Optional[Any] = ..., - _source_excludes: Optional[Any] = ..., - _source_includes: Optional[Any] = ..., - preference: Optional[Any] = ..., - realtime: Optional[Any] = ..., - refresh: Optional[Any] = ..., - routing: Optional[Any] = ..., - version: Optional[Any] = ..., - version_type: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> HeadApiResponse: ... - async def explain( - self, - index: Any, - id: Any, - *, - body: Optional[Any] = ..., - _source: Optional[Any] = ..., - _source_excludes: Optional[Any] = ..., - _source_includes: Optional[Any] = ..., - analyze_wildcard: Optional[Any] = ..., - analyzer: Optional[Any] = ..., - default_operator: Optional[Any] = ..., - df: Optional[Any] = ..., - lenient: Optional[Any] = ..., - preference: Optional[Any] = ..., - q: Optional[Any] = ..., - routing: Optional[Any] = ..., - stored_fields: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def field_caps( - self, - *, - body: Optional[Any] = ..., - index: Optional[Any] = ..., - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - fields: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - include_unmapped: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get( - self, - index: Any, - id: Any, - *, - _source: Optional[Any] = ..., - _source_excludes: Optional[Any] = ..., - _source_includes: Optional[Any] = ..., - preference: Optional[Any] = ..., - realtime: Optional[Any] = ..., - refresh: Optional[Any] = ..., - routing: Optional[Any] = ..., - stored_fields: Optional[Any] = ..., - version: Optional[Any] = ..., - version_type: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_script( - self, - id: Any, - *, - master_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_source( - self, - index: Any, - id: Any, - *, - _source: Optional[Any] = ..., - _source_excludes: Optional[Any] = ..., - _source_includes: Optional[Any] = ..., - preference: Optional[Any] = ..., - realtime: Optional[Any] = ..., - refresh: Optional[Any] = ..., - routing: Optional[Any] = ..., - version: Optional[Any] = ..., - version_type: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def mget( - self, - *, - body: Any, - index: Optional[Any] = ..., - _source: Optional[Any] = ..., - _source_excludes: Optional[Any] = ..., - _source_includes: Optional[Any] = ..., - preference: Optional[Any] = ..., - realtime: Optional[Any] = ..., - refresh: Optional[Any] = ..., - routing: Optional[Any] = ..., - stored_fields: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def msearch( - self, - *, - body: Any, - index: Optional[Any] = ..., - ccs_minimize_roundtrips: Optional[Any] = ..., - max_concurrent_searches: Optional[Any] = ..., - max_concurrent_shard_requests: Optional[Any] = ..., - pre_filter_shard_size: Optional[Any] = ..., - rest_total_hits_as_int: Optional[Any] = ..., - search_type: Optional[Any] = ..., - typed_keys: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def put_script( - self, - id: Any, - *, - body: Any, - context: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def rank_eval( - self, - *, - body: Any, - index: Optional[Any] = ..., - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - search_type: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def reindex( - self, - *, - body: Any, - max_docs: Optional[Any] = ..., - refresh: Optional[Any] = ..., - requests_per_second: Optional[Any] = ..., - scroll: Optional[Any] = ..., - slices: Optional[Any] = ..., - timeout: Optional[Any] = ..., - wait_for_active_shards: Optional[Any] = ..., - wait_for_completion: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def reindex_rethrottle( - self, - task_id: Any, - *, - requests_per_second: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def render_search_template( - self, - *, - body: Optional[Any] = ..., - id: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def scripts_painless_execute( - self, - *, - body: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def scroll( - self, - *, - body: Optional[Any] = ..., - scroll_id: Optional[Any] = ..., - rest_total_hits_as_int: Optional[Any] = ..., - scroll: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def search( - self, - *, - body: Optional[Any] = ..., - index: Optional[Any] = ..., - _source: Optional[Any] = ..., - _source_excludes: Optional[Any] = ..., - _source_includes: Optional[Any] = ..., - allow_no_indices: Optional[Any] = ..., - allow_partial_search_results: Optional[Any] = ..., - analyze_wildcard: Optional[Any] = ..., - analyzer: Optional[Any] = ..., - batched_reduce_size: Optional[Any] = ..., - ccs_minimize_roundtrips: Optional[Any] = ..., - default_operator: Optional[Any] = ..., - df: Optional[Any] = ..., - docvalue_fields: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - explain: Optional[Any] = ..., - from_: Optional[Any] = ..., - ignore_throttled: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - lenient: Optional[Any] = ..., - max_concurrent_shard_requests: Optional[Any] = ..., - min_compatible_shard_node: Optional[Any] = ..., - pre_filter_shard_size: Optional[Any] = ..., - preference: Optional[Any] = ..., - q: Optional[Any] = ..., - request_cache: Optional[Any] = ..., - rest_total_hits_as_int: Optional[Any] = ..., - routing: Optional[Any] = ..., - scroll: Optional[Any] = ..., - search_type: Optional[Any] = ..., - seq_no_primary_term: Optional[Any] = ..., - size: Optional[Any] = ..., - sort: Optional[Any] = ..., - stats: Optional[Any] = ..., - stored_fields: Optional[Any] = ..., - suggest_field: Optional[Any] = ..., - suggest_mode: Optional[Any] = ..., - suggest_size: Optional[Any] = ..., - suggest_text: Optional[Any] = ..., - terminate_after: Optional[Any] = ..., - timeout: Optional[Any] = ..., - track_scores: Optional[Any] = ..., - track_total_hits: Optional[Any] = ..., - typed_keys: Optional[Any] = ..., - version: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def search_shards( - self, - *, - index: Optional[Any] = ..., - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - local: Optional[Any] = ..., - preference: Optional[Any] = ..., - routing: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def update( - self, - index: Any, - id: Any, - *, - body: Any, - doc_type: Optional[Any] = ..., - _source: Optional[Any] = ..., - _source_excludes: Optional[Any] = ..., - _source_includes: Optional[Any] = ..., - if_primary_term: Optional[Any] = ..., - if_seq_no: Optional[Any] = ..., - lang: Optional[Any] = ..., - refresh: Optional[Any] = ..., - require_alias: Optional[Any] = ..., - retry_on_conflict: Optional[Any] = ..., - routing: Optional[Any] = ..., - timeout: Optional[Any] = ..., - wait_for_active_shards: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def update_by_query_rethrottle( - self, - task_id: Any, - *, - requests_per_second: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_script_context( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_script_languages( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def msearch_template( - self, - *, - body: Any, - index: Optional[Any] = ..., - ccs_minimize_roundtrips: Optional[Any] = ..., - max_concurrent_searches: Optional[Any] = ..., - rest_total_hits_as_int: Optional[Any] = ..., - search_type: Optional[Any] = ..., - typed_keys: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def mtermvectors( - self, - *, - body: Optional[Any] = ..., - index: Optional[Any] = ..., - field_statistics: Optional[Any] = ..., - fields: Optional[Any] = ..., - ids: Optional[Any] = ..., - offsets: Optional[Any] = ..., - payloads: Optional[Any] = ..., - positions: Optional[Any] = ..., - preference: Optional[Any] = ..., - realtime: Optional[Any] = ..., - routing: Optional[Any] = ..., - term_statistics: Optional[Any] = ..., - version: Optional[Any] = ..., - version_type: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def search_template( - self, - *, - body: Any, - index: Optional[Any] = ..., - allow_no_indices: Optional[Any] = ..., - ccs_minimize_roundtrips: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - explain: Optional[Any] = ..., - ignore_throttled: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - preference: Optional[Any] = ..., - profile: Optional[Any] = ..., - rest_total_hits_as_int: Optional[Any] = ..., - routing: Optional[Any] = ..., - scroll: Optional[Any] = ..., - search_type: Optional[Any] = ..., - typed_keys: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def termvectors( - self, - index: Any, - *, - body: Optional[Any] = ..., - id: Optional[Any] = ..., - field_statistics: Optional[Any] = ..., - fields: Optional[Any] = ..., - offsets: Optional[Any] = ..., - payloads: Optional[Any] = ..., - positions: Optional[Any] = ..., - preference: Optional[Any] = ..., - realtime: Optional[Any] = ..., - routing: Optional[Any] = ..., - term_statistics: Optional[Any] = ..., - version: Optional[Any] = ..., - version_type: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def update_by_query( - self, - index: Any, - *, - body: Optional[Any] = ..., - _source: Optional[Any] = ..., - _source_excludes: Optional[Any] = ..., - _source_includes: Optional[Any] = ..., - allow_no_indices: Optional[Any] = ..., - analyze_wildcard: Optional[Any] = ..., - analyzer: Optional[Any] = ..., - conflicts: Optional[Any] = ..., - default_operator: Optional[Any] = ..., - df: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - from_: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - lenient: Optional[Any] = ..., - max_docs: Optional[Any] = ..., - pipeline: Optional[Any] = ..., - preference: Optional[Any] = ..., - q: Optional[Any] = ..., - refresh: Optional[Any] = ..., - request_cache: Optional[Any] = ..., - requests_per_second: Optional[Any] = ..., - routing: Optional[Any] = ..., - scroll: Optional[Any] = ..., - scroll_size: Optional[Any] = ..., - search_timeout: Optional[Any] = ..., - search_type: Optional[Any] = ..., - slices: Optional[Any] = ..., - sort: Optional[Any] = ..., - stats: Optional[Any] = ..., - terminate_after: Optional[Any] = ..., - timeout: Optional[Any] = ..., - version: Optional[Any] = ..., - version_type: Optional[Any] = ..., - wait_for_active_shards: Optional[Any] = ..., - wait_for_completion: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def close_point_in_time( - self, - *, - body: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def open_point_in_time( - self, - index: Any, - *, - expand_wildcards: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - keep_alive: Optional[Any] = ..., - preference: Optional[Any] = ..., - routing: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def terms_enum( - self, - index: Any, - *, - body: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def search_mvt( - self, - index: Any, - field: Any, - zoom: Any, - x: Any, - y: Any, - *, - body: Optional[Any] = ..., - exact_bounds: Optional[Any] = ..., - extent: Optional[Any] = ..., - grid_precision: Optional[Any] = ..., - grid_type: Optional[Any] = ..., - size: Optional[Any] = ..., - track_total_hits: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> Any: ... - async def knn_search( - self, - index: Any, - *, - body: Optional[Any] = ..., - routing: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_async/client/_base.py b/elasticsearch/_async/client/_base.py index 2da8078a8..035cbd6ce 100644 --- a/elasticsearch/_async/client/_base.py +++ b/elasticsearch/_async/client/_base.py @@ -45,7 +45,7 @@ ) from elastic_transport.client_utils import DEFAULT, DefaultType, resolve_default -from ...compat import urlencode, warn_stacklevel +from ...compat import warn_stacklevel from ...exceptions import ( HTTP_EXCEPTIONS, ApiError, @@ -250,16 +250,8 @@ async def _perform_request( method: str, target: str, headers: Optional[Mapping[str, str]] = None, - params: Optional[Mapping[str, str]] = None, body: Optional[Any] = None, ) -> ApiResponse[Any, Any]: - # Handle the passing of 'params' as additional query parameters. - # This behavior is deprecated and should be removed in 9.0.0. - if params: - if "?" in target: - raise ValueError("Can't add query to a target that already has a query") - target = f"{target}?{urlencode(params)}" - if headers: request_headers = self._headers.copy() request_headers.update(headers) @@ -418,11 +410,10 @@ async def _perform_request( method: str, target: str, headers: Optional[Mapping[str, str]] = None, - params: Optional[Mapping[str, str]] = None, body: Optional[Any] = None, ) -> Any: # Use the internal clients .perform_request() implementation # so we take advantage of their transport options. return await self._client._perform_request( - method, target, headers=headers, params=params, body=body + method, target, headers=headers, body=body ) diff --git a/elasticsearch/_async/client/async_search.py b/elasticsearch/_async/client/async_search.py index 5275e5a48..f13c64089 100644 --- a/elasticsearch/_async/client/async_search.py +++ b/elasticsearch/_async/client/async_search.py @@ -15,218 +15,489 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params +from .utils import SKIP_IN_PATH, _quote, _quote_query, _rewrite_parameters class AsyncSearchClient(NamespacedClient): - @query_params() - async def delete(self, id, params=None, headers=None): + @_rewrite_parameters() + async def delete( + self, + *, + id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - 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. + 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 + :param id: The async search ID """ - client, params = _deprecated_options(self, params) if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'id'.") - - return await client._perform_request( - "DELETE", _make_path("_async_search", id), params=params, headers=headers - ) + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/_async_search/{_quote(id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("DELETE", __target, headers=__headers) - @query_params("keep_alive", "typed_keys", "wait_for_completion_timeout") - async def get(self, id, params=None, headers=None): + @_rewrite_parameters() + async def get( + self, + *, + id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + keep_alive: Optional[Any] = None, + pretty: Optional[bool] = None, + typed_keys: Optional[bool] = None, + wait_for_completion_timeout: Optional[Any] = None, + ) -> Any: """ 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 - (partial or final) for this search will be available - :arg typed_keys: Specify whether aggregation and suggester names - should be prefixed by their respective types in the response - :arg wait_for_completion_timeout: Specify the time that the - request should block waiting for the final response + :param id: The async search ID + :param keep_alive: Specify the time interval in which the results (partial or + final) for this search will be available + :param typed_keys: Specify whether aggregation and suggester names should be + prefixed by their respective types in the response + :param wait_for_completion_timeout: Specify the time that the request should + block waiting for the final response """ - client, params = _deprecated_options(self, params) if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'id'.") - - return await client._perform_request( - "GET", _make_path("_async_search", id), params=params, headers=headers - ) + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/_async_search/{_quote(id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if keep_alive is not None: + __query["keep_alive"] = keep_alive + if pretty is not None: + __query["pretty"] = pretty + if typed_keys is not None: + __query["typed_keys"] = typed_keys + if wait_for_completion_timeout is not None: + __query["wait_for_completion_timeout"] = wait_for_completion_timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) - @query_params( - "_source", - "_source_excludes", - "_source_includes", - "allow_no_indices", - "allow_partial_search_results", - "analyze_wildcard", - "analyzer", - "batched_reduce_size", - "default_operator", - "df", - "docvalue_fields", - "expand_wildcards", - "explain", - "from_", - "ignore_throttled", - "ignore_unavailable", - "keep_alive", - "keep_on_completion", - "lenient", - "max_concurrent_shard_requests", - "preference", - "q", - "request_cache", - "routing", - "search_type", - "seq_no_primary_term", - "size", - "sort", - "stats", - "stored_fields", - "suggest_field", - "suggest_mode", - "suggest_size", - "suggest_text", - "terminate_after", - "timeout", - "track_scores", - "track_total_hits", - "typed_keys", - "version", - "wait_for_completion_timeout", - ) - async def submit(self, body=None, index=None, params=None, headers=None): + @_rewrite_parameters() + async def status( + self, + *, + id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Executes a search request asynchronously. + Retrieves the status of a previously submitted async search request given its + ID. - ``_ + ``_ - :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 _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 - returned _source field - :arg _source_includes: A list of fields to extract and return - from the _source field - :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 allow_partial_search_results: Indicate if an error should - be returned if there is a partial search failure or timeout Default: - True - :arg analyze_wildcard: Specify whether wildcard and prefix - queries should be analyzed (default: false) - :arg analyzer: The analyzer to use for the query string - :arg batched_reduce_size: The number of shard results that - should be reduced at once on the coordinating node. This value should be - used as the granularity at which progress results will be made - available. Default: 5 - :arg default_operator: The default operator for query string - query (AND or OR) Valid choices: AND, OR Default: OR - :arg df: The field to use as default where no field prefix is - given in the query string - :arg docvalue_fields: A comma-separated list of fields to return - as the docvalue representation of a field for each hit - :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 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 - should be ignored when unavailable (missing or closed) - :arg keep_alive: Update the time interval in which the results - (partial or final) for this search will be available Default: 5d - :arg keep_on_completion: Control whether the response should be - stored in the cluster if it completed within the provided - [wait_for_completion] time (default: false) - :arg lenient: Specify whether format-based query failures (such - as providing text to a numeric field) should be ignored - :arg max_concurrent_shard_requests: The number of concurrent - shard requests per node this search executes concurrently. This value - should be used to limit the impact of the search on the cluster in order - to limit the number of concurrent shard requests Default: 5 - :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 request_cache: Specify if request cache should be used for - this request or not, defaults to true - :arg routing: A comma-separated list of specific routing values - :arg search_type: Search operation type Valid choices: - query_then_fetch, dfs_query_then_fetch - :arg seq_no_primary_term: Specify whether to return sequence - number and primary term of the last modification of each hit - :arg size: Number of hits to return (default: 10) - :arg sort: A comma-separated list of : pairs - :arg stats: Specific 'tag' of the request for logging and - statistical purposes - :arg stored_fields: A comma-separated list of stored fields to - return as part of a hit - :arg suggest_field: Specify which field to use for suggestions - :arg suggest_mode: Specify suggest mode Valid choices: missing, - popular, always Default: missing - :arg suggest_size: How many suggestions to return in response - :arg suggest_text: The source text for which the suggestions - should be returned - :arg terminate_after: The maximum number of documents to collect - for each shard, upon reaching which the query execution will terminate - early. - :arg timeout: Explicit operation timeout - :arg track_scores: Whether to calculate and return scores even - if they are not used for sorting - :arg track_total_hits: Indicate if the number of documents that - match the query should be tracked. A number can also be specified, to - accurately track the total hit count up to the number. - :arg typed_keys: Specify whether aggregation and suggester names - should be prefixed by their respective types in the response - :arg version: Specify whether to return document version as part - of a hit - :arg wait_for_completion_timeout: Specify the time that the - request should block waiting for the final response Default: 1s + :param id: The async search ID """ - client, params = _deprecated_options(self, params) - if params and "from_" in params: - params["from"] = params.pop("from_") - - return await client._perform_request( - "POST", - _make_path(index, "_async_search"), - params=params, - headers=headers, - body=body, - ) + if id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/_async_search/status/{_quote(id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) - @query_params() - async def status(self, id, params=None, headers=None): + @_rewrite_parameters( + body_fields=True, + parameter_aliases={ + "_source": "source", + "_source_excludes": "source_excludes", + "_source_includes": "source_includes", + "from": "from_", + }, + ) + async def submit( + self, + *, + index: Optional[Any] = None, + aggregations: Optional[Dict[str, Any]] = None, + allow_no_indices: Optional[bool] = None, + allow_partial_search_results: Optional[bool] = None, + analyze_wildcard: Optional[bool] = None, + analyzer: Optional[str] = None, + batched_reduce_size: Optional[int] = None, + ccs_minimize_roundtrips: Optional[bool] = None, + collapse: Optional[Any] = None, + default_operator: Optional[Any] = None, + df: Optional[str] = None, + docvalue_fields: Optional[Union[Any, List[Any]]] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + explain: Optional[bool] = None, + fields: Optional[List[Any]] = None, + filter_path: Optional[Union[List[str], str]] = None, + from_: Optional[int] = None, + highlight: Optional[Any] = None, + human: Optional[bool] = None, + ignore_throttled: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + indices_boost: Optional[List[Dict[Any, float]]] = None, + keep_alive: Optional[Any] = None, + keep_on_completion: Optional[bool] = None, + lenient: Optional[bool] = None, + max_concurrent_shard_requests: Optional[int] = None, + min_compatible_shard_node: Optional[Any] = None, + min_score: Optional[float] = None, + pit: Optional[Any] = None, + post_filter: Optional[Any] = None, + pre_filter_shard_size: Optional[int] = None, + preference: Optional[str] = None, + pretty: Optional[bool] = None, + profile: Optional[bool] = None, + q: Optional[str] = None, + query: Optional[Any] = None, + request_cache: Optional[bool] = None, + rescore: Optional[Union[Any, List[Any]]] = None, + rest_total_hits_as_int: Optional[bool] = None, + routing: Optional[Any] = None, + runtime_mappings: Optional[Any] = None, + script_fields: Optional[Dict[str, Any]] = None, + scroll: Optional[Any] = None, + search_after: Optional[Any] = None, + search_type: Optional[Any] = None, + seq_no_primary_term: Optional[bool] = None, + size: Optional[int] = None, + slice: Optional[Any] = None, + sort: Optional[Any] = None, + source: Optional[Union[Any, bool]] = None, + source_excludes: Optional[Any] = None, + source_includes: Optional[Any] = None, + stats: Optional[List[str]] = None, + stored_fields: Optional[Any] = None, + suggest: Optional[Union[Any, Dict[str, Any]]] = None, + suggest_field: Optional[Any] = None, + suggest_mode: Optional[Any] = None, + suggest_size: Optional[int] = None, + suggest_text: Optional[str] = None, + terminate_after: Optional[int] = None, + timeout: Optional[str] = None, + track_scores: Optional[bool] = None, + track_total_hits: Optional[Union[bool, int]] = None, + typed_keys: Optional[bool] = None, + version: Optional[bool] = None, + wait_for_completion_timeout: Optional[Any] = None, + ) -> Any: """ - Retrieves the status of a previously submitted async search request given its - ID. + Executes a search request asynchronously. - ``_ + ``_ - :arg id: The async search ID + :param index: A comma-separated list of index names to search; use `_all` or + empty string to perform the operation on all indices + :param aggregations: + :param 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) + :param allow_partial_search_results: Indicate if an error should be returned + if there is a partial search failure or timeout + :param analyze_wildcard: Specify whether wildcard and prefix queries should be + analyzed (default: false) + :param analyzer: The analyzer to use for the query string + :param batched_reduce_size: The number of shard results that should be reduced + at once on the coordinating node. This value should be used as the granularity + at which progress results will be made available. + :param ccs_minimize_roundtrips: + :param collapse: + :param default_operator: The default operator for query string query (AND or + OR) + :param df: The field to use as default where no field prefix is given in the + query string + :param docvalue_fields: Array of wildcard (*) patterns. The request returns doc + values for field names matching these patterns in the hits.fields property + of the response. + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param explain: If true, returns detailed information about score computation + as part of a hit. + :param fields: Array of wildcard (*) patterns. The request returns values for + field names matching these patterns in the hits.fields property of the response. + :param from_: Starting document offset. By default, you cannot page through more + than 10,000 hits using the from and size parameters. To page through more + hits, use the search_after parameter. + :param highlight: + :param ignore_throttled: Whether specified concrete, expanded or aliased indices + should be ignored when throttled + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param indices_boost: Boosts the _score of documents from specified indices. + :param keep_alive: Update the time interval in which the results (partial or + final) for this search will be available + :param keep_on_completion: Control whether the response should be stored in the + cluster if it completed within the provided [wait_for_completion] time (default: + false) + :param lenient: Specify whether format-based query failures (such as providing + text to a numeric field) should be ignored + :param max_concurrent_shard_requests: The number of concurrent shard requests + per node this search executes concurrently. This value should be used to + limit the impact of the search on the cluster in order to limit the number + of concurrent shard requests + :param min_compatible_shard_node: + :param min_score: Minimum _score for matching documents. Documents with a lower + _score are not included in the search results. + :param pit: Limits the search to a point in time (PIT). If you provide a PIT, + you cannot specify an in the request path. + :param post_filter: + :param pre_filter_shard_size: + :param preference: Specify the node or shard the operation should be performed + on (default: random) + :param profile: + :param q: Query in the Lucene query string syntax + :param query: Defines the search definition using the Query DSL. + :param request_cache: Specify if request cache should be used for this request + or not, defaults to true + :param rescore: + :param rest_total_hits_as_int: + :param routing: A comma-separated list of specific routing values + :param runtime_mappings: Defines one or more runtime fields in the search request. + These fields take precedence over mapped fields with the same name. + :param script_fields: Retrieve a script evaluation (based on different fields) + for each hit. + :param scroll: + :param search_after: + :param search_type: Search operation type + :param seq_no_primary_term: If true, returns sequence number and primary term + of the last modification of each hit. See Optimistic concurrency control. + :param size: The number of hits to return. By default, you cannot page through + more than 10,000 hits using the from and size parameters. To page through + more hits, use the search_after parameter. + :param slice: + :param sort: + :param source: Indicates which source fields are returned for matching documents. + These fields are returned in the hits._source property of the search response. + :param source_excludes: A list of fields to exclude from the returned _source + field + :param source_includes: A list of fields to extract and return from the _source + field + :param stats: Stats groups to associate with the search. Each group maintains + a statistics aggregation for its associated searches. You can retrieve these + stats using the indices stats API. + :param stored_fields: List of stored fields to return as part of a hit. If no + fields are specified, no stored fields are included in the response. If this + field is specified, the _source parameter defaults to false. You can pass + _source: true to return both source fields and stored fields in the search + response. + :param suggest: + :param suggest_field: Specifies which field to use for suggestions. + :param suggest_mode: Specify suggest mode + :param suggest_size: How many suggestions to return in response + :param suggest_text: The source text for which the suggestions should be returned. + :param terminate_after: Maximum number of documents to collect for each shard. + If a query reaches this limit, Elasticsearch terminates the query early. + Elasticsearch collects documents before sorting. Defaults to 0, which does + not terminate query execution early. + :param timeout: Specifies the period of time to wait for a response from each + shard. If no response is received before the timeout expires, the request + fails and returns an error. Defaults to no timeout. + :param track_scores: If true, calculate and return document scores, even if the + scores are not used for sorting. + :param track_total_hits: Number of hits matching the query to count accurately. + If true, the exact number of hits is returned at the cost of some performance. + If false, the response does not include the total number of hits matching + the query. Defaults to 10,000 hits. + :param typed_keys: Specify whether aggregation and suggester names should be + prefixed by their respective types in the response + :param version: If true, returns document version as part of a hit. + :param wait_for_completion_timeout: Specify the time that the request should + block waiting for the final response """ - client, params = _deprecated_options(self, params) - if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'id'.") - - return await client._perform_request( - "GET", - _make_path("_async_search", "status", id), - params=params, - headers=headers, + if index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_async_search" + else: + __path = "/_async_search" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if aggregations is not None: + __body["aggregations"] = aggregations + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if allow_partial_search_results is not None: + __query["allow_partial_search_results"] = allow_partial_search_results + if analyze_wildcard is not None: + __query["analyze_wildcard"] = analyze_wildcard + if analyzer is not None: + __query["analyzer"] = analyzer + if batched_reduce_size is not None: + __query["batched_reduce_size"] = batched_reduce_size + if ccs_minimize_roundtrips is not None: + __query["ccs_minimize_roundtrips"] = ccs_minimize_roundtrips + if collapse is not None: + __body["collapse"] = collapse + if default_operator is not None: + __query["default_operator"] = default_operator + if df is not None: + __query["df"] = df + if docvalue_fields is not None: + __body["docvalue_fields"] = docvalue_fields + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if explain is not None: + __body["explain"] = explain + if fields is not None: + __body["fields"] = fields + if filter_path is not None: + __query["filter_path"] = filter_path + if from_ is not None: + __body["from"] = from_ + if highlight is not None: + __body["highlight"] = highlight + if human is not None: + __query["human"] = human + if ignore_throttled is not None: + __query["ignore_throttled"] = ignore_throttled + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if indices_boost is not None: + __body["indices_boost"] = indices_boost + if keep_alive is not None: + __query["keep_alive"] = keep_alive + if keep_on_completion is not None: + __query["keep_on_completion"] = keep_on_completion + if lenient is not None: + __query["lenient"] = lenient + if max_concurrent_shard_requests is not None: + __query["max_concurrent_shard_requests"] = max_concurrent_shard_requests + if min_compatible_shard_node is not None: + __query["min_compatible_shard_node"] = min_compatible_shard_node + if min_score is not None: + __body["min_score"] = min_score + if pit is not None: + __body["pit"] = pit + if post_filter is not None: + __body["post_filter"] = post_filter + if pre_filter_shard_size is not None: + __query["pre_filter_shard_size"] = pre_filter_shard_size + if preference is not None: + __query["preference"] = preference + if pretty is not None: + __query["pretty"] = pretty + if profile is not None: + __body["profile"] = profile + if q is not None: + __query["q"] = q + if query is not None: + __body["query"] = query + if request_cache is not None: + __query["request_cache"] = request_cache + if rescore is not None: + __body["rescore"] = rescore + if rest_total_hits_as_int is not None: + __query["rest_total_hits_as_int"] = rest_total_hits_as_int + if routing is not None: + __query["routing"] = routing + if runtime_mappings is not None: + __body["runtime_mappings"] = runtime_mappings + if script_fields is not None: + __body["script_fields"] = script_fields + if scroll is not None: + __query["scroll"] = scroll + if search_after is not None: + __body["search_after"] = search_after + if search_type is not None: + __query["search_type"] = search_type + if seq_no_primary_term is not None: + __body["seq_no_primary_term"] = seq_no_primary_term + if size is not None: + __body["size"] = size + if slice is not None: + __body["slice"] = slice + if sort is not None: + __body["sort"] = sort + if source is not None: + __body["_source"] = source + if source_excludes is not None: + __query["_source_excludes"] = source_excludes + if source_includes is not None: + __query["_source_includes"] = source_includes + if stats is not None: + __body["stats"] = stats + if stored_fields is not None: + __body["stored_fields"] = stored_fields + if suggest is not None: + __body["suggest"] = suggest + if suggest_field is not None: + __query["suggest_field"] = suggest_field + if suggest_mode is not None: + __query["suggest_mode"] = suggest_mode + if suggest_size is not None: + __query["suggest_size"] = suggest_size + if suggest_text is not None: + __query["suggest_text"] = suggest_text + if terminate_after is not None: + __body["terminate_after"] = terminate_after + if timeout is not None: + __body["timeout"] = timeout + if track_scores is not None: + __body["track_scores"] = track_scores + if track_total_hits is not None: + __body["track_total_hits"] = track_total_hits + if typed_keys is not None: + __query["typed_keys"] = typed_keys + if version is not None: + __body["version"] = version + if wait_for_completion_timeout is not None: + __query["wait_for_completion_timeout"] = wait_for_completion_timeout + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "POST", __target, headers=__headers, body=__body ) diff --git a/elasticsearch/_async/client/async_search.pyi b/elasticsearch/_async/client/async_search.pyi deleted file mode 100644 index b5af4b60e..000000000 --- a/elasticsearch/_async/client/async_search.pyi +++ /dev/null @@ -1,137 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class AsyncSearchClient(NamespacedClient): - async def delete( - self, - id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get( - self, - id: Any, - *, - keep_alive: Optional[Any] = ..., - typed_keys: Optional[Any] = ..., - wait_for_completion_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def submit( - self, - *, - body: Optional[Any] = ..., - index: Optional[Any] = ..., - _source: Optional[Any] = ..., - _source_excludes: Optional[Any] = ..., - _source_includes: Optional[Any] = ..., - allow_no_indices: Optional[Any] = ..., - allow_partial_search_results: Optional[Any] = ..., - analyze_wildcard: Optional[Any] = ..., - analyzer: Optional[Any] = ..., - batched_reduce_size: Optional[Any] = ..., - default_operator: Optional[Any] = ..., - df: Optional[Any] = ..., - docvalue_fields: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - explain: Optional[Any] = ..., - from_: Optional[Any] = ..., - ignore_throttled: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - keep_alive: Optional[Any] = ..., - keep_on_completion: Optional[Any] = ..., - lenient: Optional[Any] = ..., - max_concurrent_shard_requests: Optional[Any] = ..., - preference: Optional[Any] = ..., - q: Optional[Any] = ..., - request_cache: Optional[Any] = ..., - routing: Optional[Any] = ..., - search_type: Optional[Any] = ..., - seq_no_primary_term: Optional[Any] = ..., - size: Optional[Any] = ..., - sort: Optional[Any] = ..., - stats: Optional[Any] = ..., - stored_fields: Optional[Any] = ..., - suggest_field: Optional[Any] = ..., - suggest_mode: Optional[Any] = ..., - suggest_size: Optional[Any] = ..., - suggest_text: Optional[Any] = ..., - terminate_after: Optional[Any] = ..., - timeout: Optional[Any] = ..., - track_scores: Optional[Any] = ..., - track_total_hits: Optional[Any] = ..., - typed_keys: Optional[Any] = ..., - version: Optional[Any] = ..., - wait_for_completion_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def status( - self, - id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_async/client/autoscaling.py b/elasticsearch/_async/client/autoscaling.py index a7b59f2de..258710187 100644 --- a/elasticsearch/_async/client/autoscaling.py +++ b/elasticsearch/_async/client/autoscaling.py @@ -15,87 +15,161 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params +from .utils import SKIP_IN_PATH, _quote, _quote_query, _rewrite_parameters class AutoscalingClient(NamespacedClient): - @query_params() - async def delete_autoscaling_policy(self, name, params=None, headers=None): + @_rewrite_parameters() + async def delete_autoscaling_policy( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Deletes an autoscaling policy. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported. - ``_ + ``_ - :arg name: the name of the autoscaling policy + :param name: the name of the autoscaling policy """ - client, params = _deprecated_options(self, params) if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'name'.") - - return await client._perform_request( - "DELETE", - _make_path("_autoscaling", "policy", name), - params=params, - headers=headers, - ) - - @query_params() - async def put_autoscaling_policy(self, name, body, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_autoscaling/policy/{_quote(name)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + async def get_autoscaling_capacity( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Creates a new autoscaling policy. Designed for indirect use by ECE/ESS and ECK. - Direct use is not supported. - - ``_ + Gets the current autoscaling capacity based on the configured autoscaling policy. + Designed for indirect use by ECE/ESS and ECK. Direct use is not supported. - :arg name: the name of the autoscaling policy - :arg body: the specification of the autoscaling policy + ``_ """ - client, params = _deprecated_options(self, params) - for param in (name, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "PUT", - _make_path("_autoscaling", "policy", name), - params=params, - headers=headers, - body=body, - ) - - @query_params() - async def get_autoscaling_policy(self, name, params=None, headers=None): + __path = "/_autoscaling/capacity" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def get_autoscaling_policy( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Retrieves an autoscaling policy. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported. - ``_ + ``_ - :arg name: the name of the autoscaling policy + :param name: the name of the autoscaling policy """ - client, params = _deprecated_options(self, params) if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'name'.") - - return await client._perform_request( - "GET", - _make_path("_autoscaling", "policy", name), - params=params, - headers=headers, - ) - - @query_params() - async def get_autoscaling_capacity(self, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_autoscaling/policy/{_quote(name)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + body_name="policy", + ) + async def put_autoscaling_policy( + self, + *, + name: Any, + policy: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Gets the current autoscaling capacity based on the configured autoscaling - policy. Designed for indirect use by ECE/ESS and ECK. Direct use is not - supported. + Creates a new autoscaling policy. Designed for indirect use by ECE/ESS and ECK. + Direct use is not supported. - ``_ + ``_ + + :param name: the name of the autoscaling policy + :param policy: """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", "/_autoscaling/capacity", params=params, headers=headers + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + if policy is None: + raise ValueError("Empty value passed for parameter 'policy'") + __path = f"/_autoscaling/policy/{_quote(name)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + __body = policy + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "PUT", __target, headers=__headers, body=__body ) diff --git a/elasticsearch/_async/client/autoscaling.pyi b/elasticsearch/_async/client/autoscaling.pyi deleted file mode 100644 index 8ec1f66c8..000000000 --- a/elasticsearch/_async/client/autoscaling.pyi +++ /dev/null @@ -1,92 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class AutoscalingClient(NamespacedClient): - async def delete_autoscaling_policy( - self, - name: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def put_autoscaling_policy( - self, - name: Any, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_autoscaling_policy( - self, - name: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_autoscaling_capacity( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_async/client/cat.py b/elasticsearch/_async/client/cat.py index 1c9013abe..f20853b81 100644 --- a/elasticsearch/_async/client/cat.py +++ b/elasticsearch/_async/client/cat.py @@ -15,792 +15,1954 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import _deprecated_options, _make_path, query_params +from .utils import SKIP_IN_PATH, _quote, _quote_query, _rewrite_parameters class CatClient(NamespacedClient): - @query_params("expand_wildcards", "format", "h", "help", "local", "s", "v") - async def aliases(self, name=None, params=None, headers=None): + @_rewrite_parameters() + async def aliases( + self, + *, + name: Optional[Any] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + h: Optional[Any] = None, + help: Optional[bool] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + s: Optional[List[str]] = None, + v: Optional[bool] = None, + ) -> Any: """ - Shows information about currently configured aliases to indices including - filter and routing infos. + 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 - concrete indices that are open, closed or both. Valid choices: open, - closed, hidden, none, all Default: all - :arg format: a short version of the Accept header, e.g. json, - yaml - :arg h: Comma-separated list of column names to display - :arg help: Return help information - :arg local: Return local information, do not retrieve the state - from master node (default: false) - :arg s: Comma-separated list of column names or column aliases - to sort by - :arg v: Verbose mode. Display column headers - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", _make_path("_cat", "aliases", name), params=params, headers=headers - ) - - @query_params("bytes", "format", "h", "help", "local", "master_timeout", "s", "v") - async def allocation(self, node_id=None, params=None, headers=None): + :param name: A comma-separated list of alias names to return + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param format: Specifies the format to return the columnar data in, can be set + to `text`, `json`, `cbor`, `yaml`, or `smile`. + :param h: List of columns to appear in the response. Supports simple wildcards. + :param help: When set to `true` will output available columns. This option can't + be combined with any other query string option. + :param local: If `true`, the request computes the list of selected nodes from + the local cluster state. If `false` the list of selected nodes are computed + from the cluster state of the master node. In both cases the coordinating + node will send requests for further information to each selected node. + :param master_timeout: Period to wait for a connection to the master node. + :param s: List of columns that determine how the table should be sorted. Sorting + defaults to ascending and can be changed by setting `:asc` or `:desc` as + a suffix to the column name. + :param v: When set to `true` will enable verbose output. + """ + if name not in SKIP_IN_PATH: + __path = f"/_cat/aliases/{_quote(name)}" + else: + __path = "/_cat/aliases" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if h is not None: + __query["h"] = h + if help is not None: + __query["help"] = help + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if s is not None: + __query["s"] = s + if v is not None: + __query["v"] = v + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain,application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def allocation( + self, + *, + node_id: Optional[Any] = None, + bytes: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + h: Optional[Any] = None, + help: Optional[bool] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + s: Optional[List[str]] = None, + v: Optional[bool] = None, + ) -> Any: """ 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 - :arg bytes: The unit in which to display byte values Valid - 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 h: Comma-separated list of column names to display - :arg help: Return help information - :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 - :arg s: Comma-separated list of column names or column aliases - to sort by - :arg v: Verbose mode. Display column headers - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", - _make_path("_cat", "allocation", node_id), - params=params, - headers=headers, - ) - - @query_params("format", "h", "help", "s", "v") - async def count(self, index=None, params=None, headers=None): - """ - Provides quick access to the document count of the entire cluster, or - individual indices. + :param node_id: A comma-separated list of node IDs or names to limit the returned + information + :param bytes: The unit in which to display byte values + :param format: Specifies the format to return the columnar data in, can be set + to `text`, `json`, `cbor`, `yaml`, or `smile`. + :param h: List of columns to appear in the response. Supports simple wildcards. + :param help: When set to `true` will output available columns. This option can't + be combined with any other query string option. + :param local: If `true`, the request computes the list of selected nodes from + the local cluster state. If `false` the list of selected nodes are computed + from the cluster state of the master node. In both cases the coordinating + node will send requests for further information to each selected node. + :param master_timeout: Period to wait for a connection to the master node. + :param s: List of columns that determine how the table should be sorted. Sorting + defaults to ascending and can be changed by setting `:asc` or `:desc` as + a suffix to the column name. + :param v: When set to `true` will enable verbose output. + """ + if node_id not in SKIP_IN_PATH: + __path = f"/_cat/allocation/{_quote(node_id)}" + else: + __path = "/_cat/allocation" + __query: Dict[str, Any] = {} + if bytes is not None: + __query["bytes"] = bytes + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if h is not None: + __query["h"] = h + if help is not None: + __query["help"] = help + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if s is not None: + __query["s"] = s + if v is not None: + __query["v"] = v + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain,application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def count( + self, + *, + index: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + h: Optional[Any] = None, + help: Optional[bool] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + s: Optional[List[str]] = None, + v: Optional[bool] = None, + ) -> Any: + """ + 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 - :arg format: a short version of the Accept header, e.g. json, - yaml - :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 - to sort by - :arg v: Verbose mode. Display column headers + :param index: A comma-separated list of index names to limit the returned information + :param format: Specifies the format to return the columnar data in, can be set + to `text`, `json`, `cbor`, `yaml`, or `smile`. + :param h: List of columns to appear in the response. Supports simple wildcards. + :param help: When set to `true` will output available columns. This option can't + be combined with any other query string option. + :param local: If `true`, the request computes the list of selected nodes from + the local cluster state. If `false` the list of selected nodes are computed + from the cluster state of the master node. In both cases the coordinating + node will send requests for further information to each selected node. + :param master_timeout: Period to wait for a connection to the master node. + :param s: List of columns that determine how the table should be sorted. Sorting + defaults to ascending and can be changed by setting `:asc` or `:desc` as + a suffix to the column name. + :param v: When set to `true` will enable verbose output. + """ + if index not in SKIP_IN_PATH: + __path = f"/_cat/count/{_quote(index)}" + else: + __path = "/_cat/count" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if h is not None: + __query["h"] = h + if help is not None: + __query["help"] = help + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if s is not None: + __query["s"] = s + if v is not None: + __query["v"] = v + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain,application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def fielddata( + self, + *, + fields: Optional[Any] = None, + bytes: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + h: Optional[Any] = None, + help: Optional[bool] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + s: Optional[List[str]] = None, + v: Optional[bool] = None, + ) -> Any: """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", _make_path("_cat", "count", index), params=params, headers=headers - ) + Shows how much heap memory is currently being used by fielddata on every data + node in the cluster. + + ``_ - @query_params("format", "h", "help", "s", "time", "ts", "v") - async def health(self, params=None, headers=None): + :param fields: A comma-separated list of fields to return the fielddata size + :param bytes: The unit in which to display byte values + :param format: Specifies the format to return the columnar data in, can be set + to `text`, `json`, `cbor`, `yaml`, or `smile`. + :param h: List of columns to appear in the response. Supports simple wildcards. + :param help: When set to `true` will output available columns. This option can't + be combined with any other query string option. + :param local: If `true`, the request computes the list of selected nodes from + the local cluster state. If `false` the list of selected nodes are computed + from the cluster state of the master node. In both cases the coordinating + node will send requests for further information to each selected node. + :param master_timeout: Period to wait for a connection to the master node. + :param s: List of columns that determine how the table should be sorted. Sorting + defaults to ascending and can be changed by setting `:asc` or `:desc` as + a suffix to the column name. + :param v: When set to `true` will enable verbose output. + """ + if fields not in SKIP_IN_PATH: + __path = f"/_cat/fielddata/{_quote(fields)}" + else: + __path = "/_cat/fielddata" + __query: Dict[str, Any] = {} + if bytes is not None: + __query["bytes"] = bytes + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if h is not None: + __query["h"] = h + if help is not None: + __query["help"] = help + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if s is not None: + __query["s"] = s + if v is not None: + __query["v"] = v + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain,application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def health( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + h: Optional[Any] = None, + help: Optional[bool] = None, + human: Optional[bool] = None, + include_timestamp: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + s: Optional[List[str]] = None, + ts: Optional[bool] = None, + v: Optional[bool] = None, + ) -> Any: """ Returns a concise representation of the cluster health. ``_ - :arg format: a short version of the Accept header, e.g. json, - yaml - :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 - to sort by - :arg time: The unit in which to display time values Valid - choices: d, h, m, s, ms, micros, nanos - :arg ts: Set to false to disable timestamping Default: True - :arg v: Verbose mode. Display column headers - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", "/_cat/health", params=params, headers=headers - ) - - @query_params("help", "s") - async def help(self, params=None, headers=None): + :param format: Specifies the format to return the columnar data in, can be set + to `text`, `json`, `cbor`, `yaml`, or `smile`. + :param h: List of columns to appear in the response. Supports simple wildcards. + :param help: When set to `true` will output available columns. This option can't + be combined with any other query string option. + :param include_timestamp: + :param local: If `true`, the request computes the list of selected nodes from + the local cluster state. If `false` the list of selected nodes are computed + from the cluster state of the master node. In both cases the coordinating + node will send requests for further information to each selected node. + :param master_timeout: Period to wait for a connection to the master node. + :param s: List of columns that determine how the table should be sorted. Sorting + defaults to ascending and can be changed by setting `:asc` or `:desc` as + a suffix to the column name. + :param ts: Set to false to disable timestamping + :param v: When set to `true` will enable verbose output. + """ + __path = "/_cat/health" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if h is not None: + __query["h"] = h + if help is not None: + __query["help"] = help + if human is not None: + __query["human"] = human + if include_timestamp is not None: + __query["include_timestamp"] = include_timestamp + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if s is not None: + __query["s"] = s + if ts is not None: + __query["ts"] = ts + if v is not None: + __query["v"] = v + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain,application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def help( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + h: Optional[Any] = None, + help: Optional[bool] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + s: Optional[List[str]] = None, + v: Optional[bool] = None, + ) -> Any: """ 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 - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", "/_cat", params=params, headers=headers - ) - - @query_params( - "bytes", - "expand_wildcards", - "format", - "h", - "health", - "help", - "include_unloaded_segments", - "master_timeout", - "pri", - "s", - "time", - "v", - ) - async def indices(self, index=None, params=None, headers=None): + :param format: Specifies the format to return the columnar data in, can be set + to `text`, `json`, `cbor`, `yaml`, or `smile`. + :param h: List of columns to appear in the response. Supports simple wildcards. + :param help: When set to `true` will output available columns. This option can't + be combined with any other query string option. + :param local: If `true`, the request computes the list of selected nodes from + the local cluster state. If `false` the list of selected nodes are computed + from the cluster state of the master node. In both cases the coordinating + node will send requests for further information to each selected node. + :param master_timeout: Period to wait for a connection to the master node. + :param s: List of columns that determine how the table should be sorted. Sorting + defaults to ascending and can be changed by setting `:asc` or `:desc` as + a suffix to the column name. + :param v: When set to `true` will enable verbose output. + """ + __path = "/_cat" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if h is not None: + __query["h"] = h + if help is not None: + __query["help"] = help + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if s is not None: + __query["s"] = s + if v is not None: + __query["v"] = v + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def indices( + self, + *, + index: Optional[Any] = None, + bytes: Optional[Any] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + h: Optional[Any] = None, + health: Optional[Any] = None, + help: Optional[bool] = None, + human: Optional[bool] = None, + include_unloaded_segments: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + pri: Optional[bool] = None, + s: Optional[List[str]] = None, + v: Optional[bool] = None, + ) -> Any: """ 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 - :arg bytes: The unit in which to display byte values Valid - choices: b, k, kb, m, mb, g, gb, t, tb, p, pb - :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: all - :arg format: a short version of the Accept header, e.g. json, - yaml - :arg h: Comma-separated list of column names to display - :arg health: A health status ("green", "yellow", or "red" to - filter only indices matching the specified health status Valid choices: - green, yellow, red - :arg help: Return help information - :arg include_unloaded_segments: If set to true segment stats - will include stats for segments that are not currently loaded into - memory - :arg master_timeout: Explicit operation timeout for connection - to master node - :arg pri: Set to true to return stats only for primary shards - :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 v: Verbose mode. Display column headers - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", _make_path("_cat", "indices", index), params=params, headers=headers - ) - - @query_params("format", "h", "help", "local", "master_timeout", "s", "v") - async def master(self, params=None, headers=None): + :param index: A comma-separated list of index names to limit the returned information + :param bytes: The unit in which to display byte values + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param format: Specifies the format to return the columnar data in, can be set + to `text`, `json`, `cbor`, `yaml`, or `smile`. + :param h: List of columns to appear in the response. Supports simple wildcards. + :param health: A health status ("green", "yellow", or "red" to filter only indices + matching the specified health status + :param help: When set to `true` will output available columns. This option can't + be combined with any other query string option. + :param include_unloaded_segments: If set to true segment stats will include stats + for segments that are not currently loaded into memory + :param local: If `true`, the request computes the list of selected nodes from + the local cluster state. If `false` the list of selected nodes are computed + from the cluster state of the master node. In both cases the coordinating + node will send requests for further information to each selected node. + :param master_timeout: Period to wait for a connection to the master node. + :param pri: Set to true to return stats only for primary shards + :param s: List of columns that determine how the table should be sorted. Sorting + defaults to ascending and can be changed by setting `:asc` or `:desc` as + a suffix to the column name. + :param v: When set to `true` will enable verbose output. + """ + if index not in SKIP_IN_PATH: + __path = f"/_cat/indices/{_quote(index)}" + else: + __path = "/_cat/indices" + __query: Dict[str, Any] = {} + if bytes is not None: + __query["bytes"] = bytes + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if h is not None: + __query["h"] = h + if health is not None: + __query["health"] = health + if help is not None: + __query["help"] = help + if human is not None: + __query["human"] = human + if include_unloaded_segments is not None: + __query["include_unloaded_segments"] = include_unloaded_segments + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if pri is not None: + __query["pri"] = pri + if s is not None: + __query["s"] = s + if v is not None: + __query["v"] = v + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain,application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def master( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + h: Optional[Any] = None, + help: Optional[bool] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + s: Optional[List[str]] = None, + v: Optional[bool] = None, + ) -> Any: """ Returns information about the master node. ``_ - :arg format: a short version of the Accept header, e.g. json, - yaml - :arg h: Comma-separated list of column names to display - :arg help: Return help information - :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 - :arg s: Comma-separated list of column names or column aliases - to sort by - :arg v: Verbose mode. Display column headers - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", "/_cat/master", params=params, headers=headers - ) - - @query_params( - "bytes", - "format", - "full_id", - "h", - "help", - "include_unloaded_segments", - "master_timeout", - "s", - "time", - "v", - ) - async def nodes(self, params=None, headers=None): + :param format: Specifies the format to return the columnar data in, can be set + to `text`, `json`, `cbor`, `yaml`, or `smile`. + :param h: List of columns to appear in the response. Supports simple wildcards. + :param help: When set to `true` will output available columns. This option can't + be combined with any other query string option. + :param local: If `true`, the request computes the list of selected nodes from + the local cluster state. If `false` the list of selected nodes are computed + from the cluster state of the master node. In both cases the coordinating + node will send requests for further information to each selected node. + :param master_timeout: Period to wait for a connection to the master node. + :param s: List of columns that determine how the table should be sorted. Sorting + defaults to ascending and can be changed by setting `:asc` or `:desc` as + a suffix to the column name. + :param v: When set to `true` will enable verbose output. """ - Returns basic statistics about performance of cluster nodes. + __path = "/_cat/master" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if h is not None: + __query["h"] = h + if help is not None: + __query["help"] = help + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if s is not None: + __query["s"] = s + if v is not None: + __query["v"] = v + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain,application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def ml_data_frame_analytics( + self, + *, + id: Optional[Any] = None, + allow_no_match: Optional[bool] = None, + bytes: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + h: Optional[Any] = None, + help: Optional[bool] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + s: Optional[List[str]] = None, + v: Optional[bool] = None, + ) -> Any: + """ + Gets configuration and usage information about data frame analytics jobs. - ``_ + ``_ + + :param id: The ID of the data frame analytics to fetch + :param allow_no_match: Whether to ignore if a wildcard expression matches no + configs. (This includes `_all` string or when no configs have been specified) + :param bytes: The unit in which to display byte values + :param format: Specifies the format to return the columnar data in, can be set + to `text`, `json`, `cbor`, `yaml`, or `smile`. + :param h: List of columns to appear in the response. Supports simple wildcards. + :param help: When set to `true` will output available columns. This option can't + be combined with any other query string option. + :param local: If `true`, the request computes the list of selected nodes from + the local cluster state. If `false` the list of selected nodes are computed + from the cluster state of the master node. In both cases the coordinating + node will send requests for further information to each selected node. + :param master_timeout: Period to wait for a connection to the master node. + :param s: List of columns that determine how the table should be sorted. Sorting + defaults to ascending and can be changed by setting `:asc` or `:desc` as + a suffix to the column name. + :param v: When set to `true` will enable verbose output. + """ + if id not in SKIP_IN_PATH: + __path = f"/_cat/ml/data_frame/analytics/{_quote(id)}" + else: + __path = "/_cat/ml/data_frame/analytics" + __query: Dict[str, Any] = {} + if allow_no_match is not None: + __query["allow_no_match"] = allow_no_match + if bytes is not None: + __query["bytes"] = bytes + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if h is not None: + __query["h"] = h + if help is not None: + __query["help"] = help + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if s is not None: + __query["s"] = s + if v is not None: + __query["v"] = v + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain,application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def ml_datafeeds( + self, + *, + datafeed_id: Optional[Any] = None, + allow_no_match: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + h: Optional[Any] = None, + help: Optional[bool] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + s: Optional[List[str]] = None, + time: Optional[Any] = None, + v: Optional[bool] = None, + ) -> Any: + """ + Gets configuration and usage information about datafeeds. + + ``_ + + :param datafeed_id: A numerical character string that uniquely identifies the + datafeed. This identifier can contain lowercase alphanumeric characters (a-z + and 0-9), hyphens, and underscores. It must start and end with alphanumeric + characters. + :param allow_no_match: Specifies what to do when the request: * Contains wildcard + expressions and there are no datafeeds that match. * Contains the `_all` + string or no identifiers and there are no matches. * Contains wildcard expressions + and there are only partial matches. If `true`, the API returns an empty datafeeds + array when there are no matches and the subset of results when there are + partial matches. If `false`, the API returns a 404 status code when there + are no matches or only partial matches. + :param format: Specifies the format to return the columnar data in, can be set + to `text`, `json`, `cbor`, `yaml`, or `smile`. + :param h: List of columns to appear in the response. Supports simple wildcards. + :param help: When set to `true` will output available columns. This option can't + be combined with any other query string option. + :param local: If `true`, the request computes the list of selected nodes from + the local cluster state. If `false` the list of selected nodes are computed + from the cluster state of the master node. In both cases the coordinating + node will send requests for further information to each selected node. + :param master_timeout: Period to wait for a connection to the master node. + :param s: List of columns that determine how the table should be sorted. Sorting + defaults to ascending and can be changed by setting `:asc` or `:desc` as + a suffix to the column name. + :param time: The unit used to display time values. + :param v: When set to `true` will enable verbose output. + """ + if datafeed_id not in SKIP_IN_PATH: + __path = f"/_cat/ml/datafeeds/{_quote(datafeed_id)}" + else: + __path = "/_cat/ml/datafeeds" + __query: Dict[str, Any] = {} + if allow_no_match is not None: + __query["allow_no_match"] = allow_no_match + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if h is not None: + __query["h"] = h + if help is not None: + __query["help"] = help + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if s is not None: + __query["s"] = s + if time is not None: + __query["time"] = time + if v is not None: + __query["v"] = v + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain,application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def ml_jobs( + self, + *, + job_id: Optional[Any] = None, + allow_no_match: Optional[bool] = None, + bytes: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + h: Optional[Any] = None, + help: Optional[bool] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + s: Optional[List[str]] = None, + time: Optional[Any] = None, + v: Optional[bool] = None, + ) -> Any: + """ + Gets configuration and usage information about anomaly detection jobs. - :arg bytes: The unit in which to display byte values Valid - 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 full_id: Return the full node ID instead of the shortened - version (default: false) - :arg h: Comma-separated list of column names to display - :arg help: Return help information - :arg include_unloaded_segments: If set to true segment stats - will include stats for segments that are not currently loaded into - memory - :arg master_timeout: Explicit operation timeout for connection - 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 v: Verbose mode. Display column headers - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", "/_cat/nodes", params=params, headers=headers - ) - - @query_params( - "active_only", "bytes", "detailed", "format", "h", "help", "s", "time", "v" + ``_ + + :param job_id: Identifier for the anomaly detection job. + :param allow_no_match: Specifies what to do when the request: * Contains wildcard + expressions and there are no jobs that match. * Contains the `_all` string + or no identifiers and there are no matches. * Contains wildcard expressions + and there are only partial matches. If `true`, the API returns an empty jobs + array when there are no matches and the subset of results when there are + partial matches. If `false`, the API returns a 404 status code when there + are no matches or only partial matches. + :param bytes: The unit used to display byte values. + :param format: Specifies the format to return the columnar data in, can be set + to `text`, `json`, `cbor`, `yaml`, or `smile`. + :param h: List of columns to appear in the response. Supports simple wildcards. + :param help: When set to `true` will output available columns. This option can't + be combined with any other query string option. + :param local: If `true`, the request computes the list of selected nodes from + the local cluster state. If `false` the list of selected nodes are computed + from the cluster state of the master node. In both cases the coordinating + node will send requests for further information to each selected node. + :param master_timeout: Period to wait for a connection to the master node. + :param s: List of columns that determine how the table should be sorted. Sorting + defaults to ascending and can be changed by setting `:asc` or `:desc` as + a suffix to the column name. + :param time: The unit used to display time values. + :param v: When set to `true` will enable verbose output. + """ + if job_id not in SKIP_IN_PATH: + __path = f"/_cat/ml/anomaly_detectors/{_quote(job_id)}" + else: + __path = "/_cat/ml/anomaly_detectors" + __query: Dict[str, Any] = {} + if allow_no_match is not None: + __query["allow_no_match"] = allow_no_match + if bytes is not None: + __query["bytes"] = bytes + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if h is not None: + __query["h"] = h + if help is not None: + __query["help"] = help + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if s is not None: + __query["s"] = s + if time is not None: + __query["time"] = time + if v is not None: + __query["v"] = v + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain,application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + parameter_aliases={"from": "from_"}, ) - async def recovery(self, index=None, params=None, headers=None): + async def ml_trained_models( + self, + *, + model_id: Optional[Any] = None, + allow_no_match: Optional[bool] = None, + bytes: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + from_: Optional[int] = None, + h: Optional[Any] = None, + help: Optional[bool] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + s: Optional[List[str]] = None, + size: Optional[int] = None, + v: Optional[bool] = None, + ) -> Any: """ - Returns information about index shard recoveries, both on-going completed. + Gets configuration and usage information about inference trained models. - ``_ + ``_ - :arg index: Comma-separated list or wildcard expression of index - names to limit the returned information - :arg active_only: If `true`, the response only includes ongoing - shard recoveries - :arg bytes: The unit in which to display byte values Valid - choices: b, k, kb, m, mb, g, gb, t, tb, p, pb - :arg detailed: If `true`, the response includes detailed - information about shard recoveries - :arg format: a short version of the Accept header, e.g. json, - yaml - :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 - to sort by - :arg time: The unit in which to display time values Valid - choices: d, h, m, s, ms, micros, nanos - :arg v: Verbose mode. Display column headers - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", _make_path("_cat", "recovery", index), params=params, headers=headers - ) - - @query_params("bytes", "format", "h", "help", "master_timeout", "s", "time", "v") - async def shards(self, index=None, params=None, headers=None): + :param model_id: The ID of the trained models stats to fetch + :param 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) + :param bytes: The unit in which to display byte values + :param format: Specifies the format to return the columnar data in, can be set + to `text`, `json`, `cbor`, `yaml`, or `smile`. + :param from_: skips a number of trained models + :param h: List of columns to appear in the response. Supports simple wildcards. + :param help: When set to `true` will output available columns. This option can't + be combined with any other query string option. + :param local: If `true`, the request computes the list of selected nodes from + the local cluster state. If `false` the list of selected nodes are computed + from the cluster state of the master node. In both cases the coordinating + node will send requests for further information to each selected node. + :param master_timeout: Period to wait for a connection to the master node. + :param s: List of columns that determine how the table should be sorted. Sorting + defaults to ascending and can be changed by setting `:asc` or `:desc` as + a suffix to the column name. + :param size: specifies a max number of trained models to get + :param v: When set to `true` will enable verbose output. """ - Provides a detailed view of shard allocation on nodes. + if model_id not in SKIP_IN_PATH: + __path = f"/_cat/ml/trained_models/{_quote(model_id)}" + else: + __path = "/_cat/ml/trained_models" + __query: Dict[str, Any] = {} + if allow_no_match is not None: + __query["allow_no_match"] = allow_no_match + if bytes is not None: + __query["bytes"] = bytes + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if from_ is not None: + __query["from"] = from_ + if h is not None: + __query["h"] = h + if help is not None: + __query["help"] = help + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if s is not None: + __query["s"] = s + if size is not None: + __query["size"] = size + if v is not None: + __query["v"] = v + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain,application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def nodeattrs( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + h: Optional[Any] = None, + help: Optional[bool] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + s: Optional[List[str]] = None, + v: Optional[bool] = None, + ) -> Any: + """ + Returns information about custom node attributes. - ``_ + ``_ - :arg index: A comma-separated list of index names to limit the - returned information - :arg bytes: The unit in which to display byte values Valid - 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 h: Comma-separated list of column names to display - :arg help: Return help information - :arg master_timeout: Explicit operation timeout for connection - 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 v: Verbose mode. Display column headers - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", _make_path("_cat", "shards", index), params=params, headers=headers - ) - - @query_params("bytes", "format", "h", "help", "s", "v") - async def segments(self, index=None, params=None, headers=None): + :param format: Specifies the format to return the columnar data in, can be set + to `text`, `json`, `cbor`, `yaml`, or `smile`. + :param h: List of columns to appear in the response. Supports simple wildcards. + :param help: When set to `true` will output available columns. This option can't + be combined with any other query string option. + :param local: If `true`, the request computes the list of selected nodes from + the local cluster state. If `false` the list of selected nodes are computed + from the cluster state of the master node. In both cases the coordinating + node will send requests for further information to each selected node. + :param master_timeout: Period to wait for a connection to the master node. + :param s: List of columns that determine how the table should be sorted. Sorting + defaults to ascending and can be changed by setting `:asc` or `:desc` as + a suffix to the column name. + :param v: When set to `true` will enable verbose output. """ - Provides low-level information about the segments in the shards of an index. + __path = "/_cat/nodeattrs" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if h is not None: + __query["h"] = h + if help is not None: + __query["help"] = help + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if s is not None: + __query["s"] = s + if v is not None: + __query["v"] = v + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain,application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def nodes( + self, + *, + bytes: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + full_id: Optional[Union[bool, str]] = None, + h: Optional[Any] = None, + help: Optional[bool] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + s: Optional[List[str]] = None, + v: Optional[bool] = None, + ) -> Any: + """ + Returns basic statistics about performance of cluster nodes. - ``_ + ``_ - :arg index: A comma-separated list of index names to limit the - returned information - :arg bytes: The unit in which to display byte values Valid - 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 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 - to sort by - :arg v: Verbose mode. Display column headers - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", _make_path("_cat", "segments", index), params=params, headers=headers - ) - - @query_params("format", "h", "help", "local", "master_timeout", "s", "time", "v") - async def pending_tasks(self, params=None, headers=None): + :param bytes: The unit in which to display byte values + :param format: Specifies the format to return the columnar data in, can be set + to `text`, `json`, `cbor`, `yaml`, or `smile`. + :param full_id: Return the full node ID instead of the shortened version (default: + false) + :param h: List of columns to appear in the response. Supports simple wildcards. + :param help: When set to `true` will output available columns. This option can't + be combined with any other query string option. + :param local: If `true`, the request computes the list of selected nodes from + the local cluster state. If `false` the list of selected nodes are computed + from the cluster state of the master node. In both cases the coordinating + node will send requests for further information to each selected node. + :param master_timeout: Period to wait for a connection to the master node. + :param s: List of columns that determine how the table should be sorted. Sorting + defaults to ascending and can be changed by setting `:asc` or `:desc` as + a suffix to the column name. + :param v: When set to `true` will enable verbose output. + """ + __path = "/_cat/nodes" + __query: Dict[str, Any] = {} + if bytes is not None: + __query["bytes"] = bytes + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if full_id is not None: + __query["full_id"] = full_id + if h is not None: + __query["h"] = h + if help is not None: + __query["help"] = help + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if s is not None: + __query["s"] = s + if v is not None: + __query["v"] = v + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain,application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def pending_tasks( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + h: Optional[Any] = None, + help: Optional[bool] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + s: Optional[List[str]] = None, + v: Optional[bool] = None, + ) -> Any: """ Returns a concise representation of the cluster pending tasks. ``_ - :arg format: a short version of the Accept header, e.g. json, - yaml - :arg h: Comma-separated list of column names to display - :arg help: Return help information - :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 - :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 v: Verbose mode. Display column headers - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", "/_cat/pending_tasks", params=params, headers=headers - ) - - @query_params("format", "h", "help", "local", "master_timeout", "s", "time", "v") - async def thread_pool(self, thread_pool_patterns=None, params=None, headers=None): + :param format: Specifies the format to return the columnar data in, can be set + to `text`, `json`, `cbor`, `yaml`, or `smile`. + :param h: List of columns to appear in the response. Supports simple wildcards. + :param help: When set to `true` will output available columns. This option can't + be combined with any other query string option. + :param local: If `true`, the request computes the list of selected nodes from + the local cluster state. If `false` the list of selected nodes are computed + from the cluster state of the master node. In both cases the coordinating + node will send requests for further information to each selected node. + :param master_timeout: Period to wait for a connection to the master node. + :param s: List of columns that determine how the table should be sorted. Sorting + defaults to ascending and can be changed by setting `:asc` or `:desc` as + a suffix to the column name. + :param v: When set to `true` will enable verbose output. """ - Returns cluster-wide thread pool statistics per node. By default the active, - queue and rejected statistics are returned for all thread pools. + __path = "/_cat/pending_tasks" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if h is not None: + __query["h"] = h + if help is not None: + __query["help"] = help + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if s is not None: + __query["s"] = s + if v is not None: + __query["v"] = v + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain,application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def plugins( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + h: Optional[Any] = None, + help: Optional[bool] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + s: Optional[List[str]] = None, + v: Optional[bool] = None, + ) -> Any: + """ + Returns information about installed plugins across nodes node. - ``_ + ``_ - :arg thread_pool_patterns: A comma-separated list of regular- - expressions to filter the thread pools in the output - :arg format: a short version of the Accept header, e.g. json, - yaml - :arg h: Comma-separated list of column names to display - :arg help: Return help information - :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 - :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 v: Verbose mode. Display column headers - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", - _make_path("_cat", "thread_pool", thread_pool_patterns), - params=params, - headers=headers, - ) - - @query_params("bytes", "format", "h", "help", "s", "v") - async def fielddata(self, fields=None, params=None, headers=None): + :param format: Specifies the format to return the columnar data in, can be set + to `text`, `json`, `cbor`, `yaml`, or `smile`. + :param h: List of columns to appear in the response. Supports simple wildcards. + :param help: When set to `true` will output available columns. This option can't + be combined with any other query string option. + :param local: If `true`, the request computes the list of selected nodes from + the local cluster state. If `false` the list of selected nodes are computed + from the cluster state of the master node. In both cases the coordinating + node will send requests for further information to each selected node. + :param master_timeout: Period to wait for a connection to the master node. + :param s: List of columns that determine how the table should be sorted. Sorting + defaults to ascending and can be changed by setting `:asc` or `:desc` as + a suffix to the column name. + :param v: When set to `true` will enable verbose output. """ - Shows how much heap memory is currently being used by fielddata on every data - node in the cluster. + __path = "/_cat/plugins" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if h is not None: + __query["h"] = h + if help is not None: + __query["help"] = help + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if s is not None: + __query["s"] = s + if v is not None: + __query["v"] = v + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain,application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def recovery( + self, + *, + index: Optional[Any] = None, + active_only: Optional[bool] = None, + bytes: Optional[Any] = None, + detailed: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + h: Optional[Any] = None, + help: Optional[bool] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + s: Optional[List[str]] = None, + v: Optional[bool] = None, + ) -> Any: + """ + Returns information about index shard recoveries, both on-going completed. - ``_ + ``_ - :arg fields: A comma-separated list of fields to return in the - output - :arg bytes: The unit in which to display byte values Valid - 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 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 - to sort by - :arg v: Verbose mode. Display column headers - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", - _make_path("_cat", "fielddata", fields), - params=params, - headers=headers, - ) - - @query_params( - "format", "h", "help", "include_bootstrap", "local", "master_timeout", "s", "v" - ) - async def plugins(self, params=None, headers=None): + :param index: Comma-separated list or wildcard expression of index names to limit + the returned information + :param active_only: If `true`, the response only includes ongoing shard recoveries + :param bytes: The unit in which to display byte values + :param detailed: If `true`, the response includes detailed information about + shard recoveries + :param format: Specifies the format to return the columnar data in, can be set + to `text`, `json`, `cbor`, `yaml`, or `smile`. + :param h: List of columns to appear in the response. Supports simple wildcards. + :param help: When set to `true` will output available columns. This option can't + be combined with any other query string option. + :param local: If `true`, the request computes the list of selected nodes from + the local cluster state. If `false` the list of selected nodes are computed + from the cluster state of the master node. In both cases the coordinating + node will send requests for further information to each selected node. + :param master_timeout: Period to wait for a connection to the master node. + :param s: List of columns that determine how the table should be sorted. Sorting + defaults to ascending and can be changed by setting `:asc` or `:desc` as + a suffix to the column name. + :param v: When set to `true` will enable verbose output. """ - Returns information about installed plugins across nodes node. + if index not in SKIP_IN_PATH: + __path = f"/_cat/recovery/{_quote(index)}" + else: + __path = "/_cat/recovery" + __query: Dict[str, Any] = {} + if active_only is not None: + __query["active_only"] = active_only + if bytes is not None: + __query["bytes"] = bytes + if detailed is not None: + __query["detailed"] = detailed + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if h is not None: + __query["h"] = h + if help is not None: + __query["help"] = help + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if s is not None: + __query["s"] = s + if v is not None: + __query["v"] = v + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain,application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def repositories( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + h: Optional[Any] = None, + help: Optional[bool] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + s: Optional[List[str]] = None, + v: Optional[bool] = None, + ) -> Any: + """ + Returns information about snapshot repositories registered in the cluster. - ``_ + ``_ - :arg format: a short version of the Accept header, e.g. json, - yaml - :arg h: Comma-separated list of column names to display - :arg help: Return help information - :arg include_bootstrap: Include bootstrap plugins in the - response - :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 - :arg s: Comma-separated list of column names or column aliases - to sort by - :arg v: Verbose mode. Display column headers - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", "/_cat/plugins", params=params, headers=headers - ) - - @query_params("format", "h", "help", "local", "master_timeout", "s", "v") - async def nodeattrs(self, params=None, headers=None): + :param format: Specifies the format to return the columnar data in, can be set + to `text`, `json`, `cbor`, `yaml`, or `smile`. + :param h: List of columns to appear in the response. Supports simple wildcards. + :param help: When set to `true` will output available columns. This option can't + be combined with any other query string option. + :param local: If `true`, the request computes the list of selected nodes from + the local cluster state. If `false` the list of selected nodes are computed + from the cluster state of the master node. In both cases the coordinating + node will send requests for further information to each selected node. + :param master_timeout: Period to wait for a connection to the master node. + :param s: List of columns that determine how the table should be sorted. Sorting + defaults to ascending and can be changed by setting `:asc` or `:desc` as + a suffix to the column name. + :param v: When set to `true` will enable verbose output. """ - Returns information about custom node attributes. + __path = "/_cat/repositories" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if h is not None: + __query["h"] = h + if help is not None: + __query["help"] = help + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if s is not None: + __query["s"] = s + if v is not None: + __query["v"] = v + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain,application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def segments( + self, + *, + index: Optional[Any] = None, + bytes: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + h: Optional[Any] = None, + help: Optional[bool] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + s: Optional[List[str]] = None, + v: Optional[bool] = None, + ) -> Any: + """ + Provides low-level information about the segments in the shards of an index. - ``_ + ``_ - :arg format: a short version of the Accept header, e.g. json, - yaml - :arg h: Comma-separated list of column names to display - :arg help: Return help information - :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 - :arg s: Comma-separated list of column names or column aliases - to sort by - :arg v: Verbose mode. Display column headers - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", "/_cat/nodeattrs", params=params, headers=headers - ) - - @query_params("format", "h", "help", "local", "master_timeout", "s", "v") - async def repositories(self, params=None, headers=None): + :param index: A comma-separated list of index names to limit the returned information + :param bytes: The unit in which to display byte values + :param format: Specifies the format to return the columnar data in, can be set + to `text`, `json`, `cbor`, `yaml`, or `smile`. + :param h: List of columns to appear in the response. Supports simple wildcards. + :param help: When set to `true` will output available columns. This option can't + be combined with any other query string option. + :param local: If `true`, the request computes the list of selected nodes from + the local cluster state. If `false` the list of selected nodes are computed + from the cluster state of the master node. In both cases the coordinating + node will send requests for further information to each selected node. + :param master_timeout: Period to wait for a connection to the master node. + :param s: List of columns that determine how the table should be sorted. Sorting + defaults to ascending and can be changed by setting `:asc` or `:desc` as + a suffix to the column name. + :param v: When set to `true` will enable verbose output. """ - Returns information about snapshot repositories registered in the cluster. + if index not in SKIP_IN_PATH: + __path = f"/_cat/segments/{_quote(index)}" + else: + __path = "/_cat/segments" + __query: Dict[str, Any] = {} + if bytes is not None: + __query["bytes"] = bytes + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if h is not None: + __query["h"] = h + if help is not None: + __query["help"] = help + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if s is not None: + __query["s"] = s + if v is not None: + __query["v"] = v + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain,application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def shards( + self, + *, + index: Optional[Any] = None, + bytes: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + h: Optional[Any] = None, + help: Optional[bool] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + s: Optional[List[str]] = None, + v: Optional[bool] = None, + ) -> Any: + """ + Provides a detailed view of shard allocation on nodes. - ``_ + ``_ - :arg format: a short version of the Accept header, e.g. json, - yaml - :arg h: Comma-separated list of column names to display - :arg help: Return help information - :arg local: Return local information, do not retrieve the state - from master node - :arg master_timeout: Explicit operation timeout for connection - to master node - :arg s: Comma-separated list of column names or column aliases - to sort by - :arg v: Verbose mode. Display column headers - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", "/_cat/repositories", params=params, headers=headers - ) - - @query_params( - "format", "h", "help", "ignore_unavailable", "master_timeout", "s", "time", "v" - ) - async def snapshots(self, repository=None, params=None, headers=None): + :param index: A comma-separated list of index names to limit the returned information + :param bytes: The unit in which to display byte values + :param format: Specifies the format to return the columnar data in, can be set + to `text`, `json`, `cbor`, `yaml`, or `smile`. + :param h: List of columns to appear in the response. Supports simple wildcards. + :param help: When set to `true` will output available columns. This option can't + be combined with any other query string option. + :param local: If `true`, the request computes the list of selected nodes from + the local cluster state. If `false` the list of selected nodes are computed + from the cluster state of the master node. In both cases the coordinating + node will send requests for further information to each selected node. + :param master_timeout: Period to wait for a connection to the master node. + :param s: List of columns that determine how the table should be sorted. Sorting + defaults to ascending and can be changed by setting `:asc` or `:desc` as + a suffix to the column name. + :param v: When set to `true` will enable verbose output. + """ + if index not in SKIP_IN_PATH: + __path = f"/_cat/shards/{_quote(index)}" + else: + __path = "/_cat/shards" + __query: Dict[str, Any] = {} + if bytes is not None: + __query["bytes"] = bytes + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if h is not None: + __query["h"] = h + if help is not None: + __query["help"] = help + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if s is not None: + __query["s"] = s + if v is not None: + __query["v"] = v + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain,application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def snapshots( + self, + *, + repository: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + h: Optional[Any] = None, + help: Optional[bool] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + s: Optional[List[str]] = None, + v: Optional[bool] = None, + ) -> Any: """ Returns all snapshots in a specific repository. ``_ - :arg repository: Name of repository from which to fetch the - snapshot information - :arg format: a short version of the Accept header, e.g. json, - yaml - :arg h: Comma-separated list of column names to display - :arg help: Return help information - :arg ignore_unavailable: Set to true to ignore unavailable - snapshots - :arg master_timeout: Explicit operation timeout for connection - 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 v: Verbose mode. Display column headers - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", - _make_path("_cat", "snapshots", repository), - params=params, - headers=headers, - ) - - @query_params( - "actions", - "detailed", - "format", - "h", - "help", - "nodes", - "parent_task_id", - "s", - "time", - "v", - ) - async def tasks(self, params=None, headers=None): + :param repository: Name of repository from which to fetch the snapshot information + :param format: Specifies the format to return the columnar data in, can be set + to `text`, `json`, `cbor`, `yaml`, or `smile`. + :param h: List of columns to appear in the response. Supports simple wildcards. + :param help: When set to `true` will output available columns. This option can't + be combined with any other query string option. + :param ignore_unavailable: Set to true to ignore unavailable snapshots + :param local: If `true`, the request computes the list of selected nodes from + the local cluster state. If `false` the list of selected nodes are computed + from the cluster state of the master node. In both cases the coordinating + node will send requests for further information to each selected node. + :param master_timeout: Period to wait for a connection to the master node. + :param s: List of columns that determine how the table should be sorted. Sorting + defaults to ascending and can be changed by setting `:asc` or `:desc` as + a suffix to the column name. + :param v: When set to `true` will enable verbose output. """ - Returns information about the tasks currently executing on one or more nodes in - the cluster. + if repository not in SKIP_IN_PATH: + __path = f"/_cat/snapshots/{_quote(repository)}" + else: + __path = "/_cat/snapshots" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if h is not None: + __query["h"] = h + if help is not None: + __query["help"] = help + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if s is not None: + __query["s"] = s + if v is not None: + __query["v"] = v + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain,application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def tasks( + self, + *, + actions: Optional[List[str]] = None, + detailed: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + h: Optional[Any] = None, + help: Optional[bool] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + node_id: Optional[List[str]] = None, + parent_task: Optional[int] = None, + pretty: Optional[bool] = None, + s: Optional[List[str]] = None, + v: Optional[bool] = None, + ) -> Any: + """ + Returns information about the tasks currently executing on one or more nodes + in the cluster. ``_ - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - - :arg actions: A comma-separated list of actions that should be - returned. Leave empty to return all. - :arg detailed: Return detailed task information (default: false) - :arg format: a short version of the Accept header, e.g. json, - yaml - :arg h: Comma-separated list of column names to display - :arg help: Return help information - :arg nodes: 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 parent_task_id: Return tasks with specified parent task id - (node_id:task_number). Set to -1 to return all. - :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 v: Verbose mode. Display column headers - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", "/_cat/tasks", params=params, headers=headers - ) - - @query_params("format", "h", "help", "local", "master_timeout", "s", "v") - async def templates(self, name=None, params=None, headers=None): + :param actions: A comma-separated list of actions that should be returned. Leave + empty to return all. + :param detailed: Return detailed task information (default: false) + :param format: Specifies the format to return the columnar data in, can be set + to `text`, `json`, `cbor`, `yaml`, or `smile`. + :param h: List of columns to appear in the response. Supports simple wildcards. + :param help: When set to `true` will output available columns. This option can't + be combined with any other query string option. + :param local: If `true`, the request computes the list of selected nodes from + the local cluster state. If `false` the list of selected nodes are computed + from the cluster state of the master node. In both cases the coordinating + node will send requests for further information to each selected node. + :param master_timeout: Period to wait for a connection to the master node. + :param node_id: + :param parent_task: + :param s: List of columns that determine how the table should be sorted. Sorting + defaults to ascending and can be changed by setting `:asc` or `:desc` as + a suffix to the column name. + :param v: When set to `true` will enable verbose output. + """ + __path = "/_cat/tasks" + __query: Dict[str, Any] = {} + if actions is not None: + __query["actions"] = actions + if detailed is not None: + __query["detailed"] = detailed + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if h is not None: + __query["h"] = h + if help is not None: + __query["help"] = help + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if node_id is not None: + __query["node_id"] = node_id + if parent_task is not None: + __query["parent_task"] = parent_task + if pretty is not None: + __query["pretty"] = pretty + if s is not None: + __query["s"] = s + if v is not None: + __query["v"] = v + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain,application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def templates( + self, + *, + name: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + h: Optional[Any] = None, + help: Optional[bool] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + s: Optional[List[str]] = None, + v: Optional[bool] = None, + ) -> Any: """ 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, - yaml - :arg h: Comma-separated list of column names to display - :arg help: Return help information - :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 - :arg s: Comma-separated list of column names or column aliases - to sort by - :arg v: Verbose mode. Display column headers - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", _make_path("_cat", "templates", name), params=params, headers=headers - ) - - @query_params("allow_no_match", "bytes", "format", "h", "help", "s", "time", "v") - async def ml_data_frame_analytics(self, id=None, params=None, headers=None): + :param name: A pattern that returned template names must match + :param format: Specifies the format to return the columnar data in, can be set + to `text`, `json`, `cbor`, `yaml`, or `smile`. + :param h: List of columns to appear in the response. Supports simple wildcards. + :param help: When set to `true` will output available columns. This option can't + be combined with any other query string option. + :param local: If `true`, the request computes the list of selected nodes from + the local cluster state. If `false` the list of selected nodes are computed + from the cluster state of the master node. In both cases the coordinating + node will send requests for further information to each selected node. + :param master_timeout: Period to wait for a connection to the master node. + :param s: List of columns that determine how the table should be sorted. Sorting + defaults to ascending and can be changed by setting `:asc` or `:desc` as + a suffix to the column name. + :param v: When set to `true` will enable verbose output. """ - Gets configuration and usage information about data frame analytics jobs. + if name not in SKIP_IN_PATH: + __path = f"/_cat/templates/{_quote(name)}" + else: + __path = "/_cat/templates" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if h is not None: + __query["h"] = h + if help is not None: + __query["help"] = help + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if s is not None: + __query["s"] = s + if v is not None: + __query["v"] = v + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain,application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def thread_pool( + self, + *, + thread_pool_patterns: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + h: Optional[Any] = None, + help: Optional[bool] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + s: Optional[List[str]] = None, + size: Optional[Union[Any, bool]] = None, + v: Optional[bool] = None, + ) -> Any: + """ + Returns cluster-wide thread pool statistics per node. By default the active, + queue and rejected statistics are returned for all thread pools. - ``_ + ``_ - :arg id: The ID of the data frame analytics to fetch - :arg allow_no_match: Whether to ignore if a wildcard expression - matches no configs. (This includes `_all` string or when no configs have - been specified) - :arg bytes: The unit in which to display byte values Valid - 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 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 - to sort by - :arg time: The unit in which to display time values Valid - choices: d, h, m, s, ms, micros, nanos - :arg v: Verbose mode. Display column headers - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", - _make_path("_cat", "ml", "data_frame", "analytics", id), - params=params, - headers=headers, - ) - - @query_params( - "allow_no_datafeeds", "allow_no_match", "format", "h", "help", "s", "time", "v" - ) - async def ml_datafeeds(self, datafeed_id=None, params=None, headers=None): + :param thread_pool_patterns: A comma-separated list of regular-expressions to + filter the thread pools in the output + :param format: Specifies the format to return the columnar data in, can be set + to `text`, `json`, `cbor`, `yaml`, or `smile`. + :param h: List of columns to appear in the response. Supports simple wildcards. + :param help: When set to `true` will output available columns. This option can't + be combined with any other query string option. + :param local: If `true`, the request computes the list of selected nodes from + the local cluster state. If `false` the list of selected nodes are computed + from the cluster state of the master node. In both cases the coordinating + node will send requests for further information to each selected node. + :param master_timeout: Period to wait for a connection to the master node. + :param s: List of columns that determine how the table should be sorted. Sorting + defaults to ascending and can be changed by setting `:asc` or `:desc` as + a suffix to the column name. + :param size: + :param v: When set to `true` will enable verbose output. """ - 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 - expression matches no datafeeds. (This includes `_all` string or when no - datafeeds have been specified) - :arg allow_no_match: Whether to ignore if a wildcard expression - matches no datafeeds. (This includes `_all` string or when no datafeeds - have been specified) - :arg format: a short version of the Accept header, e.g. json, - yaml - :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 - to sort by - :arg time: The unit in which to display time values Valid - choices: d, h, m, s, ms, micros, nanos - :arg v: Verbose mode. Display column headers - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", - _make_path("_cat", "ml", "datafeeds", datafeed_id), - params=params, - headers=headers, - ) - - @query_params( - "allow_no_jobs", - "allow_no_match", - "bytes", - "format", - "h", - "help", - "s", - "time", - "v", + if thread_pool_patterns not in SKIP_IN_PATH: + __path = f"/_cat/thread_pool/{_quote(thread_pool_patterns)}" + else: + __path = "/_cat/thread_pool" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if h is not None: + __query["h"] = h + if help is not None: + __query["help"] = help + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if s is not None: + __query["s"] = s + if size is not None: + __query["size"] = size + if v is not None: + __query["v"] = v + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain,application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + parameter_aliases={"from": "from_"}, ) - async def ml_jobs(self, job_id=None, params=None, headers=None): + async def transforms( + self, + *, + transform_id: Optional[Any] = None, + allow_no_match: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + from_: Optional[int] = None, + h: Optional[Any] = None, + help: Optional[bool] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + s: Optional[List[str]] = None, + size: Optional[int] = None, + v: Optional[bool] = None, + ) -> Any: """ - Gets configuration and usage information about anomaly detection jobs. + Gets configuration and usage information about transforms. - ``_ + ``_ - :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) - :arg allow_no_match: Whether to ignore if a wildcard expression - matches no jobs. (This includes `_all` string or when no jobs have been + :param transform_id: The id of the transform for which to get stats. '_all' or + '*' implies all transforms + :param 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 bytes: The unit in which to display byte values Valid - 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 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 - to sort by - :arg time: The unit in which to display time values Valid - choices: d, h, m, s, ms, micros, nanos - :arg v: Verbose mode. Display column headers - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", - _make_path("_cat", "ml", "anomaly_detectors", job_id), - params=params, - headers=headers, - ) - - @query_params( - "allow_no_match", - "bytes", - "format", - "from_", - "h", - "help", - "s", - "size", - "time", - "v", - ) - async def ml_trained_models(self, model_id=None, params=None, headers=None): + :param format: Specifies the format to return the columnar data in, can be set + to `text`, `json`, `cbor`, `yaml`, or `smile`. + :param from_: skips a number of transform configs, defaults to 0 + :param h: List of columns to appear in the response. Supports simple wildcards. + :param help: When set to `true` will output available columns. This option can't + be combined with any other query string option. + :param local: If `true`, the request computes the list of selected nodes from + the local cluster state. If `false` the list of selected nodes are computed + from the cluster state of the master node. In both cases the coordinating + node will send requests for further information to each selected node. + :param master_timeout: Period to wait for a connection to the master node. + :param s: List of columns that determine how the table should be sorted. Sorting + defaults to ascending and can be changed by setting `:asc` or `:desc` as + a suffix to the column name. + :param size: specifies a max number of transforms to get, defaults to 100 + :param v: When set to `true` will enable verbose output. """ - 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 - matches no trained models. (This includes `_all` string or when no - trained models have been specified) Default: True - :arg bytes: The unit in which to display byte values Valid - 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 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 - to sort by - :arg size: specifies a max number of trained models to get - Default: 100 - :arg time: The unit in which to display time values Valid - choices: d, h, m, s, ms, micros, nanos - :arg v: Verbose mode. Display column headers - """ - client, params = _deprecated_options(self, params) - if params and "from_" in params: - params["from"] = params.pop("from_") - - return await client._perform_request( - "GET", - _make_path("_cat", "ml", "trained_models", model_id), - params=params, - headers=headers, - ) - - @query_params( - "allow_no_match", "format", "from_", "h", "help", "s", "size", "time", "v" - ) - 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 - :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 format: a short version of the Accept header, e.g. json, - yaml - :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 - to sort by - :arg size: specifies a max number of transforms to get, defaults - to 100 - :arg time: The unit in which to display time values Valid - choices: d, h, m, s, ms, micros, nanos - :arg v: Verbose mode. Display column headers - """ - client, params = _deprecated_options(self, params) - if params and "from_" in params: - params["from"] = params.pop("from_") - - return await client._perform_request( - "GET", - _make_path("_cat", "transforms", transform_id), - params=params, - headers=headers, - ) + if transform_id not in SKIP_IN_PATH: + __path = f"/_cat/transforms/{_quote(transform_id)}" + else: + __path = "/_cat/transforms" + __query: Dict[str, Any] = {} + if allow_no_match is not None: + __query["allow_no_match"] = allow_no_match + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if from_ is not None: + __query["from"] = from_ + if h is not None: + __query["h"] = h + if help is not None: + __query["help"] = help + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if s is not None: + __query["s"] = s + if size is not None: + __query["size"] = size + if v is not None: + __query["v"] = v + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain,application/json"} + return await self._perform_request("GET", __target, headers=__headers) diff --git a/elasticsearch/_async/client/cat.pyi b/elasticsearch/_async/client/cat.pyi deleted file mode 100644 index 6414d0ab7..000000000 --- a/elasticsearch/_async/client/cat.pyi +++ /dev/null @@ -1,610 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse, TextApiResponse - -from ._base import NamespacedClient - -class CatClient(NamespacedClient): - async def aliases( - self, - *, - name: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - format: Optional[Any] = ..., - h: Optional[Any] = ..., - help: Optional[Any] = ..., - local: Optional[Any] = ..., - s: Optional[Any] = ..., - v: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> Union[ObjectApiResponse[None], TextApiResponse]: ... - async def allocation( - self, - *, - node_id: Optional[Any] = ..., - bytes: Optional[Any] = ..., - format: Optional[Any] = ..., - h: Optional[Any] = ..., - help: Optional[Any] = ..., - local: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - s: Optional[Any] = ..., - v: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> Union[ObjectApiResponse[None], TextApiResponse]: ... - async def count( - self, - *, - index: Optional[Any] = ..., - format: Optional[Any] = ..., - h: Optional[Any] = ..., - help: Optional[Any] = ..., - s: Optional[Any] = ..., - v: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> Union[ObjectApiResponse[None], TextApiResponse]: ... - async def health( - self, - *, - format: Optional[Any] = ..., - h: Optional[Any] = ..., - help: Optional[Any] = ..., - s: Optional[Any] = ..., - time: Optional[Any] = ..., - ts: Optional[Any] = ..., - v: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> Union[ObjectApiResponse[None], TextApiResponse]: ... - async def help( - self, - *, - help: Optional[Any] = ..., - s: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> TextApiResponse: ... - async def indices( - self, - *, - index: Optional[Any] = ..., - bytes: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - format: Optional[Any] = ..., - h: Optional[Any] = ..., - health: Optional[Any] = ..., - help: Optional[Any] = ..., - include_unloaded_segments: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - pri: Optional[Any] = ..., - s: Optional[Any] = ..., - time: Optional[Any] = ..., - v: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> Union[ObjectApiResponse[None], TextApiResponse]: ... - async def master( - self, - *, - format: Optional[Any] = ..., - h: Optional[Any] = ..., - help: Optional[Any] = ..., - local: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - s: Optional[Any] = ..., - v: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> Union[ObjectApiResponse[None], TextApiResponse]: ... - async def nodes( - self, - *, - bytes: Optional[Any] = ..., - format: Optional[Any] = ..., - full_id: Optional[Any] = ..., - h: Optional[Any] = ..., - help: Optional[Any] = ..., - include_unloaded_segments: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - s: Optional[Any] = ..., - time: Optional[Any] = ..., - v: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> Union[ObjectApiResponse[None], TextApiResponse]: ... - async def recovery( - self, - *, - index: Optional[Any] = ..., - active_only: Optional[Any] = ..., - bytes: Optional[Any] = ..., - detailed: Optional[Any] = ..., - format: Optional[Any] = ..., - h: Optional[Any] = ..., - help: Optional[Any] = ..., - s: Optional[Any] = ..., - time: Optional[Any] = ..., - v: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> Union[ObjectApiResponse[None], TextApiResponse]: ... - async def shards( - self, - *, - index: Optional[Any] = ..., - bytes: Optional[Any] = ..., - format: Optional[Any] = ..., - h: Optional[Any] = ..., - help: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - s: Optional[Any] = ..., - time: Optional[Any] = ..., - v: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> Union[ObjectApiResponse[None], TextApiResponse]: ... - async def segments( - self, - *, - index: Optional[Any] = ..., - bytes: Optional[Any] = ..., - format: Optional[Any] = ..., - h: Optional[Any] = ..., - help: Optional[Any] = ..., - s: Optional[Any] = ..., - v: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> Union[ObjectApiResponse[None], TextApiResponse]: ... - async def pending_tasks( - self, - *, - format: Optional[Any] = ..., - h: Optional[Any] = ..., - help: Optional[Any] = ..., - local: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - s: Optional[Any] = ..., - time: Optional[Any] = ..., - v: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> Union[ObjectApiResponse[None], TextApiResponse]: ... - async def thread_pool( - self, - *, - thread_pool_patterns: Optional[Any] = ..., - format: Optional[Any] = ..., - h: Optional[Any] = ..., - help: Optional[Any] = ..., - local: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - s: Optional[Any] = ..., - time: Optional[Any] = ..., - v: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> Union[ObjectApiResponse[None], TextApiResponse]: ... - async def fielddata( - self, - *, - fields: Optional[Any] = ..., - bytes: Optional[Any] = ..., - format: Optional[Any] = ..., - h: Optional[Any] = ..., - help: Optional[Any] = ..., - s: Optional[Any] = ..., - v: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> Union[ObjectApiResponse[None], TextApiResponse]: ... - async def plugins( - self, - *, - format: Optional[Any] = ..., - h: Optional[Any] = ..., - help: Optional[Any] = ..., - include_bootstrap: Optional[Any] = ..., - local: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - s: Optional[Any] = ..., - v: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> Union[ObjectApiResponse[None], TextApiResponse]: ... - async def nodeattrs( - self, - *, - format: Optional[Any] = ..., - h: Optional[Any] = ..., - help: Optional[Any] = ..., - local: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - s: Optional[Any] = ..., - v: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> Union[ObjectApiResponse[None], TextApiResponse]: ... - async def repositories( - self, - *, - format: Optional[Any] = ..., - h: Optional[Any] = ..., - help: Optional[Any] = ..., - local: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - s: Optional[Any] = ..., - v: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> Union[ObjectApiResponse[None], TextApiResponse]: ... - async def snapshots( - self, - *, - repository: Optional[Any] = ..., - format: Optional[Any] = ..., - h: Optional[Any] = ..., - help: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - s: Optional[Any] = ..., - time: Optional[Any] = ..., - v: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> Union[ObjectApiResponse[None], TextApiResponse]: ... - async def tasks( - self, - *, - actions: Optional[Any] = ..., - detailed: Optional[Any] = ..., - format: Optional[Any] = ..., - h: Optional[Any] = ..., - help: Optional[Any] = ..., - nodes: Optional[Any] = ..., - parent_task_id: Optional[Any] = ..., - s: Optional[Any] = ..., - time: Optional[Any] = ..., - v: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> Union[ObjectApiResponse[None], TextApiResponse]: ... - async def templates( - self, - *, - name: Optional[Any] = ..., - format: Optional[Any] = ..., - h: Optional[Any] = ..., - help: Optional[Any] = ..., - local: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - s: Optional[Any] = ..., - v: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> Union[ObjectApiResponse[None], TextApiResponse]: ... - async def ml_data_frame_analytics( - self, - *, - id: Optional[Any] = ..., - allow_no_match: Optional[Any] = ..., - bytes: Optional[Any] = ..., - format: Optional[Any] = ..., - h: Optional[Any] = ..., - help: Optional[Any] = ..., - s: Optional[Any] = ..., - time: Optional[Any] = ..., - v: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> Union[ObjectApiResponse[None], TextApiResponse]: ... - async def ml_datafeeds( - self, - *, - datafeed_id: Optional[Any] = ..., - allow_no_datafeeds: Optional[Any] = ..., - allow_no_match: Optional[Any] = ..., - format: Optional[Any] = ..., - h: Optional[Any] = ..., - help: Optional[Any] = ..., - s: Optional[Any] = ..., - time: Optional[Any] = ..., - v: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> Union[ObjectApiResponse[None], TextApiResponse]: ... - async def ml_jobs( - self, - *, - job_id: Optional[Any] = ..., - allow_no_jobs: Optional[Any] = ..., - allow_no_match: Optional[Any] = ..., - bytes: Optional[Any] = ..., - format: Optional[Any] = ..., - h: Optional[Any] = ..., - help: Optional[Any] = ..., - s: Optional[Any] = ..., - time: Optional[Any] = ..., - v: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> Union[ObjectApiResponse[None], TextApiResponse]: ... - async def ml_trained_models( - self, - *, - model_id: Optional[Any] = ..., - allow_no_match: Optional[Any] = ..., - bytes: Optional[Any] = ..., - format: Optional[Any] = ..., - from_: Optional[Any] = ..., - h: Optional[Any] = ..., - help: Optional[Any] = ..., - s: Optional[Any] = ..., - size: Optional[Any] = ..., - time: Optional[Any] = ..., - v: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> Union[ObjectApiResponse[None], TextApiResponse]: ... - async def transforms( - self, - *, - transform_id: Optional[Any] = ..., - allow_no_match: Optional[Any] = ..., - format: Optional[Any] = ..., - from_: Optional[Any] = ..., - h: Optional[Any] = ..., - help: Optional[Any] = ..., - s: Optional[Any] = ..., - size: Optional[Any] = ..., - time: Optional[Any] = ..., - v: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> Union[ObjectApiResponse[None], TextApiResponse]: ... diff --git a/elasticsearch/_async/client/ccr.py b/elasticsearch/_async/client/ccr.py index ca34a3b32..3edc14f17 100644 --- a/elasticsearch/_async/client/ccr.py +++ b/elasticsearch/_async/client/ccr.py @@ -15,285 +15,723 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params +from .utils import SKIP_IN_PATH, _quote, _quote_query, _rewrite_parameters class CcrClient(NamespacedClient): - @query_params() - async def delete_auto_follow_pattern(self, name, params=None, headers=None): + @_rewrite_parameters() + async def delete_auto_follow_pattern( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Deletes auto-follow patterns. - ``_ + ``_ - :arg name: The name of the auto follow pattern. + :param name: The name of the auto follow pattern. """ - client, params = _deprecated_options(self, params) if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'name'.") - - return await client._perform_request( - "DELETE", - _make_path("_ccr", "auto_follow", name), - params=params, - headers=headers, - ) - - @query_params("wait_for_active_shards") - async def follow(self, index, body, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_ccr/auto_follow/{_quote(name)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + async def follow( + self, + *, + index: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + leader_index: Optional[Any] = None, + max_outstanding_read_requests: Optional[int] = None, + max_outstanding_write_requests: Optional[int] = None, + max_read_request_operation_count: Optional[int] = None, + max_read_request_size: Optional[str] = None, + max_retry_delay: Optional[Any] = None, + max_write_buffer_count: Optional[int] = None, + max_write_buffer_size: Optional[str] = None, + max_write_request_operation_count: Optional[int] = None, + max_write_request_size: Optional[str] = None, + pretty: Optional[bool] = None, + read_poll_timeout: Optional[Any] = None, + remote_cluster: Optional[str] = None, + wait_for_active_shards: Optional[Any] = None, + ) -> Any: """ 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 - related parameters - :arg wait_for_active_shards: Sets the number of shard copies - that must be active before returning. Defaults to 0. Set to `all` for - all shard copies, otherwise set to any non-negative value less than or - equal to the total number of copies for the shard (number of replicas + - 1) Default: 0 + ``_ + + :param index: The name of the follower index + :param leader_index: + :param max_outstanding_read_requests: + :param max_outstanding_write_requests: + :param max_read_request_operation_count: + :param max_read_request_size: + :param max_retry_delay: + :param max_write_buffer_count: + :param max_write_buffer_size: + :param max_write_request_operation_count: + :param max_write_request_size: + :param read_poll_timeout: + :param remote_cluster: + :param wait_for_active_shards: Sets the number of shard copies that must be active + before returning. Defaults to 0. Set to `all` for all shard copies, otherwise + set to any non-negative value less than or equal to the total number of copies + for the shard (number of replicas + 1) """ - client, params = _deprecated_options(self, params) - for param in (index, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "PUT", - _make_path(index, "_ccr", "follow"), - params=params, - headers=headers, - body=body, + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + __path = f"/{_quote(index)}/_ccr/follow" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if leader_index is not None: + __body["leader_index"] = leader_index + if max_outstanding_read_requests is not None: + __body["max_outstanding_read_requests"] = max_outstanding_read_requests + if max_outstanding_write_requests is not None: + __body["max_outstanding_write_requests"] = max_outstanding_write_requests + if max_read_request_operation_count is not None: + __body[ + "max_read_request_operation_count" + ] = max_read_request_operation_count + if max_read_request_size is not None: + __body["max_read_request_size"] = max_read_request_size + if max_retry_delay is not None: + __body["max_retry_delay"] = max_retry_delay + if max_write_buffer_count is not None: + __body["max_write_buffer_count"] = max_write_buffer_count + if max_write_buffer_size is not None: + __body["max_write_buffer_size"] = max_write_buffer_size + if max_write_request_operation_count is not None: + __body[ + "max_write_request_operation_count" + ] = max_write_request_operation_count + if max_write_request_size is not None: + __body["max_write_request_size"] = max_write_request_size + if pretty is not None: + __query["pretty"] = pretty + if read_poll_timeout is not None: + __body["read_poll_timeout"] = read_poll_timeout + if remote_cluster is not None: + __body["remote_cluster"] = remote_cluster + if wait_for_active_shards is not None: + __query["wait_for_active_shards"] = wait_for_active_shards + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "PUT", __target, headers=__headers, body=__body ) - @query_params() - async def follow_info(self, index, params=None, headers=None): + @_rewrite_parameters() + async def follow_info( + self, + *, + index: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Retrieves information about all follower indices, including parameters and - status for each follower index + 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 + :param index: A comma-separated list of index patterns; use `_all` to perform + the operation on all indices """ - client, params = _deprecated_options(self, params) if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return await client._perform_request( - "GET", _make_path(index, "_ccr", "info"), params=params, headers=headers - ) - - @query_params() - async def follow_stats(self, index, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'index'") + __path = f"/{_quote(index)}/_ccr/info" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def follow_stats( + self, + *, + index: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ 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 + :param index: A comma-separated list of index patterns; use `_all` to perform + the operation on all indices """ - client, params = _deprecated_options(self, params) if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return await client._perform_request( - "GET", _make_path(index, "_ccr", "stats"), params=params, headers=headers - ) - - @query_params() - async def forget_follower(self, index, body, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'index'") + __path = f"/{_quote(index)}/_ccr/stats" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + async def forget_follower( + self, + *, + index: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + follower_cluster: Optional[str] = None, + follower_index: Optional[Any] = None, + follower_index_uuid: Optional[Any] = None, + human: Optional[bool] = None, + leader_remote_cluster: Optional[str] = None, + pretty: Optional[bool] = None, + ) -> Any: """ 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 - :arg body: the name and UUID of the follower index, the name of - the cluster containing the follower index, and the alias from the - perspective of that cluster for the remote cluster containing the leader - index + :param index: the name of the leader index for which specified follower retention + leases should be removed + :param follower_cluster: + :param follower_index: + :param follower_index_uuid: + :param leader_remote_cluster: """ - client, params = _deprecated_options(self, params) - for param in (index, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "POST", - _make_path(index, "_ccr", "forget_follower"), - params=params, - headers=headers, - body=body, + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + __path = f"/{_quote(index)}/_ccr/forget_follower" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if follower_cluster is not None: + __body["follower_cluster"] = follower_cluster + if follower_index is not None: + __body["follower_index"] = follower_index + if follower_index_uuid is not None: + __body["follower_index_uuid"] = follower_index_uuid + if human is not None: + __query["human"] = human + if leader_remote_cluster is not None: + __body["leader_remote_cluster"] = leader_remote_cluster + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "POST", __target, headers=__headers, body=__body ) - @query_params() - async def get_auto_follow_pattern(self, name=None, params=None, headers=None): + @_rewrite_parameters() + async def get_auto_follow_pattern( + self, + *, + name: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Gets configured auto-follow patterns. Returns the specified auto-follow pattern collection. - ``_ + ``_ - :arg name: The name of the auto follow pattern. + :param name: Specifies the auto-follow pattern collection that you want to retrieve. + If you do not specify a name, the API returns information for all collections. """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", - _make_path("_ccr", "auto_follow", name), - params=params, - headers=headers, - ) - - @query_params() - async def pause_follow(self, index, params=None, headers=None): + if name not in SKIP_IN_PATH: + __path = f"/_ccr/auto_follow/{_quote(name)}" + else: + __path = "/_ccr/auto_follow" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def pause_auto_follow_pattern( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Pauses a follower index. The follower index will not fetch any additional - operations from the leader index. + Pauses an auto-follow pattern - ``_ + ``_ - :arg index: The name of the follower index that should pause - following its leader index. + :param name: The name of the auto follow pattern that should pause discovering + new indices to follow. """ - client, params = _deprecated_options(self, params) - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return await client._perform_request( - "POST", - _make_path(index, "_ccr", "pause_follow"), - params=params, - headers=headers, - ) - - @query_params() - async def put_auto_follow_pattern(self, name, body, params=None, headers=None): + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_ccr/auto_follow/{_quote(name)}/pause" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters() + async def pause_follow( + self, + *, + index: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - 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. + Pauses a follower index. The follower index will not fetch any additional operations + from the leader index. - ``_ + ``_ - :arg name: The name of the auto follow pattern. - :arg body: The specification of the auto follow pattern + :param index: The name of the follower index that should pause following its + leader index. """ - client, params = _deprecated_options(self, params) - for param in (name, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "PUT", - _make_path("_ccr", "auto_follow", name), - params=params, - headers=headers, - body=body, - ) - - @query_params() - async def resume_follow(self, index, body=None, params=None, headers=None): + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + __path = f"/{_quote(index)}/_ccr/pause_follow" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + async def put_auto_follow_pattern( + self, + *, + name: Any, + remote_cluster: str, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + follow_index_pattern: Optional[Any] = None, + human: Optional[bool] = None, + leader_index_exclusion_patterns: Optional[Any] = None, + leader_index_patterns: Optional[Any] = None, + max_outstanding_read_requests: Optional[int] = None, + max_outstanding_write_requests: Optional[int] = None, + max_read_request_operation_count: Optional[int] = None, + max_read_request_size: Optional[Any] = None, + max_retry_delay: Optional[Any] = None, + max_write_buffer_count: Optional[int] = None, + max_write_buffer_size: Optional[Any] = None, + max_write_request_operation_count: Optional[int] = None, + max_write_request_size: Optional[Any] = None, + pretty: Optional[bool] = None, + read_poll_timeout: Optional[Any] = None, + settings: Optional[Dict[str, Any]] = None, + ) -> Any: """ - 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 - related parameters + 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. + + ``_ + + :param name: The name of the collection of auto-follow patterns. + :param remote_cluster: The remote cluster containing the leader indices to match + against. + :param follow_index_pattern: The name of follower index. The template {{leader_index}} + can be used to derive the name of the follower index from the name of the + leader index. When following a data stream, use {{leader_index}}; CCR does + not support changes to the names of a follower data stream’s backing indices. + :param leader_index_exclusion_patterns: An array of simple index patterns that + can be used to exclude indices from being auto-followed. Indices in the remote + cluster whose names are matching one or more leader_index_patterns and one + or more leader_index_exclusion_patterns won’t be followed. + :param leader_index_patterns: An array of simple index patterns to match against + indices in the remote cluster specified by the remote_cluster field. + :param max_outstanding_read_requests: The maximum number of outstanding reads + requests from the remote cluster. + :param max_outstanding_write_requests: The maximum number of outstanding reads + requests from the remote cluster. + :param max_read_request_operation_count: The maximum number of operations to + pull per read from the remote cluster. + :param max_read_request_size: The maximum size in bytes of per read of a batch + of operations pulled from the remote cluster. + :param max_retry_delay: The maximum time to wait before retrying an operation + that failed exceptionally. An exponential backoff strategy is employed when + retrying. + :param max_write_buffer_count: The maximum number of operations that can be queued + for writing. When this limit is reached, reads from the remote cluster will + be deferred until the number of queued operations goes below the limit. + :param max_write_buffer_size: The maximum total bytes of operations that can + be queued for writing. When this limit is reached, reads from the remote + cluster will be deferred until the total bytes of queued operations goes + below the limit. + :param max_write_request_operation_count: The maximum number of operations per + bulk write request executed on the follower. + :param max_write_request_size: The maximum total bytes of operations per bulk + write request executed on the follower. + :param read_poll_timeout: The maximum time to wait for new operations on the + remote cluster when the follower index is synchronized with the leader index. + When the timeout has elapsed, the poll for operations will return to the + follower so that it can update some statistics. Then the follower will immediately + attempt to read from the leader again. + :param settings: Settings to override from the leader index. Note that certain + settings can not be overrode (e.g., index.number_of_shards). """ - client, params = _deprecated_options(self, params) - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return await client._perform_request( - "POST", - _make_path(index, "_ccr", "resume_follow"), - params=params, - headers=headers, - body=body, + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + if remote_cluster is None: + raise ValueError("Empty value passed for parameter 'remote_cluster'") + __path = f"/_ccr/auto_follow/{_quote(name)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if remote_cluster is not None: + __body["remote_cluster"] = remote_cluster + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if follow_index_pattern is not None: + __body["follow_index_pattern"] = follow_index_pattern + if human is not None: + __query["human"] = human + if leader_index_exclusion_patterns is not None: + __body["leader_index_exclusion_patterns"] = leader_index_exclusion_patterns + if leader_index_patterns is not None: + __body["leader_index_patterns"] = leader_index_patterns + if max_outstanding_read_requests is not None: + __body["max_outstanding_read_requests"] = max_outstanding_read_requests + if max_outstanding_write_requests is not None: + __body["max_outstanding_write_requests"] = max_outstanding_write_requests + if max_read_request_operation_count is not None: + __body[ + "max_read_request_operation_count" + ] = max_read_request_operation_count + if max_read_request_size is not None: + __body["max_read_request_size"] = max_read_request_size + if max_retry_delay is not None: + __body["max_retry_delay"] = max_retry_delay + if max_write_buffer_count is not None: + __body["max_write_buffer_count"] = max_write_buffer_count + if max_write_buffer_size is not None: + __body["max_write_buffer_size"] = max_write_buffer_size + if max_write_request_operation_count is not None: + __body[ + "max_write_request_operation_count" + ] = max_write_request_operation_count + if max_write_request_size is not None: + __body["max_write_request_size"] = max_write_request_size + if pretty is not None: + __query["pretty"] = pretty + if read_poll_timeout is not None: + __body["read_poll_timeout"] = read_poll_timeout + if settings is not None: + __body["settings"] = settings + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "PUT", __target, headers=__headers, body=__body ) - @query_params() - async def stats(self, params=None, headers=None): + @_rewrite_parameters() + async def resume_auto_follow_pattern( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Gets all stats related to cross-cluster replication. + Resumes an auto-follow pattern that has been paused - ``_ - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", "/_ccr/stats", params=params, headers=headers - ) + ``_ - @query_params() - async def unfollow(self, index, params=None, headers=None): + :param name: The name of the auto follow pattern to resume discovering new indices + to follow. """ - Stops the following task associated with a follower index and removes index - metadata and settings associated with cross-cluster replication. - - ``_ + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_ccr/auto_follow/{_quote(name)}/resume" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + async def resume_follow( + self, + *, + index: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + max_outstanding_read_requests: Optional[int] = None, + max_outstanding_write_requests: Optional[int] = None, + max_read_request_operation_count: Optional[int] = None, + max_read_request_size: Optional[str] = None, + max_retry_delay: Optional[Any] = None, + max_write_buffer_count: Optional[int] = None, + max_write_buffer_size: Optional[str] = None, + max_write_request_operation_count: Optional[int] = None, + max_write_request_size: Optional[str] = None, + pretty: Optional[bool] = None, + read_poll_timeout: Optional[Any] = None, + ) -> Any: + """ + Resumes a follower index that has been paused - :arg index: The name of the follower index that should be turned - into a regular index. + ``_ + + :param index: The name of the follow index to resume following. + :param max_outstanding_read_requests: + :param max_outstanding_write_requests: + :param max_read_request_operation_count: + :param max_read_request_size: + :param max_retry_delay: + :param max_write_buffer_count: + :param max_write_buffer_size: + :param max_write_request_operation_count: + :param max_write_request_size: + :param read_poll_timeout: """ - client, params = _deprecated_options(self, params) if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return await client._perform_request( - "POST", - _make_path(index, "_ccr", "unfollow"), - params=params, - headers=headers, + raise ValueError("Empty value passed for parameter 'index'") + __path = f"/{_quote(index)}/_ccr/resume_follow" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if max_outstanding_read_requests is not None: + __body["max_outstanding_read_requests"] = max_outstanding_read_requests + if max_outstanding_write_requests is not None: + __body["max_outstanding_write_requests"] = max_outstanding_write_requests + if max_read_request_operation_count is not None: + __body[ + "max_read_request_operation_count" + ] = max_read_request_operation_count + if max_read_request_size is not None: + __body["max_read_request_size"] = max_read_request_size + if max_retry_delay is not None: + __body["max_retry_delay"] = max_retry_delay + if max_write_buffer_count is not None: + __body["max_write_buffer_count"] = max_write_buffer_count + if max_write_buffer_size is not None: + __body["max_write_buffer_size"] = max_write_buffer_size + if max_write_request_operation_count is not None: + __body[ + "max_write_request_operation_count" + ] = max_write_request_operation_count + if max_write_request_size is not None: + __body["max_write_request_size"] = max_write_request_size + if pretty is not None: + __query["pretty"] = pretty + if read_poll_timeout is not None: + __body["read_poll_timeout"] = read_poll_timeout + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "POST", __target, headers=__headers, body=__body ) - @query_params() - async def pause_auto_follow_pattern(self, name, params=None, headers=None): + @_rewrite_parameters() + async def stats( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Pauses an auto-follow pattern - - ``_ + Gets all stats related to cross-cluster replication. - :arg name: The name of the auto follow pattern that should pause - discovering new indices to follow. + ``_ """ - client, params = _deprecated_options(self, params) - if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'name'.") - - return await client._perform_request( - "POST", - _make_path("_ccr", "auto_follow", name, "pause"), - params=params, - headers=headers, - ) - - @query_params() - async def resume_auto_follow_pattern(self, name, params=None, headers=None): + __path = "/_ccr/stats" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def unfollow( + self, + *, + index: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Resumes an auto-follow pattern that has been paused + Stops the following task associated with a follower index and removes index metadata + and settings associated with cross-cluster replication. - ``_ + ``_ - :arg name: The name of the auto follow pattern to resume - discovering new indices to follow. + :param index: The name of the follower index that should be turned into a regular + index. """ - client, params = _deprecated_options(self, params) - if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'name'.") - - return await client._perform_request( - "POST", - _make_path("_ccr", "auto_follow", name, "resume"), - params=params, - headers=headers, - ) + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + __path = f"/{_quote(index)}/_ccr/unfollow" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) diff --git a/elasticsearch/_async/client/ccr.pyi b/elasticsearch/_async/client/ccr.pyi deleted file mode 100644 index 46d847709..000000000 --- a/elasticsearch/_async/client/ccr.pyi +++ /dev/null @@ -1,249 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class CcrClient(NamespacedClient): - async def delete_auto_follow_pattern( - self, - name: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def follow( - self, - index: Any, - *, - body: Any, - wait_for_active_shards: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def follow_info( - self, - index: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def follow_stats( - self, - index: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def forget_follower( - self, - index: Any, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_auto_follow_pattern( - self, - *, - name: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def pause_follow( - self, - index: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def put_auto_follow_pattern( - self, - name: Any, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def resume_follow( - self, - index: Any, - *, - body: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def stats( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def unfollow( - self, - index: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def pause_auto_follow_pattern( - self, - name: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def resume_auto_follow_pattern( - self, - name: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_async/client/cluster.py b/elasticsearch/_async/client/cluster.py index 7189ecee7..54463c4a4 100644 --- a/elasticsearch/_async/client/cluster.py +++ b/elasticsearch/_async/client/cluster.py @@ -15,395 +15,877 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params +from .utils import SKIP_IN_PATH, _quote, _quote_query, _rewrite_parameters class ClusterClient(NamespacedClient): - @query_params( - "expand_wildcards", - "level", - "local", - "master_timeout", - "return_200_for_cluster_health_timeout", - "timeout", - "wait_for_active_shards", - "wait_for_events", - "wait_for_no_initializing_shards", - "wait_for_no_relocating_shards", - "wait_for_nodes", - "wait_for_status", + @_rewrite_parameters( + body_fields=True, ) - async def health(self, index=None, params=None, headers=None): + async def allocation_explain( + self, + *, + current_node: Optional[str] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + include_disk_info: Optional[bool] = None, + include_yes_decisions: Optional[bool] = None, + index: Optional[Any] = None, + pretty: Optional[bool] = None, + primary: Optional[bool] = None, + shard: Optional[int] = None, + ) -> Any: """ - Returns basic information about the health of the cluster. + Provides explanations for shard allocations in the cluster. - ``_ + ``_ - :arg index: Limit the information returned to a specific index - :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: all - :arg level: Specify the level of detail for returned information - Valid choices: cluster, indices, shards Default: cluster - :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 - :arg return_200_for_cluster_health_timeout: Whether to return - HTTP 200 instead of 408 in case of a cluster health timeout from the - server side - :arg timeout: Explicit operation timeout - :arg wait_for_active_shards: Wait until the specified number of - shards is active - :arg wait_for_events: Wait until all currently queued events - with the given priority are processed Valid choices: immediate, urgent, - high, normal, low, languid - :arg wait_for_no_initializing_shards: Whether to wait until - there are no initializing shards in the cluster - :arg wait_for_no_relocating_shards: Whether to wait until there - are no relocating shards in the cluster - :arg wait_for_nodes: Wait until the specified number of nodes is - available - :arg wait_for_status: Wait until cluster is in a specific state - Valid choices: green, yellow, red + :param current_node: Specifies the node ID or the name of the node to only explain + a shard that is currently located on the specified node. + :param include_disk_info: If true, returns information about disk usage and shard + sizes. + :param include_yes_decisions: If true, returns YES decisions in explanation. + :param index: Specifies the name of the index that you would like an explanation + for. + :param primary: If true, returns explanation for the primary shard for the given + shard ID. + :param shard: Specifies the ID of the shard that you would like an explanation + for. """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", - _make_path("_cluster", "health", index), - params=params, - headers=headers, + __path = "/_cluster/allocation/explain" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if current_node is not None: + __body["current_node"] = current_node + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if include_disk_info is not None: + __query["include_disk_info"] = include_disk_info + if include_yes_decisions is not None: + __query["include_yes_decisions"] = include_yes_decisions + if index is not None: + __body["index"] = index + if pretty is not None: + __query["pretty"] = pretty + if primary is not None: + __body["primary"] = primary + if shard is not None: + __body["shard"] = shard + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "POST", __target, headers=__headers, body=__body ) - @query_params("local", "master_timeout") - async def pending_tasks(self, params=None, headers=None): + @_rewrite_parameters() + async def delete_component_template( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ - Returns a list of any cluster-level changes (e.g. create index, update mapping, - allocate or fail shard) which have not yet been executed. + Deletes a component template - ``_ + ``_ - :arg local: Return local information, do not retrieve the state - from master node (default: false) - :arg master_timeout: Specify timeout for connection to master + :param name: The name of the template + :param master_timeout: Specify timeout for connection to master + :param timeout: Explicit operation timeout """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", "/_cluster/pending_tasks", params=params, headers=headers - ) - - @query_params( - "allow_no_indices", - "expand_wildcards", - "flat_settings", - "ignore_unavailable", - "local", - "master_timeout", - "wait_for_metadata_version", - "wait_for_timeout", - ) - async def state(self, metric=None, index=None, params=None, headers=None): + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_component_template/{_quote(name)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + async def delete_voting_config_exclusions( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + wait_for_removal: Optional[bool] = None, + ) -> Any: """ - Returns a comprehensive information about the state of the cluster. + Clears cluster voting config exclusions. - ``_ + ``_ - :arg metric: Limit the information returned to the specified - metrics Valid choices: _all, blocks, metadata, nodes, routing_table, - routing_nodes, master_node, version - :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 flat_settings: Return settings in flat format (default: - false) - :arg ignore_unavailable: Whether specified concrete indices - should be ignored when unavailable (missing or closed) - :arg local: Return local information, do not retrieve the state - from master node (default: false) - :arg master_timeout: Specify timeout for connection to master - :arg wait_for_metadata_version: Wait for the metadata version to - be equal or greater than the specified metadata version - :arg wait_for_timeout: The maximum time to wait for - wait_for_metadata_version before timing out + :param wait_for_removal: Specifies whether to wait for all excluded nodes to + be removed from the cluster before clearing the voting configuration exclusions + list. Defaults to true, meaning that all excluded nodes must be removed from + the cluster before this API takes any action. If set to false then the voting + configuration exclusions list is cleared even if some excluded nodes are + still in the cluster. """ - client, params = _deprecated_options(self, params) - if index and metric in SKIP_IN_PATH: - metric = "_all" - - return await client._perform_request( - "GET", - _make_path("_cluster", "state", metric, index), - params=params, - headers=headers, - ) - - @query_params("flat_settings", "timeout") - async def stats(self, node_id=None, params=None, headers=None): + __path = "/_cluster/voting_config_exclusions" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if wait_for_removal is not None: + __query["wait_for_removal"] = wait_for_removal + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + async def exists_component_template( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Returns high-level overview of cluster statistics. + Returns information about whether a particular component template exist - ``_ + ``_ - :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 flat_settings: Return settings in flat format (default: - false) - :arg timeout: Explicit operation timeout + :param name: Comma-separated list of component template names used to limit the + request. Wildcard (*) expressions are supported. + :param local: If true, the request retrieves information from the local node + only. Defaults to false, which means information is retrieved from the master + node. + :param master_timeout: Period to wait for a connection to the master node. If + no response is received before the timeout expires, the request fails and + returns an error. """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", - "/_cluster/stats" - if node_id in SKIP_IN_PATH - else _make_path("_cluster", "stats", "nodes", node_id), - params=params, - headers=headers, - ) - - @query_params( - "dry_run", "explain", "master_timeout", "metric", "retry_failed", "timeout" - ) - async def reroute(self, body=None, params=None, headers=None): + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_component_template/{_quote(name)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("HEAD", __target, headers=__headers) + + @_rewrite_parameters() + async def get_component_template( + self, + *, + name: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + flat_settings: Optional[bool] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Allows to manually change the allocation of individual shards in the cluster. + Returns one or more component templates - ``_ + ``_ - :arg body: The definition of `commands` to perform (`move`, - `cancel`, `allocate`) - :arg dry_run: Simulate the operation only and return the - resulting state - :arg explain: Return an explanation of why the commands can or - cannot be executed - :arg master_timeout: Explicit operation timeout for connection - to master node - :arg metric: Limit the information returned to the specified - metrics. Defaults to all but metadata Valid choices: _all, blocks, - metadata, nodes, routing_table, master_node, version - :arg retry_failed: Retries allocation of shards that are blocked - due to too many subsequent allocation failures - :arg timeout: Explicit operation timeout + :param name: The comma separated names of the component templates + :param flat_settings: + :param local: Return local information, do not retrieve the state from master + node (default: false) + :param master_timeout: Explicit operation timeout for connection to master node """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "POST", "/_cluster/reroute", params=params, headers=headers, body=body - ) - - @query_params("flat_settings", "include_defaults", "master_timeout", "timeout") - async def get_settings(self, params=None, headers=None): + if name not in SKIP_IN_PATH: + __path = f"/_component_template/{_quote(name)}" + else: + __path = "/_component_template" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if flat_settings is not None: + __query["flat_settings"] = flat_settings + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def get_settings( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + flat_settings: Optional[bool] = None, + human: Optional[bool] = None, + include_defaults: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ Returns cluster settings. ``_ - :arg flat_settings: Return settings in flat format (default: - false) - :arg include_defaults: Whether to return all default clusters - setting. - :arg master_timeout: Explicit operation timeout for connection - to master node - :arg timeout: Explicit operation timeout + :param flat_settings: Return settings in flat format (default: false) + :param include_defaults: Whether to return all default clusters setting. + :param master_timeout: Explicit operation timeout for connection to master node + :param timeout: Explicit operation timeout """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", "/_cluster/settings", params=params, headers=headers - ) - - @query_params("flat_settings", "master_timeout", "timeout") - async def put_settings(self, body, params=None, headers=None): + __path = "/_cluster/settings" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if flat_settings is not None: + __query["flat_settings"] = flat_settings + if human is not None: + __query["human"] = human + if include_defaults is not None: + __query["include_defaults"] = include_defaults + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def health( + self, + *, + index: Optional[Any] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + level: Optional[Any] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + wait_for_active_shards: Optional[Any] = None, + wait_for_events: Optional[Any] = None, + wait_for_no_initializing_shards: Optional[bool] = None, + wait_for_no_relocating_shards: Optional[bool] = None, + wait_for_nodes: Optional[str] = None, + wait_for_status: Optional[Any] = None, + ) -> Any: """ - Updates the cluster settings. + Returns basic information about the health of the cluster. - ``_ + ``_ - :arg body: The settings to be updated. Can be either `transient` - or `persistent` (survives cluster restart). - :arg flat_settings: Return settings in flat format (default: - false) - :arg master_timeout: Explicit operation timeout for connection - to master node - :arg timeout: Explicit operation timeout + :param index: Comma-separated list of data streams, indices, and index aliases + used to limit the request. Wildcard expressions (*) are supported. To target + all data streams and indices in a cluster, omit this parameter or use _all + or *. + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param level: Can be one of cluster, indices or shards. Controls the details + level of the health information returned. + :param local: If true, the request retrieves information from the local node + only. Defaults to false, which means information is retrieved from the master + node. + :param master_timeout: Period to wait for a connection to the master node. If + no response is received before the timeout expires, the request fails and + returns an error. + :param timeout: Period to wait for a response. If no response is received before + the timeout expires, the request fails and returns an error. + :param wait_for_active_shards: A number controlling to how many active shards + to wait for, all to wait for all shards in the cluster to be active, or 0 + to not wait. + :param wait_for_events: Can be one of immediate, urgent, high, normal, low, languid. + Wait until all currently queued events with the given priority are processed. + :param wait_for_no_initializing_shards: A boolean value which controls whether + to wait (until the timeout provided) for the cluster to have no shard initializations. + Defaults to false, which means it will not wait for initializing shards. + :param wait_for_no_relocating_shards: A boolean value which controls whether + to wait (until the timeout provided) for the cluster to have no shard relocations. + Defaults to false, which means it will not wait for relocating shards. + :param wait_for_nodes: The request waits until the specified number N of nodes + is available. It also accepts >=N, <=N, >N and yellow > red. By default, will not wait for any status. """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return await client._perform_request( - "PUT", "/_cluster/settings", params=params, headers=headers, body=body - ) - - @query_params() - async def remote_info(self, params=None, headers=None): + if index not in SKIP_IN_PATH: + __path = f"/_cluster/health/{_quote(index)}" + else: + __path = "/_cluster/health" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if level is not None: + __query["level"] = level + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if wait_for_active_shards is not None: + __query["wait_for_active_shards"] = wait_for_active_shards + if wait_for_events is not None: + __query["wait_for_events"] = wait_for_events + if wait_for_no_initializing_shards is not None: + __query["wait_for_no_initializing_shards"] = wait_for_no_initializing_shards + if wait_for_no_relocating_shards is not None: + __query["wait_for_no_relocating_shards"] = wait_for_no_relocating_shards + if wait_for_nodes is not None: + __query["wait_for_nodes"] = wait_for_nodes + if wait_for_status is not None: + __query["wait_for_status"] = wait_for_status + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def pending_tasks( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Returns the information about configured remote clusters. + Returns a list of any cluster-level changes (e.g. create index, update mapping, + allocate or fail shard) which have not yet been executed. - ``_ - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", "/_remote/info", params=params, headers=headers - ) + ``_ - @query_params("include_disk_info", "include_yes_decisions") - async def allocation_explain(self, body=None, params=None, headers=None): + :param local: Return local information, do not retrieve the state from master + node (default: false) + :param master_timeout: Specify timeout for connection to master """ - Provides explanations for shard allocations in the cluster. + __path = "/_cluster/pending_tasks" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def post_voting_config_exclusions( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + node_ids: Optional[Any] = None, + node_names: Optional[Any] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: + """ + Updates the cluster voting config exclusions by node ids or node names. - ``_ + ``_ - :arg body: The index, shard, and primary flag to explain. Empty - means 'explain a randomly-chosen unassigned shard' - :arg include_disk_info: Return information about disk usage and - shard sizes (default: false) - :arg include_yes_decisions: Return 'YES' decisions in - explanation (default: false) + :param node_ids: A comma-separated list of the persistent ids of the nodes to + exclude from the voting configuration. If specified, you may not also specify + node_names. + :param node_names: A comma-separated list of the names of the nodes to exclude + from the voting configuration. If specified, you may not also specify node_ids. + :param timeout: When adding a voting configuration exclusion, the API waits for + the specified nodes to be excluded from the voting configuration before returning. + If the timeout expires before the appropriate condition is satisfied, the + request fails and returns an error. """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "POST", - "/_cluster/allocation/explain", - params=params, - headers=headers, - body=body, - ) - - @query_params("master_timeout", "timeout") - async def delete_component_template(self, name, params=None, headers=None): + __path = "/_cluster/voting_config_exclusions" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if node_ids is not None: + __query["node_ids"] = node_ids + if node_names is not None: + __query["node_names"] = node_names + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + parameter_aliases={"_meta": "meta"}, + ) + async def put_component_template( + self, + *, + name: Any, + template: Any, + aliases: Optional[Dict[str, Any]] = None, + create: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + mappings: Optional[Any] = None, + master_timeout: Optional[Any] = None, + meta: Optional[Any] = None, + pretty: Optional[bool] = None, + settings: Optional[Any] = None, + version: Optional[Any] = None, + ) -> Any: """ - Deletes a component template + Creates or updates a component template ``_ - :arg name: The name of the template - :arg master_timeout: Specify timeout for connection to master - :arg timeout: Explicit operation timeout + :param name: The name of the template + :param template: + :param aliases: + :param create: Whether the index template should only be added if new or can + also replace an existing one + :param mappings: + :param master_timeout: Specify timeout for connection to master + :param meta: + :param settings: + :param version: """ - client, params = _deprecated_options(self, params) if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'name'.") - - return await client._perform_request( - "DELETE", - _make_path("_component_template", name), - params=params, - headers=headers, + raise ValueError("Empty value passed for parameter 'name'") + if template is None: + raise ValueError("Empty value passed for parameter 'template'") + __path = f"/_component_template/{_quote(name)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if template is not None: + __body["template"] = template + if aliases is not None: + __body["aliases"] = aliases + if create is not None: + __query["create"] = create + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if mappings is not None: + __body["mappings"] = mappings + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if meta is not None: + __body["_meta"] = meta + if pretty is not None: + __query["pretty"] = pretty + if settings is not None: + __body["settings"] = settings + if version is not None: + __body["version"] = version + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "PUT", __target, headers=__headers, body=__body ) - @query_params("local", "master_timeout") - async def get_component_template(self, name=None, params=None, headers=None): + @_rewrite_parameters( + body_fields=True, + ) + async def put_settings( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + flat_settings: Optional[bool] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + persistent: Optional[Dict[str, Any]] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + transient: Optional[Dict[str, Any]] = None, + ) -> Any: """ - Returns one or more component templates + Updates the cluster settings. - ``_ + ``_ - :arg name: The comma separated names of the component templates - :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 + :param flat_settings: Return settings in flat format (default: false) + :param master_timeout: Explicit operation timeout for connection to master node + :param persistent: + :param timeout: Explicit operation timeout + :param transient: """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", - _make_path("_component_template", name), - params=params, - headers=headers, + __path = "/_cluster/settings" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if flat_settings is not None: + __query["flat_settings"] = flat_settings + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if persistent is not None: + __body["persistent"] = persistent + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if transient is not None: + __body["transient"] = transient + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "PUT", __target, headers=__headers, body=__body ) - @query_params("create", "master_timeout", "timeout") - async def put_component_template(self, name, body, params=None, headers=None): + @_rewrite_parameters() + async def remote_info( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Creates or updates a component template - - ``_ + Returns the information about configured remote clusters. - :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 master_timeout: Specify timeout for connection to master - :arg timeout: Explicit operation timeout + ``_ """ - client, params = _deprecated_options(self, params) - for param in (name, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "PUT", - _make_path("_component_template", name), - params=params, - headers=headers, - body=body, - ) - - @query_params("local", "master_timeout") - async def exists_component_template(self, name, params=None, headers=None): + __path = "/_remote/info" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + async def reroute( + self, + *, + commands: Optional[List[Any]] = None, + dry_run: Optional[bool] = None, + error_trace: Optional[bool] = None, + explain: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + metric: Optional[Any] = None, + pretty: Optional[bool] = None, + retry_failed: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ - Returns information about whether a particular component template exist + Allows to manually change the allocation of individual shards in the cluster. - ``_ + ``_ - :arg name: The name of the template - :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 + :param commands: Defines the commands to perform. + :param dry_run: If true, then the request simulates the operation only and returns + the resulting state. + :param explain: If true, then the response contains an explanation of why the + commands can or cannot be executed. + :param master_timeout: Period to wait for a connection to the master node. If + no response is received before the timeout expires, the request fails and + returns an error. + :param metric: Limits the information returned to the specified metrics. + :param retry_failed: If true, then retries allocation of shards that are blocked + due to too many subsequent allocation failures. + :param timeout: Period to wait for a response. If no response is received before + the timeout expires, the request fails and returns an error. """ - client, params = _deprecated_options(self, params) - if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'name'.") - - return await client._perform_request( - "HEAD", - _make_path("_component_template", name), - params=params, - headers=headers, + __path = "/_cluster/reroute" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if commands is not None: + __body["commands"] = commands + if dry_run is not None: + __query["dry_run"] = dry_run + if error_trace is not None: + __query["error_trace"] = error_trace + if explain is not None: + __query["explain"] = explain + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if metric is not None: + __query["metric"] = metric + if pretty is not None: + __query["pretty"] = pretty + if retry_failed is not None: + __query["retry_failed"] = retry_failed + if timeout is not None: + __query["timeout"] = timeout + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "POST", __target, headers=__headers, body=__body ) - @query_params("wait_for_removal") - async def delete_voting_config_exclusions(self, params=None, headers=None): + @_rewrite_parameters() + async def state( + self, + *, + metric: Optional[Any] = None, + index: Optional[Any] = None, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + flat_settings: Optional[bool] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + wait_for_metadata_version: Optional[Any] = None, + wait_for_timeout: Optional[Any] = None, + ) -> Any: """ - Clears cluster voting config exclusions. + Returns a comprehensive information about the state of the cluster. - ``_ + ``_ - :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 + :param metric: Limit the information returned to the specified metrics + :param index: A comma-separated list of index names; use `_all` or empty string + to perform the operation on all indices + :param 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) + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param flat_settings: Return settings in flat format (default: false) + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param local: Return local information, do not retrieve the state from master + node (default: false) + :param master_timeout: Specify timeout for connection to master + :param wait_for_metadata_version: Wait for the metadata version to be equal or + greater than the specified metadata version + :param wait_for_timeout: The maximum time to wait for wait_for_metadata_version + before timing out """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "DELETE", - "/_cluster/voting_config_exclusions", - params=params, - headers=headers, - ) - - @query_params("node_ids", "node_names", "timeout") - async def post_voting_config_exclusions(self, params=None, headers=None): + if metric not in SKIP_IN_PATH and index not in SKIP_IN_PATH: + __path = f"/_cluster/state/{_quote(metric)}/{_quote(index)}" + elif metric not in SKIP_IN_PATH: + __path = f"/_cluster/state/{_quote(metric)}" + elif index not in SKIP_IN_PATH: + __path = f"/_cluster/state/_all/{_quote(index)}" + else: + __path = "/_cluster/state" + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if flat_settings is not None: + __query["flat_settings"] = flat_settings + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if wait_for_metadata_version is not None: + __query["wait_for_metadata_version"] = wait_for_metadata_version + if wait_for_timeout is not None: + __query["wait_for_timeout"] = wait_for_timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def stats( + self, + *, + node_id: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + flat_settings: Optional[bool] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ - Updates the cluster voting config exclusions by node ids or node names. + Returns high-level overview of cluster statistics. - ``_ + ``_ - :arg node_ids: A comma-separated list of the persistent ids of - the nodes to exclude from the voting configuration. If specified, you - may not also specify ?node_names. - :arg node_names: A comma-separated list of the names of the - nodes to exclude from the voting configuration. If specified, you may - not also specify ?node_ids. - :arg timeout: Explicit operation timeout Default: 30s + :param node_id: Comma-separated list of node filters used to limit returned information. + Defaults to all nodes in the cluster. + :param flat_settings: Return settings in flat format (default: false) + :param timeout: Period to wait for each node to respond. If a node does not respond + before its timeout expires, the response does not include its stats. However, + timed out nodes are included in the response’s _nodes.failed property. Defaults + to no timeout. """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "POST", "/_cluster/voting_config_exclusions", params=params, headers=headers - ) + if node_id not in SKIP_IN_PATH: + __path = f"/_cluster/stats/nodes/{_quote(node_id)}" + else: + __path = "/_cluster/stats" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if flat_settings is not None: + __query["flat_settings"] = flat_settings + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) diff --git a/elasticsearch/_async/client/cluster.pyi b/elasticsearch/_async/client/cluster.pyi deleted file mode 100644 index e001e5af0..000000000 --- a/elasticsearch/_async/client/cluster.pyi +++ /dev/null @@ -1,328 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import HeadApiResponse, ObjectApiResponse - -from ._base import NamespacedClient - -class ClusterClient(NamespacedClient): - async def health( - self, - *, - index: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - level: Optional[Any] = ..., - local: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - return_200_for_cluster_health_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - wait_for_active_shards: Optional[Any] = ..., - wait_for_events: Optional[Any] = ..., - wait_for_no_initializing_shards: Optional[Any] = ..., - wait_for_no_relocating_shards: Optional[Any] = ..., - wait_for_nodes: Optional[Any] = ..., - wait_for_status: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def pending_tasks( - self, - *, - local: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def state( - self, - *, - metric: Optional[Any] = ..., - index: Optional[Any] = ..., - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - flat_settings: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - local: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - wait_for_metadata_version: Optional[Any] = ..., - wait_for_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def stats( - self, - *, - node_id: Optional[Any] = ..., - flat_settings: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def reroute( - self, - *, - body: Optional[Any] = ..., - dry_run: Optional[Any] = ..., - explain: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - metric: Optional[Any] = ..., - retry_failed: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_settings( - self, - *, - flat_settings: Optional[Any] = ..., - include_defaults: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def put_settings( - self, - *, - body: Any, - flat_settings: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def remote_info( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def allocation_explain( - self, - *, - body: Optional[Any] = ..., - include_disk_info: Optional[Any] = ..., - include_yes_decisions: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def delete_component_template( - self, - name: Any, - *, - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_component_template( - self, - *, - name: Optional[Any] = ..., - local: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def put_component_template( - self, - name: Any, - *, - body: Any, - create: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def exists_component_template( - self, - name: Any, - *, - local: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> HeadApiResponse: ... - async def delete_voting_config_exclusions( - self, - *, - wait_for_removal: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def post_voting_config_exclusions( - self, - *, - node_ids: Optional[Any] = ..., - node_names: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_async/client/dangling_indices.py b/elasticsearch/_async/client/dangling_indices.py index 51d19f07f..68dc6462d 100644 --- a/elasticsearch/_async/client/dangling_indices.py +++ b/elasticsearch/_async/client/dangling_indices.py @@ -15,64 +15,142 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params +from .utils import SKIP_IN_PATH, _quote, _quote_query, _rewrite_parameters class DanglingIndicesClient(NamespacedClient): - @query_params("accept_data_loss", "master_timeout", "timeout") - async def delete_dangling_index(self, index_uuid, params=None, headers=None): + @_rewrite_parameters() + async def delete_dangling_index( + self, + *, + index_uuid: Any, + accept_data_loss: bool, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ Deletes the specified dangling index ``_ - :arg index_uuid: The UUID of the dangling index - :arg accept_data_loss: Must be set to true in order to delete - the dangling index - :arg master_timeout: Specify timeout for connection to master - :arg timeout: Explicit operation timeout + :param index_uuid: The UUID of the dangling index + :param accept_data_loss: Must be set to true in order to delete the dangling + index + :param master_timeout: Specify timeout for connection to master + :param timeout: Explicit operation timeout """ - client, params = _deprecated_options(self, params) if index_uuid in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index_uuid'.") - - return await client._perform_request( - "DELETE", - _make_path("_dangling", index_uuid), - params=params, - headers=headers, - ) + raise ValueError("Empty value passed for parameter 'index_uuid'") + if accept_data_loss is None: + raise ValueError("Empty value passed for parameter 'accept_data_loss'") + __path = f"/_dangling/{_quote(index_uuid)}" + __query: Dict[str, Any] = {} + if accept_data_loss is not None: + __query["accept_data_loss"] = accept_data_loss + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("DELETE", __target, headers=__headers) - @query_params("accept_data_loss", "master_timeout", "timeout") - async def import_dangling_index(self, index_uuid, params=None, headers=None): + @_rewrite_parameters() + async def import_dangling_index( + self, + *, + index_uuid: Any, + accept_data_loss: bool, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ Imports the specified dangling index ``_ - :arg index_uuid: The UUID of the dangling index - :arg accept_data_loss: Must be set to true in order to import - the dangling index - :arg master_timeout: Specify timeout for connection to master - :arg timeout: Explicit operation timeout + :param index_uuid: The UUID of the dangling index + :param accept_data_loss: Must be set to true in order to import the dangling + index + :param master_timeout: Specify timeout for connection to master + :param timeout: Explicit operation timeout """ - client, params = _deprecated_options(self, params) if index_uuid in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index_uuid'.") - - return await client._perform_request( - "POST", _make_path("_dangling", index_uuid), params=params, headers=headers - ) + raise ValueError("Empty value passed for parameter 'index_uuid'") + if accept_data_loss is None: + raise ValueError("Empty value passed for parameter 'accept_data_loss'") + __path = f"/_dangling/{_quote(index_uuid)}" + __query: Dict[str, Any] = {} + if accept_data_loss is not None: + __query["accept_data_loss"] = accept_data_loss + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) - @query_params() - async def list_dangling_indices(self, params=None, headers=None): + @_rewrite_parameters() + async def list_dangling_indices( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Returns all dangling indices. ``_ """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", "/_dangling", params=params, headers=headers - ) + __path = "/_dangling" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) diff --git a/elasticsearch/_async/client/dangling_indices.pyi b/elasticsearch/_async/client/dangling_indices.pyi deleted file mode 100644 index d573a6ec0..000000000 --- a/elasticsearch/_async/client/dangling_indices.pyi +++ /dev/null @@ -1,80 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class DanglingIndicesClient(NamespacedClient): - async def delete_dangling_index( - self, - index_uuid: Any, - *, - accept_data_loss: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def import_dangling_index( - self, - index_uuid: Any, - *, - accept_data_loss: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def list_dangling_indices( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_async/client/enrich.py b/elasticsearch/_async/client/enrich.py index 7e0f09299..61a354945 100644 --- a/elasticsearch/_async/client/enrich.py +++ b/elasticsearch/_async/client/enrich.py @@ -15,99 +15,204 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params +from .utils import SKIP_IN_PATH, _quote, _quote_query, _rewrite_parameters class EnrichClient(NamespacedClient): - @query_params() - async def delete_policy(self, name, params=None, headers=None): + @_rewrite_parameters() + async def delete_policy( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Deletes an existing enrich policy and its enrich index. - ``_ + ``_ - :arg name: The name of the enrich policy + :param name: The name of the enrich policy """ - client, params = _deprecated_options(self, params) if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'name'.") - - return await client._perform_request( - "DELETE", - _make_path("_enrich", "policy", name), - params=params, - headers=headers, - ) - - @query_params("wait_for_completion") - async def execute_policy(self, name, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_enrich/policy/{_quote(name)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + async def execute_policy( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + wait_for_completion: Optional[bool] = None, + ) -> Any: """ 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 - the execution is complete. Default: True + :param name: The name of the enrich policy + :param wait_for_completion: Should the request should block until the execution + is complete. """ - client, params = _deprecated_options(self, params) if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'name'.") - - return await client._perform_request( - "PUT", - _make_path("_enrich", "policy", name, "_execute"), - params=params, - headers=headers, - ) - - @query_params() - async def get_policy(self, name=None, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_enrich/policy/{_quote(name)}/_execute" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if wait_for_completion is not None: + __query["wait_for_completion"] = wait_for_completion + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("PUT", __target, headers=__headers) + + @_rewrite_parameters() + async def get_policy( + self, + *, + name: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Gets information about an enrich policy. - ``_ + ``_ - :arg name: A comma-separated list of enrich policy names + :param name: A comma-separated list of enrich policy names """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", _make_path("_enrich", "policy", name), params=params, headers=headers - ) - - @query_params() - async def put_policy(self, name, body, params=None, headers=None): + if name not in SKIP_IN_PATH: + __path = f"/_enrich/policy/{_quote(name)}" + else: + __path = "/_enrich/policy" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + async def put_policy( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + geo_match: Optional[Any] = None, + human: Optional[bool] = None, + match: Optional[Any] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Creates a new enrich policy. - ``_ + ``_ - :arg name: The name of the enrich policy - :arg body: The enrich policy to register + :param name: The name of the enrich policy + :param geo_match: + :param match: """ - client, params = _deprecated_options(self, params) - for param in (name, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "PUT", - _make_path("_enrich", "policy", name), - params=params, - headers=headers, - body=body, + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_enrich/policy/{_quote(name)}" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if geo_match is not None: + __body["geo_match"] = geo_match + if human is not None: + __query["human"] = human + if match is not None: + __body["match"] = match + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "PUT", __target, headers=__headers, body=__body ) - @query_params() - async def stats(self, params=None, headers=None): + @_rewrite_parameters() + async def stats( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Gets enrich coordinator statistics and information about enrich policies that are currently executing. - ``_ + ``_ """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", "/_enrich/_stats", params=params, headers=headers - ) + __path = "/_enrich/_stats" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) diff --git a/elasticsearch/_async/client/enrich.pyi b/elasticsearch/_async/client/enrich.pyi deleted file mode 100644 index 6c8548d56..000000000 --- a/elasticsearch/_async/client/enrich.pyi +++ /dev/null @@ -1,110 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class EnrichClient(NamespacedClient): - async def delete_policy( - self, - name: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def execute_policy( - self, - name: Any, - *, - wait_for_completion: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_policy( - self, - *, - name: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def put_policy( - self, - name: Any, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def stats( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_async/client/eql.py b/elasticsearch/_async/client/eql.py index 1b0334853..e44edf46d 100644 --- a/elasticsearch/_async/client/eql.py +++ b/elasticsearch/_async/client/eql.py @@ -15,99 +15,245 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params +from .utils import SKIP_IN_PATH, _quote, _quote_query, _rewrite_parameters class EqlClient(NamespacedClient): - @query_params("keep_alive", "keep_on_completion", "wait_for_completion_timeout") - async def search(self, index, body, params=None, headers=None): + @_rewrite_parameters() + async def delete( + self, + *, + id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Returns results matching a query expressed in Event Query Language (EQL) + Deletes an async EQL search by ID. If the search is still running, the search + request will be cancelled. Otherwise, the saved search results are deleted. - ``_ + ``_ - :arg index: The name of the index to scope the operation - :arg body: Eql request body. Use the `query` to limit the query - scope. - :arg keep_alive: Update the time interval in which the results - (partial or final) for this search will be available Default: 5d - :arg keep_on_completion: Control whether the response should be - stored in the cluster if it completed within the provided - [wait_for_completion] time (default: false) - :arg wait_for_completion_timeout: Specify the time that the - request should block waiting for the final response + :param id: Identifier for the search to delete. """ - client, params = _deprecated_options(self, params) - for param in (index, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "POST", - _make_path(index, "_eql", "search"), - params=params, - headers=headers, - body=body, - ) + if id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/_eql/search/{_quote(id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("DELETE", __target, headers=__headers) - @query_params() - async def delete(self, id, params=None, headers=None): + @_rewrite_parameters() + async def get( + self, + *, + id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + keep_alive: Optional[Any] = None, + pretty: Optional[bool] = None, + wait_for_completion_timeout: Optional[Any] = None, + ) -> Any: """ - Deletes an async EQL search by ID. If the search is still running, the search - request will be cancelled. Otherwise, the saved search results are deleted. + Returns async results from previously executed Event Query Language (EQL) search - ``_ + ``_ - :arg id: The async search ID + :param id: Identifier for the search. + :param keep_alive: Period for which the search and its results are stored on + the cluster. Defaults to the keep_alive value set by the search’s EQL search + API request. + :param wait_for_completion_timeout: Timeout duration to wait for the request + to finish. Defaults to no timeout, meaning the request waits for complete + search results. """ - client, params = _deprecated_options(self, params) if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'id'.") - - return await client._perform_request( - "DELETE", _make_path("_eql", "search", id), params=params, headers=headers - ) + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/_eql/search/{_quote(id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if keep_alive is not None: + __query["keep_alive"] = keep_alive + if pretty is not None: + __query["pretty"] = pretty + if wait_for_completion_timeout is not None: + __query["wait_for_completion_timeout"] = wait_for_completion_timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) - @query_params("keep_alive", "wait_for_completion_timeout") - async def get(self, id, params=None, headers=None): + @_rewrite_parameters() + async def get_status( + self, + *, + id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Returns async results from previously executed Event Query Language (EQL) - search + Returns the status of a previously submitted async or stored Event Query Language + (EQL) search - ``_ + ``_ - :arg id: The async search ID - :arg keep_alive: Update the time interval in which the results - (partial or final) for this search will be available Default: 5d - :arg wait_for_completion_timeout: Specify the time that the - request should block waiting for the final response + :param id: Identifier for the search. """ - client, params = _deprecated_options(self, params) if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'id'.") - - return await client._perform_request( - "GET", _make_path("_eql", "search", id), params=params, headers=headers - ) + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/_eql/search/status/{_quote(id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) - @query_params() - async def get_status(self, id, params=None, headers=None): + @_rewrite_parameters( + body_fields=True, + ) + async def search( + self, + *, + index: Any, + query: str, + allow_no_indices: Optional[bool] = None, + case_sensitive: Optional[bool] = None, + error_trace: Optional[bool] = None, + event_category_field: Optional[Any] = None, + expand_wildcards: Optional[Any] = None, + fetch_size: Optional[int] = None, + fields: Optional[List[Any]] = None, + filter: Optional[Union[Any, List[Any]]] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + keep_alive: Optional[Any] = None, + keep_on_completion: Optional[bool] = None, + pretty: Optional[bool] = None, + result_position: Optional[Any] = None, + size: Optional[Union[float, int]] = None, + tiebreaker_field: Optional[Any] = None, + timestamp_field: Optional[Any] = None, + wait_for_completion_timeout: Optional[Any] = None, + ) -> Any: """ - Returns the status of a previously submitted async or stored Event Query - Language (EQL) search + Returns results matching a query expressed in Event Query Language (EQL) - ``_ + ``_ - :arg id: The async search ID + :param index: The name of the index to scope the operation + :param query: EQL query you wish to run. + :param allow_no_indices: + :param case_sensitive: + :param event_category_field: Field containing the event classification, such + as process, file, or network. + :param expand_wildcards: + :param fetch_size: Maximum number of events to search at a time for sequence + queries. + :param fields: Array of wildcard (*) patterns. The response returns values for + field names matching these patterns in the fields property of each hit. + :param filter: Query, written in Query DSL, used to filter the events on which + the EQL query runs. + :param ignore_unavailable: If true, missing or closed indices are not included + in the response. + :param keep_alive: + :param keep_on_completion: + :param result_position: + :param size: For basic queries, the maximum number of matching events to return. + Defaults to 10 + :param tiebreaker_field: Field used to sort hits with the same timestamp in ascending + order + :param timestamp_field: Field containing event timestamp. Default "@timestamp" + :param wait_for_completion_timeout: """ - client, params = _deprecated_options(self, params) - if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'id'.") - - return await client._perform_request( - "GET", - _make_path("_eql", "search", "status", id), - params=params, - headers=headers, + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + if query is None: + raise ValueError("Empty value passed for parameter 'query'") + __path = f"/{_quote(index)}/_eql/search" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if query is not None: + __body["query"] = query + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if case_sensitive is not None: + __body["case_sensitive"] = case_sensitive + if error_trace is not None: + __query["error_trace"] = error_trace + if event_category_field is not None: + __body["event_category_field"] = event_category_field + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if fetch_size is not None: + __body["fetch_size"] = fetch_size + if fields is not None: + __body["fields"] = fields + if filter is not None: + __body["filter"] = filter + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if keep_alive is not None: + __body["keep_alive"] = keep_alive + if keep_on_completion is not None: + __body["keep_on_completion"] = keep_on_completion + if pretty is not None: + __query["pretty"] = pretty + if result_position is not None: + __body["result_position"] = result_position + if size is not None: + __body["size"] = size + if tiebreaker_field is not None: + __body["tiebreaker_field"] = tiebreaker_field + if timestamp_field is not None: + __body["timestamp_field"] = timestamp_field + if wait_for_completion_timeout is not None: + __body["wait_for_completion_timeout"] = wait_for_completion_timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "POST", __target, headers=__headers, body=__body ) diff --git a/elasticsearch/_async/client/eql.pyi b/elasticsearch/_async/client/eql.pyi deleted file mode 100644 index 962d92ca8..000000000 --- a/elasticsearch/_async/client/eql.pyi +++ /dev/null @@ -1,98 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class EqlClient(NamespacedClient): - async def search( - self, - index: Any, - *, - body: Any, - keep_alive: Optional[Any] = ..., - keep_on_completion: Optional[Any] = ..., - wait_for_completion_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def delete( - self, - id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get( - self, - id: Any, - *, - keep_alive: Optional[Any] = ..., - wait_for_completion_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_status( - self, - id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_async/client/features.py b/elasticsearch/_async/client/features.py index a9f73852c..a036031a0 100644 --- a/elasticsearch/_async/client/features.py +++ b/elasticsearch/_async/client/features.py @@ -15,40 +15,72 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import _deprecated_options, query_params +from .utils import _quote_query, _rewrite_parameters class FeaturesClient(NamespacedClient): - @query_params("master_timeout") - async def get_features(self, params=None, headers=None): + @_rewrite_parameters() + async def get_features( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Gets a list of features which can be included in snapshots using the - feature_states field when creating a snapshot + Gets a list of features which can be included in snapshots using the feature_states + field when creating a snapshot ``_ - - :arg master_timeout: Explicit operation timeout for connection - to master node """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", "/_features", params=params, headers=headers - ) + __path = "/_features" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) - @query_params() - async def reset_features(self, params=None, headers=None): + @_rewrite_parameters() + async def reset_features( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Resets the internal state of features, usually by deleting system indices ``_ - - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "POST", "/_features/_reset", params=params, headers=headers - ) + __path = "/_features/_reset" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) diff --git a/elasticsearch/_async/client/features.pyi b/elasticsearch/_async/client/features.pyi deleted file mode 100644 index 241a39764..000000000 --- a/elasticsearch/_async/client/features.pyi +++ /dev/null @@ -1,57 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class FeaturesClient(NamespacedClient): - async def get_features( - self, - *, - master_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def reset_features( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_async/client/fleet.py b/elasticsearch/_async/client/fleet.py deleted file mode 100644 index 560ffe322..000000000 --- a/elasticsearch/_async/client/fleet.py +++ /dev/null @@ -1,116 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params - - -class FleetClient(NamespacedClient): - @query_params("checkpoints", "timeout", "wait_for_advance", "wait_for_index") - async def global_checkpoints(self, index, params=None, headers=None): - """ - Returns the current global checkpoints for an index. This API is design for - internal use by the fleet server project. - - ``_ - - :arg index: The name of the index. - :arg checkpoints: Comma separated list of checkpoints - :arg timeout: Timeout to wait for global checkpoint to advance - Default: 30s - :arg wait_for_advance: Whether to wait for the global checkpoint - to advance past the specified current checkpoints Default: false - :arg wait_for_index: Whether to wait for the target index to - exist and all primary shards be active Default: false - """ - client, params = _deprecated_options(self, params) - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return await client._perform_request( - "GET", - _make_path(index, "_fleet", "global_checkpoints"), - params=params, - headers=headers, - ) - - @query_params() - async def msearch(self, body, index=None, params=None, headers=None): - """ - Multi Search API where the search will only be executed after specified - checkpoints are available due to a refresh. This API is designed for internal - use by the fleet server project. - - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - - :arg body: The request definitions (metadata-fleet search - request definition pairs), separated by newlines - :arg index: The index name to use as the default - """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - headers["content-type"] = "application/x-ndjson" - return await client._perform_request( - "POST", - _make_path(index, "_fleet", "_fleet_msearch"), - params=params, - headers=headers, - body=body, - ) - - @query_params( - "allow_partial_search_results", - "wait_for_checkpoints", - "wait_for_checkpoints_timeout", - ) - async def search(self, index, body=None, params=None, headers=None): - """ - Search API where the search will only be executed after specified checkpoints - are available due to a refresh. This API is designed for internal use by the - fleet server project. - - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - - :arg index: The index name to search. - :arg body: The search definition using the Query DSL - :arg allow_partial_search_results: Indicate if an error should - be returned if there is a partial search failure or timeout Default: - True - :arg wait_for_checkpoints: Comma separated list of checkpoints, - one per shard - :arg wait_for_checkpoints_timeout: Explicit wait_for_checkpoints - timeout - """ - client, params = _deprecated_options(self, params) - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return await client._perform_request( - "POST", - _make_path(index, "_fleet", "_fleet_search"), - params=params, - headers=headers, - body=body, - ) diff --git a/elasticsearch/_async/client/fleet.pyi b/elasticsearch/_async/client/fleet.pyi deleted file mode 100644 index 9c7eab49c..000000000 --- a/elasticsearch/_async/client/fleet.pyi +++ /dev/null @@ -1,84 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class FleetClient(NamespacedClient): - async def global_checkpoints( - self, - index: Any, - *, - checkpoints: Optional[Any] = ..., - timeout: Optional[Any] = ..., - wait_for_advance: Optional[Any] = ..., - wait_for_index: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def msearch( - self, - *, - body: Any, - index: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def search( - self, - index: Any, - *, - body: Optional[Any] = ..., - allow_partial_search_results: Optional[Any] = ..., - wait_for_checkpoints: Optional[Any] = ..., - wait_for_checkpoints_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_async/client/graph.py b/elasticsearch/_async/client/graph.py index 10b22be73..adc60de58 100644 --- a/elasticsearch/_async/client/graph.py +++ b/elasticsearch/_async/client/graph.py @@ -15,33 +15,80 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params +from .utils import SKIP_IN_PATH, _quote, _quote_query, _rewrite_parameters class GraphClient(NamespacedClient): - @query_params("routing", "timeout") - async def explore(self, index, body=None, params=None, headers=None): + @_rewrite_parameters( + body_fields=True, + ) + async def explore( + self, + *, + index: Any, + connections: Optional[Any] = None, + controls: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + query: Optional[Any] = None, + routing: Optional[Any] = None, + timeout: Optional[Any] = None, + vertices: Optional[List[Any]] = None, + ) -> Any: """ 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 routing: Specific routing value - :arg timeout: Explicit operation timeout + :param index: A comma-separated list of index names to search; use `_all` or + empty string to perform the operation on all indices + :param connections: + :param controls: + :param query: + :param routing: Specific routing value + :param timeout: Explicit operation timeout + :param vertices: """ - client, params = _deprecated_options(self, params) if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return await client._perform_request( - "POST", - _make_path(index, "_graph", "explore"), - params=params, - headers=headers, - body=body, + raise ValueError("Empty value passed for parameter 'index'") + __path = f"/{_quote(index)}/_graph/explore" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if connections is not None: + __body["connections"] = connections + if controls is not None: + __body["controls"] = controls + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if query is not None: + __body["query"] = query + if routing is not None: + __query["routing"] = routing + if timeout is not None: + __query["timeout"] = timeout + if vertices is not None: + __body["vertices"] = vertices + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "POST", __target, headers=__headers, body=__body ) diff --git a/elasticsearch/_async/client/graph.pyi b/elasticsearch/_async/client/graph.pyi deleted file mode 100644 index 575a0cb07..000000000 --- a/elasticsearch/_async/client/graph.pyi +++ /dev/null @@ -1,44 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class GraphClient(NamespacedClient): - async def explore( - self, - index: Any, - *, - body: Optional[Any] = ..., - routing: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_async/client/ilm.py b/elasticsearch/_async/client/ilm.py index 8b2b209a1..7cc02a7b2 100644 --- a/elasticsearch/_async/client/ilm.py +++ b/elasticsearch/_async/client/ilm.py @@ -15,206 +15,418 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params +from .utils import SKIP_IN_PATH, _quote, _quote_query, _rewrite_parameters class IlmClient(NamespacedClient): - @query_params() - async def delete_lifecycle(self, policy, params=None, headers=None): + @_rewrite_parameters() + async def delete_lifecycle( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Deletes the specified lifecycle policy definition. A currently used policy - cannot be deleted. + Deletes the specified lifecycle policy definition. A currently used policy cannot + be deleted. - ``_ + ``_ - :arg policy: The name of the index lifecycle policy + :param name: The name of the index lifecycle policy """ - client, params = _deprecated_options(self, params) - if policy in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'policy'.") - - return await client._perform_request( - "DELETE", - _make_path("_ilm", "policy", policy), - params=params, - headers=headers, - ) - - @query_params("only_errors", "only_managed") - async def explain_lifecycle(self, index, params=None, headers=None): + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_ilm/policy/{_quote(name)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + async def explain_lifecycle( + self, + *, + index: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + only_errors: Optional[bool] = None, + only_managed: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ 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 - to ones in an ILM error state, implies only_managed - :arg only_managed: filters the indices included in the response - to ones managed by ILM + :param index: The name of the index to explain + :param only_errors: filters the indices included in the response to ones in an + ILM error state, implies only_managed + :param only_managed: filters the indices included in the response to ones managed + by ILM """ - client, params = _deprecated_options(self, params) if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return await client._perform_request( - "GET", _make_path(index, "_ilm", "explain"), params=params, headers=headers - ) - - @query_params() - async def get_lifecycle(self, policy=None, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'index'") + __path = f"/{_quote(index)}/_ilm/explain" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if only_errors is not None: + __query["only_errors"] = only_errors + if only_managed is not None: + __query["only_managed"] = only_managed + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def get_lifecycle( + self, + *, + name: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Returns the specified policy definition. Includes the policy version and last modified date. - ``_ + ``_ - :arg policy: The name of the index lifecycle policy + :param name: The name of the index lifecycle policy """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", _make_path("_ilm", "policy", policy), params=params, headers=headers - ) - - @query_params() - async def get_status(self, params=None, headers=None): + if name not in SKIP_IN_PATH: + __path = f"/_ilm/policy/{_quote(name)}" + else: + __path = "/_ilm/policy" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def get_status( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Retrieves the current index lifecycle management (ILM) status. - ``_ + ``_ """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", "/_ilm/status", params=params, headers=headers - ) - - @query_params() - async def move_to_step(self, index, body=None, params=None, headers=None): + __path = "/_ilm/status" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + async def move_to_step( + self, + *, + index: Any, + current_step: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + next_step: Optional[Any] = None, + pretty: Optional[bool] = None, + ) -> Any: """ 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 - :arg body: The new lifecycle step to move to + :param index: The name of the index whose lifecycle step is to change + :param current_step: + :param next_step: """ - client, params = _deprecated_options(self, params) if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return await client._perform_request( - "POST", - _make_path("_ilm", "move", index), - params=params, - headers=headers, - body=body, + raise ValueError("Empty value passed for parameter 'index'") + __path = f"/_ilm/move/{_quote(index)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if current_step is not None: + __body["current_step"] = current_step + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if next_step is not None: + __body["next_step"] = next_step + if pretty is not None: + __query["pretty"] = pretty + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "POST", __target, headers=__headers, body=__body ) - @query_params() - async def put_lifecycle(self, policy, body=None, params=None, headers=None): + @_rewrite_parameters( + body_fields=True, + ) + async def put_lifecycle( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + policy: Optional[Any] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Creates a lifecycle policy - ``_ + ``_ - :arg policy: The name of the index lifecycle policy - :arg body: The lifecycle policy definition to register + :param name: The name of the index lifecycle policy + :param policy: """ - client, params = _deprecated_options(self, params) - if policy in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'policy'.") - - return await client._perform_request( - "PUT", - _make_path("_ilm", "policy", policy), - params=params, - headers=headers, - body=body, + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_ilm/policy/{_quote(name)}" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if policy is not None: + __body["policy"] = policy + if pretty is not None: + __query["pretty"] = pretty + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "PUT", __target, headers=__headers, body=__body ) - @query_params() - async def remove_policy(self, index, params=None, headers=None): + @_rewrite_parameters() + async def remove_policy( + self, + *, + index: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Removes the assigned lifecycle policy and stops managing the specified index - ``_ + ``_ - :arg index: The name of the index to remove policy on + :param index: The name of the index to remove policy on """ - client, params = _deprecated_options(self, params) if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return await client._perform_request( - "POST", _make_path(index, "_ilm", "remove"), params=params, headers=headers - ) - - @query_params() - async def retry(self, index, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'index'") + __path = f"/{_quote(index)}/_ilm/remove" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters() + async def retry( + self, + *, + index: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ 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 + :param index: The name of the indices (comma-separated) whose failed lifecycle + step is to be retry """ - client, params = _deprecated_options(self, params) if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return await client._perform_request( - "POST", _make_path(index, "_ilm", "retry"), params=params, headers=headers - ) - - @query_params() - async def start(self, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'index'") + __path = f"/{_quote(index)}/_ilm/retry" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters() + async def start( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ Start the index lifecycle management (ILM) plugin. - ``_ - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "POST", "/_ilm/start", params=params, headers=headers - ) - - @query_params() - async def stop(self, params=None, headers=None): - """ - Halts all lifecycle management operations and stops the index lifecycle - management (ILM) plugin + ``_ - ``_ + :param master_timeout: + :param timeout: """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "POST", "/_ilm/stop", params=params, headers=headers - ) - - @query_params("dry_run") - async def migrate_to_data_tiers(self, body=None, params=None, headers=None): + __path = "/_ilm/start" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters() + async def stop( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ - Migrates the indices and ILM policies away from custom node attribute - allocation routing to data tiers routing + Halts all lifecycle management operations and stops the index lifecycle management + (ILM) plugin - ``_ + ``_ - :arg body: Optionally specify a legacy index template name to - delete and optionally specify a node attribute name used for index shard - routing (defaults to "data") - :arg dry_run: If set to true it will simulate the migration, - providing a way to retrieve the ILM policies and indices that need to be - migrated. The default is false + :param master_timeout: + :param timeout: """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "POST", - "/_ilm/migrate_to_data_tiers", - params=params, - headers=headers, - body=body, - ) + __path = "/_ilm/stop" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) diff --git a/elasticsearch/_async/client/ilm.pyi b/elasticsearch/_async/client/ilm.pyi deleted file mode 100644 index 9fa5f7c7f..000000000 --- a/elasticsearch/_async/client/ilm.pyi +++ /dev/null @@ -1,213 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class IlmClient(NamespacedClient): - async def delete_lifecycle( - self, - policy: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def explain_lifecycle( - self, - index: Any, - *, - only_errors: Optional[Any] = ..., - only_managed: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_lifecycle( - self, - *, - policy: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_status( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def move_to_step( - self, - index: Any, - *, - body: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def put_lifecycle( - self, - policy: Any, - *, - body: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def remove_policy( - self, - index: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def retry( - self, - index: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def start( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def stop( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def migrate_to_data_tiers( - self, - *, - body: Optional[Any] = ..., - dry_run: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_async/client/indices.py b/elasticsearch/_async/client/indices.py index 9d631489d..703d17ea8 100644 --- a/elasticsearch/_async/client/indices.py +++ b/elasticsearch/_async/client/indices.py @@ -15,1611 +15,3347 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params +from .utils import SKIP_IN_PATH, _quote, _quote_query, _rewrite_parameters class IndicesClient(NamespacedClient): - @query_params() - async def analyze(self, body=None, index=None, params=None, headers=None): + @_rewrite_parameters() + async def add_block( + self, + *, + index: Any, + block: Any, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ - Performs the analysis process on a text and return the tokens breakdown of the - text. - - ``_ + Adds a block to an index. - :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 - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "POST", - _make_path(index, "_analyze"), - params=params, - headers=headers, - body=body, - ) + ``_ - @query_params("allow_no_indices", "expand_wildcards", "ignore_unavailable") - async def refresh(self, index=None, params=None, headers=None): + :param index: A comma separated list of indices to add a block to + :param block: The block to add (one of read, write, read_only or metadata) + :param 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) + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param master_timeout: Specify timeout for connection to master + :param timeout: Explicit operation timeout """ - 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 - :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) - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "POST", _make_path(index, "_refresh"), params=params, headers=headers - ) - - @query_params( - "allow_no_indices", - "expand_wildcards", - "force", - "ignore_unavailable", - "wait_if_ongoing", + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + if block in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'block'") + __path = f"/{_quote(index)}/_block/{_quote(block)}" + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("PUT", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, ) - async def flush(self, index=None, params=None, headers=None): + async def analyze( + self, + *, + index: Optional[Any] = None, + analyzer: Optional[str] = None, + attributes: Optional[List[str]] = None, + char_filter: Optional[List[Union[Any, str]]] = None, + error_trace: Optional[bool] = None, + explain: Optional[bool] = None, + field: Optional[Any] = None, + filter: Optional[List[Union[Any, str]]] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + normalizer: Optional[str] = None, + pretty: Optional[bool] = None, + text: Optional[Any] = None, + tokenizer: Optional[Union[Any, str]] = None, + ) -> Any: """ - Performs the flush operation on one or more indices. + Performs the analysis process on a text and return the tokens breakdown of the + text. - ``_ + ``_ - :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, hidden, none, all Default: open - :arg force: Whether a flush should be forced even if it is not - necessarily needed ie. if no changes will be committed to the index. - This is useful if transaction log IDs should be incremented even if no - uncommitted changes are present. (This setting can be considered as - internal) - :arg ignore_unavailable: Whether specified concrete indices - should be ignored when unavailable (missing or closed) - :arg wait_if_ongoing: If set to true the flush operation will - block until the flush can be executed if another flush operation is - already executing. The default is true. If set to false the flush will - be skipped iff if another flush operation is already running. - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "POST", _make_path(index, "_flush"), params=params, headers=headers + :param index: The name of the index to scope the operation + :param analyzer: + :param attributes: + :param char_filter: + :param explain: + :param field: + :param filter: + :param normalizer: + :param text: + :param tokenizer: + """ + if index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_analyze" + else: + __path = "/_analyze" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if analyzer is not None: + __body["analyzer"] = analyzer + if attributes is not None: + __body["attributes"] = attributes + if char_filter is not None: + __body["char_filter"] = char_filter + if error_trace is not None: + __query["error_trace"] = error_trace + if explain is not None: + __body["explain"] = explain + if field is not None: + __body["field"] = field + if filter is not None: + __body["filter"] = filter + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if normalizer is not None: + __body["normalizer"] = normalizer + if pretty is not None: + __query["pretty"] = pretty + if text is not None: + __body["text"] = text + if tokenizer is not None: + __body["tokenizer"] = tokenizer + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "POST", __target, headers=__headers, body=__body ) - @query_params("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 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 before the operation returns. + @_rewrite_parameters() + async def clear_cache( + self, + *, + index: Optional[Any] = None, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + fielddata: Optional[bool] = None, + fields: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + pretty: Optional[bool] = None, + query: Optional[bool] = None, + request: Optional[bool] = None, + ) -> Any: """ - client, params = _deprecated_options(self, params) - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") + Clears all or specific caches for one or more indices. - return await client._perform_request( - "PUT", _make_path(index), params=params, headers=headers, body=body - ) + ``_ - @query_params("master_timeout", "timeout", "wait_for_active_shards") - async def clone(self, index, target, body=None, params=None, headers=None): + :param index: A comma-separated list of index name to limit the operation + :param 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) + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param fielddata: Clear field data + :param fields: A comma-separated list of fields to clear when using the `fielddata` + parameter (default: all) + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param query: Clear query caches + :param request: Clear request cache + """ + if index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_cache/clear" + else: + __path = "/_cache/clear" + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if fielddata is not None: + __query["fielddata"] = fielddata + if fields is not None: + __query["fields"] = fields + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if pretty is not None: + __query["pretty"] = pretty + if query is not None: + __query["query"] = query + if request is not None: + __query["request"] = request + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + async def clone( + self, + *, + index: Any, + target: Any, + aliases: Optional[Dict[Any, Any]] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + settings: Optional[Dict[str, Any]] = None, + timeout: Optional[Any] = None, + wait_for_active_shards: Optional[Any] = None, + ) -> Any: """ Clones an index ``_ - :arg index: The name of the source index to clone - :arg target: The name of the target index to clone 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 cloned index before the operation returns. - """ - client, params = _deprecated_options(self, params) - for param in (index, target): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "PUT", - _make_path(index, "_clone", target), - params=params, - headers=headers, - body=body, - ) - - @query_params( - "allow_no_indices", - "expand_wildcards", - "flat_settings", - "ignore_unavailable", - "include_defaults", - "local", - "master_timeout", - ) - async def get(self, index, params=None, headers=None): + :param index: The name of the source index to clone + :param target: The name of the target index to clone into + :param aliases: + :param master_timeout: Specify timeout for connection to master + :param settings: + :param timeout: Explicit operation timeout + :param wait_for_active_shards: Set the number of active shards to wait for on + the cloned index before the operation returns. """ - 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 - to no concrete indices (default: false) - :arg expand_wildcards: Whether wildcard expressions should get - expanded to open or closed indices (default: open) Valid choices: open, - closed, hidden, none, all Default: open - :arg flat_settings: Return settings in flat format (default: - false) - :arg ignore_unavailable: Ignore unavailable indexes (default: - false) - :arg include_defaults: Whether to return all default setting for - each of the indices. - :arg local: Return local information, do not retrieve the state - from master node (default: false) - :arg master_timeout: Specify timeout for connection to master - """ - client, params = _deprecated_options(self, params) if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return await client._perform_request( - "GET", _make_path(index), params=params, headers=headers + raise ValueError("Empty value passed for parameter 'index'") + if target in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'target'") + __path = f"/{_quote(index)}/_clone/{_quote(target)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if aliases is not None: + __body["aliases"] = aliases + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if settings is not None: + __body["settings"] = settings + if timeout is not None: + __query["timeout"] = timeout + if wait_for_active_shards is not None: + __query["wait_for_active_shards"] = wait_for_active_shards + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "PUT", __target, headers=__headers, body=__body ) - @query_params( - "allow_no_indices", - "expand_wildcards", - "ignore_unavailable", - "master_timeout", - "timeout", - "wait_for_active_shards", - ) - 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 - 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. - """ - client, params = _deprecated_options(self, params) - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return await client._perform_request( - "POST", _make_path(index, "_open"), params=params, headers=headers - ) - - @query_params( - "allow_no_indices", - "expand_wildcards", - "ignore_unavailable", - "master_timeout", - "timeout", - "wait_for_active_shards", - ) - async def close(self, index, params=None, headers=None): + @_rewrite_parameters() + async def close( + self, + *, + index: Any, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + wait_for_active_shards: Optional[Any] = None, + ) -> Any: """ Closes an index. ``_ - :arg index: A comma separated list of indices to close - :arg allow_no_indices: Whether to ignore if a wildcard indices - expression resolves into no concrete indices. (This includes `_all` - string or when no indices have been specified) - :arg expand_wildcards: Whether to expand wildcard expression to - concrete indices that are open, closed or both. Valid choices: open, - closed, hidden, none, all Default: open - :arg ignore_unavailable: Whether specified concrete indices - should be ignored when unavailable (missing or closed) - :arg master_timeout: Specify timeout for connection to master - :arg timeout: Explicit operation timeout - :arg wait_for_active_shards: Sets the number of active shards to - wait for before the operation returns. - """ - client, params = _deprecated_options(self, params) - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return await client._perform_request( - "POST", _make_path(index, "_close"), params=params, headers=headers - ) - - @query_params( - "allow_no_indices", - "expand_wildcards", - "ignore_unavailable", - "master_timeout", - "timeout", - ) - async def delete(self, index, params=None, headers=None): + :param index: A comma separated list of indices to close + :param 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) + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param master_timeout: Specify timeout for connection to master + :param timeout: Explicit operation timeout + :param wait_for_active_shards: Sets the number of active shards to wait for before + the operation returns. """ - Deletes an index. - - ``_ - - :arg index: A comma-separated list of indices to delete; use - `_all` or `*` string to delete all indices - :arg allow_no_indices: Ignore if a wildcard expression resolves - to no concrete indices (default: false) - :arg expand_wildcards: Whether wildcard expressions should get - expanded to open, closed, or hidden indices Valid choices: open, - closed, hidden, none, all Default: open,closed - :arg ignore_unavailable: Ignore unavailable indexes (default: - false) - :arg master_timeout: Specify timeout for connection to master - :arg timeout: Explicit operation timeout - """ - client, params = _deprecated_options(self, params) if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return await client._perform_request( - "DELETE", _make_path(index), params=params, headers=headers - ) - - @query_params( - "allow_no_indices", - "expand_wildcards", - "flat_settings", - "ignore_unavailable", - "include_defaults", - "local", + raise ValueError("Empty value passed for parameter 'index'") + __path = f"/{_quote(index)}/_close" + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if wait_for_active_shards is not None: + __query["wait_for_active_shards"] = wait_for_active_shards + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, ) - 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 - to no concrete indices (default: false) - :arg expand_wildcards: Whether wildcard expressions should get - expanded to open or closed indices (default: open) Valid choices: open, - closed, hidden, none, all Default: open - :arg flat_settings: Return settings in flat format (default: - false) - :arg ignore_unavailable: Ignore unavailable indexes (default: - false) - :arg include_defaults: Whether to return all default setting for - each of the indices. - :arg local: Return local information, do not retrieve the state - from master node (default: false) - """ - client, params = _deprecated_options(self, params) - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return await client._perform_request( - "HEAD", _make_path(index), params=params, headers=headers - ) - - @query_params("allow_no_indices", "expand_wildcards", "ignore_unavailable", "local") - async def exists_type(self, index, doc_type, params=None, headers=None): + async def create( + self, + *, + index: Any, + aliases: Optional[Dict[Any, Any]] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + include_type_name: Optional[bool] = None, + mappings: Optional[Any] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + settings: Optional[Any] = None, + timeout: Optional[Any] = None, + wait_for_active_shards: Optional[Any] = None, + ) -> Any: """ - 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 - :arg doc_type: A comma-separated list of document types to check - :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 local: Return local information, do not retrieve the state - from master node (default: false) - """ - client, params = _deprecated_options(self, params) - for param in (index, doc_type): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "HEAD", - _make_path(index, "_mapping", doc_type), - params=params, - headers=headers, - ) - - @query_params( - "allow_no_indices", - "expand_wildcards", - "ignore_unavailable", - "master_timeout", - "timeout", - "write_index_only", - ) - async def put_mapping(self, index, body, params=None, headers=None): - """ - Updates the index mappings. - - ``_ + Creates an index with optional settings and mappings. - :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 allow_no_indices: Whether to ignore if a wildcard indices - expression resolves into no concrete indices. (This includes `_all` - string or when no indices have been specified) - :arg expand_wildcards: Whether to expand wildcard expression to - concrete indices that are open, closed or both. Valid choices: open, - closed, hidden, none, all Default: open - :arg ignore_unavailable: Whether specified concrete indices - should be ignored when unavailable (missing or closed) - :arg master_timeout: Specify timeout for connection to master - :arg timeout: Explicit operation timeout - :arg write_index_only: When true, applies mappings only to the - write index of an alias or data stream - """ - client, params = _deprecated_options(self, params) - for param in (index, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "PUT", - _make_path(index, "_mapping"), - params=params, - headers=headers, - body=body, - ) + ``_ - @query_params( - "allow_no_indices", - "expand_wildcards", - "ignore_unavailable", - "local", - "master_timeout", - ) - async def get_mapping(self, index=None, params=None, headers=None): + :param index: The name of the index + :param aliases: + :param include_type_name: + :param mappings: Mapping for fields in the index. If specified, this mapping + can include: - Field names - Field data types - Mapping parameters + :param master_timeout: Specify timeout for connection to master + :param settings: + :param timeout: Explicit operation timeout + :param wait_for_active_shards: Set the number of active shards to wait for before + the operation returns. """ - Returns mappings for one or more indices. - - ``_ - - :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 local: Return local information, do not retrieve the state - from master node (default: false) - :arg master_timeout: Specify timeout for connection to master - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", _make_path(index, "_mapping"), params=params, headers=headers + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + __path = f"/{_quote(index)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if aliases is not None: + __body["aliases"] = aliases + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if include_type_name is not None: + __query["include_type_name"] = include_type_name + if mappings is not None: + __body["mappings"] = mappings + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if settings is not None: + __body["settings"] = settings + if timeout is not None: + __query["timeout"] = timeout + if wait_for_active_shards is not None: + __query["wait_for_active_shards"] = wait_for_active_shards + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "PUT", __target, headers=__headers, body=__body ) - @query_params("master_timeout", "timeout") - async def put_alias(self, index, name, body=None, params=None, headers=None): + @_rewrite_parameters() + async def create_data_stream( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Creates or updates an alias. - - ``_ + Creates a data stream - :arg index: A comma-separated list of index names the alias - should point to (supports wildcards); use `_all` to perform the - operation on all indices. - :arg name: The name of the alias to be created or updated - :arg body: The settings for the alias, such as `routing` or - `filter` - :arg master_timeout: Specify timeout for connection to master - :arg timeout: Explicit timestamp for the document - """ - client, params = _deprecated_options(self, params) - for param in (index, name): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "PUT", - _make_path(index, "_alias", name), - params=params, - headers=headers, - body=body, - ) + ``_ - @query_params("allow_no_indices", "expand_wildcards", "ignore_unavailable", "local") - async def exists_alias(self, name, index=None, params=None, headers=None): + :param name: The name of the data stream """ - 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 - aliases - :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: all - :arg ignore_unavailable: Whether specified concrete indices - should be ignored when unavailable (missing or closed) - :arg local: Return local information, do not retrieve the state - from master node (default: false) - """ - client, params = _deprecated_options(self, params) if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'name'.") - - return await client._perform_request( - "HEAD", _make_path(index, "_alias", name), params=params, headers=headers - ) - - @query_params("allow_no_indices", "expand_wildcards", "ignore_unavailable", "local") - async def get_alias(self, index=None, name=None, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_data_stream/{_quote(name)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("PUT", __target, headers=__headers) + + @_rewrite_parameters() + async def data_streams_stats( + self, + *, + name: Optional[Any] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Returns an alias. - - ``_ + Provides statistics on operations happening in a data stream. - :arg index: A comma-separated list of index names to filter - aliases - :arg name: A comma-separated list of alias names to return - :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: all - :arg ignore_unavailable: Whether specified concrete indices - should be ignored when unavailable (missing or closed) - :arg local: Return local information, do not retrieve the state - from master node (default: false) - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", _make_path(index, "_alias", name), params=params, headers=headers - ) + ``_ - @query_params("master_timeout", "timeout") - async def update_aliases(self, body, params=None, headers=None): + :param name: A comma-separated list of data stream names; use `_all` or empty + string to perform the operation on all data streams + :param expand_wildcards: + """ + if name not in SKIP_IN_PATH: + __path = f"/_data_stream/{_quote(name)}/_stats" + else: + __path = "/_data_stream/_stats" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def delete( + self, + *, + index: Any, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ - Updates index aliases. + Deletes an index. - ``_ + ``_ - :arg body: The definition of `actions` to perform - :arg master_timeout: Specify timeout for connection to master - :arg timeout: Request timeout + :param index: A comma-separated list of indices to delete; use `_all` or `*` + string to delete all indices + :param allow_no_indices: Ignore if a wildcard expression resolves to no concrete + indices (default: false) + :param expand_wildcards: Whether wildcard expressions should get expanded to + open, closed, or hidden indices + :param ignore_unavailable: Ignore unavailable indexes (default: false) + :param master_timeout: Specify timeout for connection to master + :param timeout: Explicit operation timeout """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return await client._perform_request( - "POST", "/_aliases", params=params, headers=headers, body=body - ) - - @query_params("master_timeout", "timeout") - async def delete_alias(self, index, name, params=None, headers=None): + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + __path = f"/{_quote(index)}" + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + async def delete_alias( + self, + *, + index: Any, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ Deletes an alias. ``_ - :arg index: A comma-separated list of index names (supports - wildcards); use `_all` for all indices - :arg name: A comma-separated list of aliases to delete (supports - wildcards); use `_all` to delete all aliases for the specified indices. - :arg master_timeout: Specify timeout for connection to master - :arg timeout: Explicit timestamp for the document - """ - client, params = _deprecated_options(self, params) - for param in (index, name): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "DELETE", _make_path(index, "_alias", name), params=params, headers=headers - ) - - @query_params("create", "master_timeout", "order") - async def put_template(self, name, body, params=None, headers=None): + :param index: A comma-separated list of index names (supports wildcards); use + `_all` for all indices + :param name: A comma-separated list of aliases to delete (supports wildcards); + use `_all` to delete all aliases for the specified indices. + :param master_timeout: Specify timeout for connection to master + :param timeout: Explicit timestamp for the document """ - 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 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 - numbers) - """ - client, params = _deprecated_options(self, params) - for param in (name, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "PUT", - _make_path("_template", name), - params=params, - headers=headers, - body=body, - ) - - @query_params("flat_settings", "local", "master_timeout") - async def exists_template(self, name, params=None, headers=None): + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/{_quote(index)}/_alias/{_quote(name)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + async def delete_data_stream( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Returns information about whether a particular index template exists. + Deletes a data stream. - ``_ + ``_ - :arg name: The comma separated names of the index templates - :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 + :param name: A comma-separated list of data streams to delete; use `*` to delete + all data streams + :param expand_wildcards: Whether wildcard expressions should get expanded to + open or closed indices (default: open) """ - client, params = _deprecated_options(self, params) if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'name'.") - - return await client._perform_request( - "HEAD", _make_path("_template", name), params=params, headers=headers - ) - - @query_params("flat_settings", "local", "master_timeout") - async def get_template(self, name=None, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_data_stream/{_quote(name)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + async def delete_index_template( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Returns an index template. + Deletes an index template. ``_ - :arg name: The comma separated names of the index templates - :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 - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", _make_path("_template", name), params=params, headers=headers - ) - - @query_params("master_timeout", "timeout") - async def delete_template(self, name, params=None, headers=None): + :param name: The name of the template + """ + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_index_template/{_quote(name)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + async def delete_template( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ Deletes an index template. ``_ - :arg name: The name of the template - :arg master_timeout: Specify timeout for connection to master - :arg timeout: Explicit operation timeout + :param name: The name of the template + :param master_timeout: Specify timeout for connection to master + :param timeout: Explicit operation timeout """ - client, params = _deprecated_options(self, params) if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'name'.") - - return await client._perform_request( - "DELETE", _make_path("_template", name), params=params, headers=headers - ) - - @query_params( - "allow_no_indices", - "expand_wildcards", - "flat_settings", - "ignore_unavailable", - "include_defaults", - "local", - "master_timeout", - ) - async def get_settings(self, index=None, name=None, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_template/{_quote(name)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + async def disk_usage( + self, + *, + index: Any, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + flush: Optional[bool] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + run_expensive_tasks: Optional[bool] = None, + timeout: Optional[Any] = None, + wait_for_active_shards: Optional[str] = None, + ) -> Any: """ - Returns settings for one or more indices. - - ``_ + Analyzes the disk usage of each field of an index or data stream - :arg index: A comma-separated list of index names; use `_all` or - empty string to perform the operation on all indices - :arg name: The name of the settings that should be included - :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: all - :arg flat_settings: Return settings in flat format (default: - false) - :arg ignore_unavailable: Whether specified concrete indices - should be ignored when unavailable (missing or closed) - :arg include_defaults: Whether to return all default setting for - each of the indices. - :arg local: Return local information, do not retrieve the state - from master node (default: false) - :arg master_timeout: Specify timeout for connection to master - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", _make_path(index, "_settings", name), params=params, headers=headers - ) + ``_ - @query_params( - "allow_no_indices", - "expand_wildcards", - "flat_settings", - "ignore_unavailable", - "master_timeout", - "preserve_existing", - "timeout", - ) - async def put_settings(self, body, index=None, params=None, headers=None): + :param index: Comma-separated list of data streams, indices, and aliases used + to limit the request. It’s recommended to execute this API with a single + index (or the latest backing index of a data stream) as the API consumes + resources significantly. + :param allow_no_indices: If false, the request returns an error if any wildcard + expression, index alias, or _all value targets only missing or closed indices. + This behavior applies even if the request targets other open indices. For + example, a request targeting foo*,bar* returns an error if an index starts + with foo but no index starts with bar. + :param expand_wildcards: Type of index that wildcard patterns can match. If the + request can target data streams, this argument determines whether wildcard + expressions match hidden data streams. Supports comma-separated values, such + as open,hidden. + :param flush: If true, the API performs a flush before analysis. If false, the + response may not include uncommitted data. + :param ignore_unavailable: If true, missing or closed indices are not included + in the response. + :param master_timeout: Period to wait for a connection to the master node. If + no response is received before the timeout expires, the request fails and + returns an error. + :param run_expensive_tasks: Analyzing field disk usage is resource-intensive. + To use the API, this parameter must be set to true. + :param timeout: Period to wait for a response. If no response is received before + the timeout expires, the request fails and returns an error. + :param wait_for_active_shards: The number of shard copies that must be active + before proceeding with the operation. Set to all or any positive integer + up to the total number of shards in the index (number_of_replicas+1). Default: + 1, the primary shard. """ - Updates the index settings. - - ``_ + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + __path = f"/{_quote(index)}/_disk_usage" + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if flush is not None: + __query["flush"] = flush + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if run_expensive_tasks is not None: + __query["run_expensive_tasks"] = run_expensive_tasks + if timeout is not None: + __query["timeout"] = timeout + if wait_for_active_shards is not None: + __query["wait_for_active_shards"] = wait_for_active_shards + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters() + async def exists( + self, + *, + index: Any, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + flat_settings: Optional[bool] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + include_defaults: Optional[bool] = None, + local: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: + """ + Returns information about whether a particular index exists. - :arg body: The index settings to be updated - :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 flat_settings: Return settings in flat format (default: - false) - :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 preserve_existing: Whether to update existing settings. If - set to `true` existing settings on an index remain unchanged, the - default is `false` - :arg timeout: Explicit operation timeout - """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return await client._perform_request( - "PUT", - _make_path(index, "_settings"), - params=params, - headers=headers, - body=body, - ) + ``_ - @query_params( - "completion_fields", - "expand_wildcards", - "fielddata_fields", - "fields", - "forbid_closed_indices", - "groups", - "include_segment_file_sizes", - "include_unloaded_segments", - "level", - "types", - ) - async def stats(self, index=None, metric=None, params=None, headers=None): + :param index: A comma-separated list of index names + :param allow_no_indices: Ignore if a wildcard expression resolves to no concrete + indices (default: false) + :param expand_wildcards: Whether wildcard expressions should get expanded to + open or closed indices (default: open) + :param flat_settings: Return settings in flat format (default: false) + :param ignore_unavailable: Ignore unavailable indexes (default: false) + :param include_defaults: Whether to return all default setting for each of the + indices. + :param local: Return local information, do not retrieve the state from master + node (default: false) """ - Provides statistics on operations happening in an index. - - ``_ + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + __path = f"/{_quote(index)}" + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if flat_settings is not None: + __query["flat_settings"] = flat_settings + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if include_defaults is not None: + __query["include_defaults"] = include_defaults + if local is not None: + __query["local"] = local + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("HEAD", __target, headers=__headers) + + @_rewrite_parameters() + async def exists_alias( + self, + *, + name: Any, + index: Optional[Any] = None, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + local: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: + """ + Returns information about whether a particular alias exists. - :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, bulk - :arg completion_fields: A comma-separated list of fields for the - `completion` index metric (supports wildcards) - :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_fields: A comma-separated list of fields for the - `fielddata` index metric (supports wildcards) - :arg fields: A comma-separated list of fields for `fielddata` - and `completion` index metric (supports wildcards) - :arg forbid_closed_indices: If set to false stats will also - collected from closed indices if explicitly specified or if - expand_wildcards expands to closed indices Default: True - :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 include_unloaded_segments: If set to true segment stats - will include stats for segments that are not currently loaded into - memory - :arg level: Return stats aggregated at cluster, index or shard - level Valid choices: cluster, indices, shards Default: indices - :arg types: A comma-separated list of document types for the - `indexing` index metric - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", _make_path(index, "_stats", metric), params=params, headers=headers - ) + ``_ - @query_params( - "allow_no_indices", "expand_wildcards", "ignore_unavailable", "verbose" - ) - async def segments(self, index=None, params=None, headers=None): + :param name: A comma-separated list of alias names to return + :param index: A comma-separated list of index names to filter aliases + :param 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) + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param local: Return local information, do not retrieve the state from master + node (default: false) """ - Provides low-level information about segments in a Lucene index. - - ``_ + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + if index not in SKIP_IN_PATH and name not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_alias/{_quote(name)}" + elif name not in SKIP_IN_PATH: + __path = f"/_alias/{_quote(name)}" + else: + raise ValueError("Couldn't find a path for the given parameters") + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if local is not None: + __query["local"] = local + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("HEAD", __target, headers=__headers) + + @_rewrite_parameters() + async def exists_index_template( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + ) -> Any: + """ + Returns information about whether a particular index template exists. - :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 verbose: Includes detailed memory usage by Lucene. - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", _make_path(index, "_segments"), params=params, headers=headers - ) + ``_ - @query_params( - "allow_no_indices", - "expand_wildcards", - "fielddata", - "fields", - "ignore_unavailable", - "query", - "request", - ) - async def clear_cache(self, index=None, params=None, headers=None): + :param name: Comma-separated list of index template names used to limit the request. + Wildcard (*) expressions are supported. + :param master_timeout: Period to wait for a connection to the master node. If + no response is received before the timeout expires, the request fails and + returns an error. """ - Clears all or specific caches for one or more indices. - - ``_ + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_index_template/{_quote(name)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("HEAD", __target, headers=__headers) + + @_rewrite_parameters() + async def exists_template( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + flat_settings: Optional[bool] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + ) -> Any: + """ + Returns information about whether a particular index template exists. - :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 - """ - client, params = _deprecated_options(self, params) - return await client._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): + :param name: The comma separated names of the index templates + :param flat_settings: Return settings in flat format (default: false) + :param local: Return local information, do not retrieve the state from master + node (default: false) + :param master_timeout: Explicit operation timeout for connection to master node """ - Returns information about ongoing index shard recoveries. + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_template/{_quote(name)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if flat_settings is not None: + __query["flat_settings"] = flat_settings + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("HEAD", __target, headers=__headers) + + @_rewrite_parameters() + async def exists_type( + self, + *, + index: Any, + type: Any, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + local: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: + """ + Returns information about whether a particular document type exists. (DEPRECATED) - ``_ + ``_ - :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 + :param index: A comma-separated list of index names; use `_all` to check the + types across all indices + :param type: A comma-separated list of document types to check + :param 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) + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param local: Return local information, do not retrieve the state from master + node (default: false) """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", _make_path(index, "_recovery"), 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): + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + if type in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'type'") + __path = f"/{_quote(index)}/_mapping/{_quote(type)}" + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if local is not None: + __query["local"] = local + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("HEAD", __target, headers=__headers) + + @_rewrite_parameters() + async def flush( + self, + *, + index: Optional[Any] = None, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + force: Optional[bool] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + pretty: Optional[bool] = None, + wait_if_ongoing: Optional[bool] = None, + ) -> Any: """ - Provides store information for shard copies of indices. - - ``_ + Performs the flush 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 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 - """ - client, params = _deprecated_options(self, params) - return await client._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): + :param index: A comma-separated list of index names; use `_all` or empty string + for all indices + :param 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) + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param force: Whether a flush should be forced even if it is not necessarily + needed ie. if no changes will be committed to the index. This is useful if + transaction log IDs should be incremented even if no uncommitted changes + are present. (This setting can be considered as internal) + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param wait_if_ongoing: If set to true the flush operation will block until the + flush can be executed if another flush operation is already executing. The + default is true. If set to false the flush will be skipped iff if another + flush operation is already running. + """ + if index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_flush" + else: + __path = "/_flush" + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if force is not None: + __query["force"] = force + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if pretty is not None: + __query["pretty"] = pretty + if wait_if_ongoing is not None: + __query["wait_if_ongoing"] = wait_if_ongoing + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters() + async def forcemerge( + self, + *, + index: Optional[Any] = None, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + flush: Optional[bool] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + max_num_segments: Optional[int] = None, + only_expunge_deletes: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ 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 - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "POST", _make_path(index, "_forcemerge"), params=params, headers=headers - ) - - @query_params("master_timeout", "timeout", "wait_for_active_shards") - async def shrink(self, index, target, body=None, params=None, headers=None): + :param index: A comma-separated list of index names; use `_all` or empty string + to perform the operation on all indices + :param 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) + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param flush: Specify whether the index should be flushed after performing the + operation (default: true) + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param max_num_segments: The number of segments the index should be merged into + (default: dynamic) + :param only_expunge_deletes: Specify whether the operation should only expunge + deleted documents + """ + if index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_forcemerge" + else: + __path = "/_forcemerge" + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if flush is not None: + __query["flush"] = flush + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if max_num_segments is not None: + __query["max_num_segments"] = max_num_segments + if only_expunge_deletes is not None: + __query["only_expunge_deletes"] = only_expunge_deletes + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters() + async def get( + self, + *, + index: Any, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + flat_settings: Optional[bool] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + include_defaults: Optional[bool] = None, + include_type_name: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Allow to shrink an existing index into a new index with fewer primary shards. - - ``_ + Returns information about one or more indices. - :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. - """ - client, params = _deprecated_options(self, params) - for param in (index, target): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "PUT", - _make_path(index, "_shrink", target), - params=params, - headers=headers, - body=body, - ) + ``_ - @query_params("master_timeout", "timeout", "wait_for_active_shards") - async def split(self, index, target, body=None, params=None, headers=None): + :param index: Comma-separated list of data streams, indices, and index aliases + used to limit the request. Wildcard expressions (*) are supported. + :param allow_no_indices: Ignore if a wildcard expression resolves to no concrete + indices (default: false) + :param expand_wildcards: Type of index that wildcard expressions can match. If + the request can target data streams, this argument determines whether wildcard + expressions match hidden data streams. Supports comma-separated values, such + as open,hidden. + :param flat_settings: If true, returns settings in flat format. + :param ignore_unavailable: If false, requests that target a missing index return + an error. + :param include_defaults: If true, return all default settings in the response. + :param include_type_name: If true, a mapping type is expected in the body of + mappings. + :param local: If true, the request retrieves information from the local node + only. Defaults to false, which means information is retrieved from the master + node. + :param master_timeout: Period to wait for a connection to the master node. If + no response is received before the timeout expires, the request fails and + returns an error. """ - 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. - """ - client, params = _deprecated_options(self, params) - for param in (index, target): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._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") - async def rollover( - self, alias, body=None, new_index=None, params=None, headers=None - ): + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + __path = f"/{_quote(index)}" + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if flat_settings is not None: + __query["flat_settings"] = flat_settings + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if include_defaults is not None: + __query["include_defaults"] = include_defaults + if include_type_name is not None: + __query["include_type_name"] = include_type_name + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def get_alias( + self, + *, + index: Optional[Any] = None, + name: Optional[Any] = None, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + local: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Updates an alias to point to a new index when the existing index is considered - to be too large or too old. - - ``_ + Returns an alias. - :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. - """ - client, params = _deprecated_options(self, params) - if alias in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'alias'.") - - return await client._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 unfreeze(self, index, params=None, headers=None): + :param index: A comma-separated list of index names to filter aliases + :param name: A comma-separated list of alias names to return + :param 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) + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param local: Return local information, do not retrieve the state from master + node (default: false) + """ + if index not in SKIP_IN_PATH and name not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_alias/{_quote(name)}" + elif index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_alias" + elif name not in SKIP_IN_PATH: + __path = f"/_alias/{_quote(name)}" + else: + __path = "/_alias" + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if local is not None: + __query["local"] = local + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def get_data_stream( + self, + *, + name: Optional[Any] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - 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. - """ - client, params = _deprecated_options(self, params) - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") + Returns data streams. - return await client._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): + :param name: A comma-separated list of data streams to get; use `*` to get all + data streams + :param expand_wildcards: Whether wildcard expressions should get expanded to + open or closed indices (default: open) + """ + if name not in SKIP_IN_PATH: + __path = f"/_data_stream/{_quote(name)}" + else: + __path = "/_data_stream" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def get_field_mapping( + self, + *, + fields: Any, + index: Optional[Any] = None, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + include_defaults: Optional[bool] = None, + include_type_name: Optional[bool] = None, + local: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Reloads an index's search analyzers and their resources. + Returns mapping for one or more fields. - ``_ + ``_ - :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) - """ - client, params = _deprecated_options(self, params) - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") + :param fields: A comma-separated list of fields + :param index: A comma-separated list of index names + :param 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) + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param include_defaults: Whether the default mapping values should be returned + as well + :param include_type_name: + :param 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 parameter 'fields'") + if index not in SKIP_IN_PATH and fields not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_mapping/field/{_quote(fields)}" + elif fields not in SKIP_IN_PATH: + __path = f"/_mapping/field/{_quote(fields)}" + else: + raise ValueError("Couldn't find a path for the given parameters") + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if include_defaults is not None: + __query["include_defaults"] = include_defaults + if include_type_name is not None: + __query["include_type_name"] = include_type_name + if local is not None: + __query["local"] = local + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def get_index_template( + self, + *, + name: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + flat_settings: Optional[bool] = None, + human: Optional[bool] = None, + include_type_name: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + ) -> Any: + """ + Returns an index template. - return await client._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", - ) - async def get_field_mapping(self, fields, index=None, params=None, headers=None): + :param name: Comma-separated list of index template names used to limit the request. + Wildcard (*) expressions are supported. + :param flat_settings: If true, returns settings in flat format. + :param include_type_name: If true, a mapping type is expected in the body of + mappings. + :param local: If true, the request retrieves information from the local node + only. Defaults to false, which means information is retrieved from the master + node. + :param master_timeout: Period to wait for a connection to the master node. If + no response is received before the timeout expires, the request fails and + returns an error. + """ + if name not in SKIP_IN_PATH: + __path = f"/_index_template/{_quote(name)}" + else: + __path = "/_index_template" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if flat_settings is not None: + __query["flat_settings"] = flat_settings + if human is not None: + __query["human"] = human + if include_type_name is not None: + __query["include_type_name"] = include_type_name + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def get_mapping( + self, + *, + index: Optional[Any] = None, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + include_type_name: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Returns mapping for one or more fields. + Returns mappings for one or more indices. - ``_ + ``_ - :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) - """ - client, params = _deprecated_options(self, params) - if fields in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'fields'.") + :param index: A comma-separated list of index names + :param 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) + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param include_type_name: + :param local: Return local information, do not retrieve the state from master + node (default: false) + :param master_timeout: Specify timeout for connection to master + """ + if index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_mapping" + else: + __path = "/_mapping" + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if include_type_name is not None: + __query["include_type_name"] = include_type_name + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def get_settings( + self, + *, + index: Optional[Any] = None, + name: Optional[Any] = None, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + flat_settings: Optional[bool] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + include_defaults: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + ) -> Any: + """ + Returns settings for one or more indices. - return await client._perform_request( - "GET", - _make_path(index, "_mapping", "field", fields), - params=params, - headers=headers, - ) + ``_ - @query_params( - "all_shards", - "allow_no_indices", - "analyze_wildcard", - "analyzer", - "default_operator", - "df", - "expand_wildcards", - "explain", - "ignore_unavailable", - "lenient", - "q", - "rewrite", - ) - async def validate_query( - self, body=None, index=None, doc_type=None, params=None, headers=None - ): + :param index: A comma-separated list of index names; use `_all` or empty string + to perform the operation on all indices + :param name: The name of the settings that should be included + :param 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) + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param flat_settings: Return settings in flat format (default: false) + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param include_defaults: Whether to return all default setting for each of the + indices. + :param local: Return local information, do not retrieve the state from master + node (default: false) + :param master_timeout: Specify timeout for connection to master + """ + if index not in SKIP_IN_PATH and name not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_settings/{_quote(name)}" + elif index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_settings" + elif name not in SKIP_IN_PATH: + __path = f"/_settings/{_quote(name)}" + else: + __path = "/_settings" + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if flat_settings is not None: + __query["flat_settings"] = flat_settings + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if include_defaults is not None: + __query["include_defaults"] = include_defaults + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def get_template( + self, + *, + name: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + flat_settings: Optional[bool] = None, + human: Optional[bool] = None, + include_type_name: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Allows a user to validate a potentially expensive query without executing it. - - ``_ + Returns an index template. - :arg body: The query definition specified with the Query DSL - :arg index: A comma-separated list of index names to restrict - the operation; use `_all` or empty string to perform the operation on - all indices - :arg doc_type: A comma-separated list of document types to - restrict the operation; leave empty to perform the operation on all - types - :arg all_shards: Execute validation on all shards instead of one - random shard per index - :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 analyze_wildcard: Specify whether wildcard and prefix - queries should be analyzed (default: false) - :arg analyzer: The analyzer to use for the query string - :arg default_operator: The default operator for query string - query (AND or OR) Valid choices: AND, OR Default: OR - :arg df: The field to use as default where no field prefix is - given in the query string - :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: Return detailed information about the error - :arg ignore_unavailable: Whether specified concrete indices - should be ignored when unavailable (missing or closed) - :arg lenient: Specify whether format-based query failures (such - as providing text to a numeric field) should be ignored - :arg q: Query in the Lucene query string syntax - :arg rewrite: Provide a more detailed explanation showing the - actual Lucene query that will be executed. - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "POST", - _make_path(index, doc_type, "_validate", "query"), - params=params, - headers=headers, - body=body, - ) + ``_ - @query_params() - async def create_data_stream(self, name, params=None, headers=None): + :param name: The comma separated names of the index templates + :param flat_settings: Return settings in flat format (default: false) + :param include_type_name: + :param local: Return local information, do not retrieve the state from master + node (default: false) + :param master_timeout: Explicit operation timeout for connection to master node + """ + if name not in SKIP_IN_PATH: + __path = f"/_template/{_quote(name)}" + else: + __path = "/_template" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if flat_settings is not None: + __query["flat_settings"] = flat_settings + if human is not None: + __query["human"] = human + if include_type_name is not None: + __query["include_type_name"] = include_type_name + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def migrate_to_data_stream( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Creates a data stream + Migrates an alias to a data stream ``_ - :arg name: The name of the data stream + :param name: The name of the alias to migrate """ - client, params = _deprecated_options(self, params) if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'name'.") + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_data_stream/_migrate/{_quote(name)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters() + async def open( + self, + *, + index: Any, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + wait_for_active_shards: Optional[Any] = None, + ) -> Any: + """ + Opens an index. - return await client._perform_request( - "PUT", _make_path("_data_stream", name), params=params, headers=headers - ) + ``_ - @query_params("expand_wildcards") - async def delete_data_stream(self, name, params=None, headers=None): + :param index: A comma separated list of indices to open + :param 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) + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param master_timeout: Specify timeout for connection to master + :param timeout: Explicit operation timeout + :param wait_for_active_shards: Sets the number of active shards to wait for before + the operation returns. """ - Deletes a data stream. + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + __path = f"/{_quote(index)}/_open" + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if wait_for_active_shards is not None: + __query["wait_for_active_shards"] = wait_for_active_shards + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters() + async def promote_data_stream( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: + """ + Promotes a data stream from a replicated data stream managed by CCR to a regular + data stream ``_ - :arg name: A comma-separated list of data streams to delete; use - `*` to delete all data streams - :arg expand_wildcards: Whether wildcard expressions should get - expanded to open or closed indices (default: open) Valid choices: open, - closed, hidden, none, all Default: open + :param name: The name of the data stream """ - client, params = _deprecated_options(self, params) if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'name'.") - - return await client._perform_request( - "DELETE", _make_path("_data_stream", name), params=params, headers=headers - ) - - @query_params("master_timeout", "timeout") - async def delete_index_template(self, name, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_data_stream/_promote/{_quote(name)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + async def put_alias( + self, + *, + index: Any, + name: Any, + error_trace: Optional[bool] = None, + filter: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + index_routing: Optional[Any] = None, + is_write_index: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + routing: Optional[Any] = None, + search_routing: Optional[Any] = None, + timeout: Optional[Any] = None, + ) -> Any: """ - Deletes an index template. + Creates or updates an alias. - ``_ + ``_ - :arg name: The name of the template - :arg master_timeout: Specify timeout for connection to master - :arg timeout: Explicit operation timeout + :param index: A comma-separated list of index names the alias should point to + (supports wildcards); use `_all` to perform the operation on all indices. + :param name: The name of the alias to be created or updated + :param filter: + :param index_routing: + :param is_write_index: + :param master_timeout: Specify timeout for connection to master + :param routing: + :param search_routing: + :param timeout: Explicit timestamp for the document """ - client, params = _deprecated_options(self, params) + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'name'.") - - return await client._perform_request( - "DELETE", - _make_path("_index_template", name), - params=params, - headers=headers, + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/{_quote(index)}/_alias/{_quote(name)}" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter is not None: + __body["filter"] = filter + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if index_routing is not None: + __body["index_routing"] = index_routing + if is_write_index is not None: + __body["is_write_index"] = is_write_index + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if routing is not None: + __body["routing"] = routing + if search_routing is not None: + __body["search_routing"] = search_routing + if timeout is not None: + __query["timeout"] = timeout + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "PUT", __target, headers=__headers, body=__body ) - @query_params("flat_settings", "local", "master_timeout") - async def get_index_template(self, name=None, params=None, headers=None): + @_rewrite_parameters( + body_fields=True, + parameter_aliases={"_meta": "meta"}, + ) + async def put_index_template( + self, + *, + name: Any, + composed_of: Optional[List[Any]] = None, + data_stream: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + index_patterns: Optional[Any] = None, + meta: Optional[Any] = None, + pretty: Optional[bool] = None, + priority: Optional[int] = None, + template: Optional[Any] = None, + version: Optional[Any] = None, + ) -> Any: """ - Returns an index template. + Creates or updates an index template. ``_ - :arg name: A pattern that returned template names must match - :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 - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", _make_path("_index_template", name), params=params, headers=headers + :param name: Index or template name + :param composed_of: + :param data_stream: + :param index_patterns: + :param meta: + :param priority: + :param template: + :param version: + """ + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_index_template/{_quote(name)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if composed_of is not None: + __body["composed_of"] = composed_of + if data_stream is not None: + __body["data_stream"] = data_stream + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if index_patterns is not None: + __body["index_patterns"] = index_patterns + if meta is not None: + __body["_meta"] = meta + if pretty is not None: + __query["pretty"] = pretty + if priority is not None: + __body["priority"] = priority + if template is not None: + __body["template"] = template + if version is not None: + __body["version"] = version + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "PUT", __target, headers=__headers, body=__body ) - @query_params("cause", "create", "master_timeout") - async def put_index_template(self, name, body, params=None, headers=None): + @_rewrite_parameters( + body_fields=True, + parameter_aliases={ + "_field_names": "field_names", + "_meta": "meta", + "_routing": "routing", + "_source": "source", + }, + ) + async def put_mapping( + self, + *, + index: Any, + allow_no_indices: Optional[bool] = None, + date_detection: Optional[bool] = None, + dynamic: Optional[Union[Any, bool]] = None, + dynamic_date_formats: Optional[List[str]] = None, + dynamic_templates: Optional[Union[Dict[str, Any], List[Dict[str, Any]]]] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + field_names: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + include_type_name: Optional[bool] = None, + master_timeout: Optional[Any] = None, + meta: Optional[Dict[str, Any]] = None, + numeric_detection: Optional[bool] = None, + pretty: Optional[bool] = None, + properties: Optional[Dict[Any, Any]] = None, + routing: Optional[Any] = None, + runtime: Optional[Any] = None, + source: Optional[Any] = None, + timeout: Optional[Any] = None, + write_index_only: Optional[bool] = None, + ) -> Any: """ - Creates or updates an index template. + Updates the index mappings. - ``_ + ``_ - :arg name: The name of the template - :arg body: The template definition - :arg cause: User defined reason for creating/updating the index - template - :arg create: Whether the index template should only be added if - new or can also replace an existing one - :arg master_timeout: Specify timeout for connection to master - """ - client, params = _deprecated_options(self, params) - for param in (name, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "PUT", - _make_path("_index_template", name), - params=params, - headers=headers, - body=body, + :param 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. + :param 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) + :param date_detection: Controls whether dynamic date detection is enabled. + :param dynamic: Controls whether new fields are added dynamically. + :param dynamic_date_formats: If date detection is enabled then new string fields + are checked against 'dynamic_date_formats' and if the value matches then + a new date field is added instead of string. + :param dynamic_templates: Specify dynamic templates for the mapping. + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param field_names: Control whether field names are enabled for the index. + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param include_type_name: + :param master_timeout: Specify timeout for connection to master + :param meta: A mapping type can have custom meta data associated with it. These + are not used at all by Elasticsearch, but can be used to store application-specific + metadata. + :param numeric_detection: Automatically map strings into numeric data types for + all fields. + :param properties: Mapping for a field. For new fields, this mapping can include: + - Field name - Field data type - Mapping parameters + :param routing: Enable making a routing value required on indexed documents. + :param runtime: Mapping of runtime fields for the index. + :param source: Control whether the _source field is enabled on the index. + :param timeout: Explicit operation timeout + :param write_index_only: When true, applies mappings only to the write index + of an alias or data stream + """ + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + __path = f"/{_quote(index)}/_mapping" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if date_detection is not None: + __body["date_detection"] = date_detection + if dynamic is not None: + __body["dynamic"] = dynamic + if dynamic_date_formats is not None: + __body["dynamic_date_formats"] = dynamic_date_formats + if dynamic_templates is not None: + __body["dynamic_templates"] = dynamic_templates + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if field_names is not None: + __body["_field_names"] = field_names + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if include_type_name is not None: + __query["include_type_name"] = include_type_name + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if meta is not None: + __body["_meta"] = meta + if numeric_detection is not None: + __body["numeric_detection"] = numeric_detection + if pretty is not None: + __query["pretty"] = pretty + if properties is not None: + __body["properties"] = properties + if routing is not None: + __body["_routing"] = routing + if runtime is not None: + __body["runtime"] = runtime + if source is not None: + __body["_source"] = source + if timeout is not None: + __query["timeout"] = timeout + if write_index_only is not None: + __query["write_index_only"] = write_index_only + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "PUT", __target, headers=__headers, body=__body ) - @query_params("flat_settings", "local", "master_timeout") - async def exists_index_template(self, name, params=None, headers=None): + @_rewrite_parameters( + body_name="settings", + ) + async def put_settings( + self, + *, + settings: Any, + index: Optional[Any] = None, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + flat_settings: Optional[bool] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + master_timeout: Optional[Any] = None, + preserve_existing: Optional[bool] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ - Returns information about whether a particular index template exists. - - ``_ + Updates the index settings. - :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 - """ - client, params = _deprecated_options(self, params) - if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'name'.") + ``_ - return await client._perform_request( - "HEAD", _make_path("_index_template", name), params=params, headers=headers + :param settings: + :param index: A comma-separated list of index names; use `_all` or empty string + to perform the operation on all indices + :param 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) + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param flat_settings: Return settings in flat format (default: false) + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param master_timeout: Specify timeout for connection to master + :param preserve_existing: Whether to update existing settings. If set to `true` + existing settings on an index remain unchanged, the default is `false` + :param timeout: Explicit operation timeout + """ + if settings is None: + raise ValueError("Empty value passed for parameter 'settings'") + if index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_settings" + else: + __path = "/_settings" + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if flat_settings is not None: + __query["flat_settings"] = flat_settings + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if preserve_existing is not None: + __query["preserve_existing"] = preserve_existing + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + __body = settings + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "PUT", __target, headers=__headers, body=__body ) - @query_params("cause", "create", "master_timeout") - async def simulate_index_template(self, name, body=None, params=None, headers=None): + @_rewrite_parameters( + body_fields=True, + ) + async def put_template( + self, + *, + name: Any, + aliases: Optional[Dict[Any, Any]] = None, + create: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + flat_settings: Optional[bool] = None, + human: Optional[bool] = None, + include_type_name: Optional[bool] = None, + index_patterns: Optional[Union[List[str], str]] = None, + mappings: Optional[Any] = None, + master_timeout: Optional[Any] = None, + order: Optional[int] = None, + pretty: Optional[bool] = None, + settings: Optional[Dict[str, Any]] = None, + timeout: Optional[Any] = None, + version: Optional[Any] = None, + ) -> Any: """ - Simulate matching the given index name against the index templates in the - system + Creates or updates an index template. ``_ - :arg name: The name of the index (it must be a concrete index - name) - :arg body: New index template definition, which will be included - in the simulation, as if it already exists in the system - :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 - """ - client, params = _deprecated_options(self, params) + :param name: The name of the template + :param aliases: Aliases for the index. + :param create: If true, this request cannot replace or update existing index + templates. + :param flat_settings: + :param include_type_name: + :param index_patterns: Array of wildcard expressions used to match the names + of indices during creation. + :param mappings: Mapping for fields in the index. + :param master_timeout: Period to wait for a connection to the master node. If + no response is received before the timeout expires, the request fails and + returns an error. + :param order: Order in which Elasticsearch applies this template if index matches + multiple templates. Templates with lower 'order' values are merged first. + Templates with higher 'order' values are merged later, overriding templates + with lower values. + :param settings: Configuration options for the index. + :param timeout: + :param version: Version number used to manage index templates externally. This + number is not automatically generated by Elasticsearch. + """ if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'name'.") - - return await client._perform_request( - "POST", - _make_path("_index_template", "_simulate_index", name), - params=params, - headers=headers, - body=body, + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_template/{_quote(name)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if aliases is not None: + __body["aliases"] = aliases + if create is not None: + __query["create"] = create + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if flat_settings is not None: + __query["flat_settings"] = flat_settings + if human is not None: + __query["human"] = human + if include_type_name is not None: + __query["include_type_name"] = include_type_name + if index_patterns is not None: + __body["index_patterns"] = index_patterns + if mappings is not None: + __body["mappings"] = mappings + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if order is not None: + __body["order"] = order + if pretty is not None: + __query["pretty"] = pretty + if settings is not None: + __body["settings"] = settings + if timeout is not None: + __query["timeout"] = timeout + if version is not None: + __body["version"] = version + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "PUT", __target, headers=__headers, body=__body ) - @query_params("expand_wildcards") - async def get_data_stream(self, name=None, params=None, headers=None): + @_rewrite_parameters() + async def recovery( + self, + *, + index: Optional[Any] = None, + active_only: Optional[bool] = None, + detailed: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Returns data streams. + Returns information about ongoing index shard recoveries. - ``_ + ``_ - :arg name: A comma-separated list of data streams to get; use - `*` to get all data streams - :arg expand_wildcards: Whether wildcard expressions should get - expanded to open or closed indices (default: open) Valid choices: open, - closed, hidden, none, all Default: open + :param index: A comma-separated list of index names; use `_all` or empty string + to perform the operation on all indices + :param active_only: Display only those recoveries that are currently on-going + :param detailed: Whether to display detailed information about shard recovery + """ + if index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_recovery" + else: + __path = "/_recovery" + __query: Dict[str, Any] = {} + if active_only is not None: + __query["active_only"] = active_only + if detailed is not None: + __query["detailed"] = detailed + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def refresh( + self, + *, + index: Optional[Any] = None, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", _make_path("_data_stream", name), params=params, headers=headers - ) + Performs the refresh operation in one or more indices. - @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 + ``_ - ``_ + :param index: A comma-separated list of index names; use `_all` or empty string + to perform the operation on all indices + :param 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) + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + """ + if index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_refresh" + else: + __path = "/_refresh" + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters() + async def reload_search_analyzers( + self, + *, + index: Any, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: + """ + Reloads an index's search analyzers and their resources. - :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 - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "POST", - _make_path("_index_template", "_simulate", name), - params=params, - headers=headers, - body=body, - ) + ``_ - @query_params("expand_wildcards") - async def resolve_index(self, name, params=None, headers=None): + :param index: A comma-separated list of index names to reload analyzers for + :param 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) + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param 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 parameter 'index'") + __path = f"/{_quote(index)}/_reload_search_analyzers" + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters() + async def resolve_index( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Returns information about any matching indices, aliases, and data streams ``_ - :arg name: A comma-separated list of names or wildcard - expressions - :arg expand_wildcards: Whether wildcard expressions should get - expanded to open or closed indices (default: open) Valid choices: open, - closed, hidden, none, all Default: open + :param name: A comma-separated list of names or wildcard expressions + :param expand_wildcards: Whether wildcard expressions should get expanded to + open or closed indices (default: open) """ - client, params = _deprecated_options(self, params) if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'name'.") - - return await client._perform_request( - "GET", _make_path("_resolve", "index", name), params=params, headers=headers - ) - - @query_params( - "allow_no_indices", - "expand_wildcards", - "ignore_unavailable", - "master_timeout", - "timeout", + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_resolve/index/{_quote(name)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, ) - async def add_block(self, index, block, params=None, headers=None): + async def rollover( + self, + *, + alias: Any, + new_index: Optional[Any] = None, + aliases: Optional[Dict[Any, Any]] = None, + conditions: Optional[Any] = None, + dry_run: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + include_type_name: Optional[bool] = None, + mappings: Optional[Union[Any, Dict[str, Any]]] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + settings: Optional[Dict[str, Any]] = None, + timeout: Optional[Any] = None, + wait_for_active_shards: Optional[Any] = None, + ) -> Any: """ - Adds a block to an index. + Updates an alias to point to a new index when the existing index is considered + to be too large or too old. - ``_ + ``_ - :arg index: A comma separated list of indices to add a block to - :arg block: The block to add (one of read, write, read_only or - metadata) - :arg allow_no_indices: Whether to ignore if a wildcard indices - expression resolves into no concrete indices. (This includes `_all` - string or when no indices have been specified) - :arg expand_wildcards: Whether to expand wildcard expression to - concrete indices that are open, closed or both. Valid choices: open, - closed, hidden, none, all Default: open - :arg ignore_unavailable: Whether specified concrete indices - should be ignored when unavailable (missing or closed) - :arg master_timeout: Specify timeout for connection to master - :arg timeout: Explicit operation timeout - """ - client, params = _deprecated_options(self, params) - for param in (index, block): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "PUT", _make_path(index, "_block", block), params=params, headers=headers + :param alias: The name of the alias to rollover + :param new_index: The name of the rollover index + :param aliases: + :param conditions: + :param 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 + :param include_type_name: + :param mappings: + :param master_timeout: Specify timeout for connection to master + :param settings: + :param timeout: Explicit operation timeout + :param 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 parameter 'alias'") + if alias not in SKIP_IN_PATH and new_index not in SKIP_IN_PATH: + __path = f"/{_quote(alias)}/_rollover/{_quote(new_index)}" + elif alias not in SKIP_IN_PATH: + __path = f"/{_quote(alias)}/_rollover" + else: + raise ValueError("Couldn't find a path for the given parameters") + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if aliases is not None: + __body["aliases"] = aliases + if conditions is not None: + __body["conditions"] = conditions + if dry_run is not None: + __query["dry_run"] = dry_run + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if include_type_name is not None: + __query["include_type_name"] = include_type_name + if mappings is not None: + __body["mappings"] = mappings + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if settings is not None: + __body["settings"] = settings + if timeout is not None: + __query["timeout"] = timeout + if wait_for_active_shards is not None: + __query["wait_for_active_shards"] = wait_for_active_shards + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "POST", __target, headers=__headers, body=__body ) - @query_params() - async def data_streams_stats(self, name=None, params=None, headers=None): + @_rewrite_parameters() + async def segments( + self, + *, + index: Optional[Any] = None, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + pretty: Optional[bool] = None, + verbose: Optional[bool] = None, + ) -> Any: """ - Provides statistics on operations happening in a data stream. + Provides low-level information about segments in a Lucene index. - ``_ + ``_ - :arg name: A comma-separated list of data stream names; use - `_all` or empty string to perform the operation on all data streams + :param index: A comma-separated list of index names; use `_all` or empty string + to perform the operation on all indices + :param 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) + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param verbose: Includes detailed memory usage by Lucene. + """ + if index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_segments" + else: + __path = "/_segments" + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if pretty is not None: + __query["pretty"] = pretty + if verbose is not None: + __query["verbose"] = verbose + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def shard_stores( + self, + *, + index: Optional[Any] = None, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + pretty: Optional[bool] = None, + status: Optional[Union[Any, List[Any]]] = None, + ) -> Any: """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", - _make_path("_data_stream", name, "_stats"), - params=params, - headers=headers, - ) + Provides store information for shard copies of indices. - @query_params() - async def migrate_to_data_stream(self, name, params=None, headers=None): + ``_ + + :param index: List of data streams, indices, and aliases used to limit the request. + :param allow_no_indices: If false, the request returns an error if any wildcard + expression, index alias, or _all value targets only missing or closed indices. + This behavior applies even if the request targets other open indices. + :param expand_wildcards: Type of index that wildcard patterns can match. If the + request can target data streams, this argument determines whether wildcard + expressions match hidden data streams. + :param ignore_unavailable: If true, missing or closed indices are not included + in the response. + :param status: List of shard health statuses used to limit the request. + """ + if index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_shard_stores" + else: + __path = "/_shard_stores" + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if pretty is not None: + __query["pretty"] = pretty + if status is not None: + __query["status"] = status + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + async def shrink( + self, + *, + index: Any, + target: Any, + aliases: Optional[Dict[Any, Any]] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + settings: Optional[Dict[str, Any]] = None, + timeout: Optional[Any] = None, + wait_for_active_shards: Optional[Any] = None, + ) -> Any: """ - Migrates an alias to a data stream + Allow to shrink an existing index into a new index with fewer primary shards. - ``_ + ``_ - :arg name: The name of the alias to migrate + :param index: The name of the source index to shrink + :param target: The name of the target index to shrink into + :param aliases: + :param master_timeout: Specify timeout for connection to master + :param settings: + :param timeout: Explicit operation timeout + :param wait_for_active_shards: Set the number of active shards to wait for on + the shrunken index before the operation returns. """ - client, params = _deprecated_options(self, params) - if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'name'.") - - return await client._perform_request( - "POST", - _make_path("_data_stream", "_migrate", name), - params=params, - headers=headers, + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + if target in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'target'") + __path = f"/{_quote(index)}/_shrink/{_quote(target)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if aliases is not None: + __body["aliases"] = aliases + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if settings is not None: + __body["settings"] = settings + if timeout is not None: + __query["timeout"] = timeout + if wait_for_active_shards is not None: + __query["wait_for_active_shards"] = wait_for_active_shards + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "PUT", __target, headers=__headers, body=__body ) - @query_params() - async def promote_data_stream(self, name, params=None, headers=None): - """ - Promotes a data stream from a replicated data stream managed by CCR to a - regular data stream + @_rewrite_parameters( + body_fields=True, + ) + async def simulate_index_template( + self, + *, + name: Any, + composed_of: Optional[List[Any]] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + index_patterns: Optional[List[Any]] = None, + overlapping: Optional[List[Any]] = None, + pretty: Optional[bool] = None, + template: Optional[Any] = None, + ) -> Any: + """ + Simulate matching the given index name against the index templates in the system - ``_ + ``_ - :arg name: The name of the data stream + :param name: Index or template name to simulate + :param composed_of: + :param index_patterns: + :param overlapping: Any overlapping templates that would have matched, but have + lower priority + :param template: """ - client, params = _deprecated_options(self, params) if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'name'.") - - return await client._perform_request( - "POST", - _make_path("_data_stream", "_promote", name), - params=params, - headers=headers, + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_index_template/_simulate_index/{_quote(name)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if composed_of is not None: + __body["composed_of"] = composed_of + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if index_patterns is not None: + __body["index_patterns"] = index_patterns + if overlapping is not None: + __body["overlapping"] = overlapping + if pretty is not None: + __query["pretty"] = pretty + if template is not None: + __body["template"] = template + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "POST", __target, headers=__headers, body=__body ) - @query_params( - "allow_no_indices", - "expand_wildcards", - "flush", - "ignore_unavailable", - "run_expensive_tasks", + @_rewrite_parameters( + body_name="template", ) - async def disk_usage(self, index, params=None, headers=None): + async def simulate_template( + self, + *, + template: Any, + name: Optional[Any] = None, + create: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Analyzes the disk usage of each field of an index or data stream - - ``_ + Simulate resolving the given template name or body - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - - :arg index: Comma-separated list of indices or data streams to - analyze the disk usage - :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: Whether flush or not before analyzing the index disk - usage. Defaults to true - :arg ignore_unavailable: Whether specified concrete indices - should be ignored when unavailable (missing or closed) - :arg run_expensive_tasks: Must be set to [true] in order for the - task to be performed. Defaults to false. - """ - client, params = _deprecated_options(self, params) - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") + ``_ - return await client._perform_request( - "POST", _make_path(index, "_disk_usage"), params=params, headers=headers + :param template: + :param name: Name of the index template to simulate. To test a template configuration + before you add it to the cluster, omit this parameter and specify the template + configuration in the request body. + :param create: If true, the template passed in the body is only used if no existing + templates match the same index patterns. If false, the simulation uses the + template with the highest priority. Note that the template is not permanently + added or updated in either case; it is only used for the simulation. + :param master_timeout: Period to wait for a connection to the master node. If + no response is received before the timeout expires, the request fails and + returns an error. + """ + if template is None: + raise ValueError("Empty value passed for parameter 'template'") + if name not in SKIP_IN_PATH: + __path = f"/_index_template/_simulate/{_quote(name)}" + else: + __path = "/_index_template/_simulate" + __query: Dict[str, Any] = {} + if create is not None: + __query["create"] = create + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + __body = template + if not __body: + __body = None + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "POST", __target, headers=__headers, body=__body ) - @query_params( - "allow_no_indices", "expand_wildcards", "fields", "ignore_unavailable" + @_rewrite_parameters( + body_fields=True, ) - async def field_usage_stats(self, index, params=None, headers=None): + async def split( + self, + *, + index: Any, + target: Any, + aliases: Optional[Dict[Any, Any]] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + settings: Optional[Dict[str, Any]] = None, + timeout: Optional[Any] = None, + wait_for_active_shards: Optional[Any] = None, + ) -> Any: + """ + Allows you to split an existing index into a new index with more primary shards. + + ``_ + + :param index: The name of the source index to split + :param target: The name of the target index to split into + :param aliases: + :param master_timeout: Specify timeout for connection to master + :param settings: + :param timeout: Explicit operation timeout + :param wait_for_active_shards: Set the number of active shards to wait for on + the shrunken index before the operation returns. """ - Returns the field usage stats for each field of an index + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + if target in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'target'") + __path = f"/{_quote(index)}/_split/{_quote(target)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if aliases is not None: + __body["aliases"] = aliases + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if settings is not None: + __body["settings"] = settings + if timeout is not None: + __query["timeout"] = timeout + if wait_for_active_shards is not None: + __query["wait_for_active_shards"] = wait_for_active_shards + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "PUT", __target, headers=__headers, body=__body + ) - ``_ + @_rewrite_parameters() + async def stats( + self, + *, + index: Optional[Any] = None, + metric: Optional[Any] = None, + completion_fields: Optional[Any] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + fielddata_fields: Optional[Any] = None, + fields: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + forbid_closed_indices: Optional[bool] = None, + groups: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + include_segment_file_sizes: Optional[bool] = None, + include_unloaded_segments: Optional[bool] = None, + level: Optional[Any] = None, + pretty: Optional[bool] = None, + types: Optional[Any] = None, + ) -> Any: + """ + Provides statistics on operations happening in an index. - .. warning:: + ``_ - This API is **experimental** so may include breaking changes - or be removed in a future version + :param index: A comma-separated list of index names; use `_all` or empty string + to perform the operation on all indices + :param metric: Limit the information returned the specific metrics. + :param completion_fields: A comma-separated list of fields for the `completion` + index metric (supports wildcards) + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param fielddata_fields: A comma-separated list of fields for the `fielddata` + index metric (supports wildcards) + :param fields: A comma-separated list of fields for `fielddata` and `completion` + index metric (supports wildcards) + :param forbid_closed_indices: If set to false stats will also collected from + closed indices if explicitly specified or if expand_wildcards expands to + closed indices + :param groups: A comma-separated list of search groups for `search` index metric + :param 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) + :param include_unloaded_segments: If set to true segment stats will include stats + for segments that are not currently loaded into memory + :param level: Return stats aggregated at cluster, index or shard level + :param types: A comma-separated list of document types for the `indexing` index + metric + """ + if index not in SKIP_IN_PATH and metric not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_stats/{_quote(metric)}" + elif index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_stats" + elif metric not in SKIP_IN_PATH: + __path = f"/_stats/{_quote(metric)}" + else: + __path = "/_stats" + __query: Dict[str, Any] = {} + if completion_fields is not None: + __query["completion_fields"] = completion_fields + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if fielddata_fields is not None: + __query["fielddata_fields"] = fielddata_fields + if fields is not None: + __query["fields"] = fields + if filter_path is not None: + __query["filter_path"] = filter_path + if forbid_closed_indices is not None: + __query["forbid_closed_indices"] = forbid_closed_indices + if groups is not None: + __query["groups"] = groups + if human is not None: + __query["human"] = human + if include_segment_file_sizes is not None: + __query["include_segment_file_sizes"] = include_segment_file_sizes + if include_unloaded_segments is not None: + __query["include_unloaded_segments"] = include_unloaded_segments + if level is not None: + __query["level"] = level + if pretty is not None: + __query["pretty"] = pretty + if types is not None: + __query["types"] = types + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def unfreeze( + self, + *, + index: Any, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + wait_for_active_shards: Optional[str] = None, + ) -> Any: + """ + Unfreezes an index. When a frozen index is unfrozen, the index goes through the + normal recovery process and becomes writeable again. - :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 fields: A comma-separated list of fields to include in the - stats if only a subset of fields should be returned (supports wildcards) - :arg ignore_unavailable: Whether specified concrete indices - should be ignored when unavailable (missing or closed) + ``_ + + :param index: The name of the index to unfreeze + :param 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) + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param master_timeout: Specify timeout for connection to master + :param timeout: Explicit operation timeout + :param wait_for_active_shards: Sets the number of active shards to wait for before + the operation returns. """ - client, params = _deprecated_options(self, params) if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") + raise ValueError("Empty value passed for parameter 'index'") + __path = f"/{_quote(index)}/_unfreeze" + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if wait_for_active_shards is not None: + __query["wait_for_active_shards"] = wait_for_active_shards + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + async def update_aliases( + self, + *, + actions: Optional[List[Any]] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: + """ + Updates index aliases. + + ``_ - return await client._perform_request( - "GET", - _make_path(index, "_field_usage_stats"), - params=params, - headers=headers, + :param actions: + :param master_timeout: Specify timeout for connection to master + :param timeout: Request timeout + """ + __path = "/_aliases" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if actions is not None: + __body["actions"] = actions + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "POST", __target, headers=__headers, body=__body ) - @query_params() - async def modify_data_stream(self, body, params=None, headers=None): + @_rewrite_parameters( + body_fields=True, + ) + async def validate_query( + self, + *, + index: Optional[Any] = None, + type: Optional[Any] = None, + all_shards: Optional[bool] = None, + allow_no_indices: Optional[bool] = None, + analyze_wildcard: Optional[bool] = None, + analyzer: Optional[str] = None, + default_operator: Optional[Any] = None, + df: Optional[str] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + explain: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + lenient: Optional[bool] = None, + pretty: Optional[bool] = None, + q: Optional[str] = None, + query: Optional[Any] = None, + rewrite: Optional[bool] = None, + ) -> Any: """ - Modifies a data stream - - ``_ + Allows a user to validate a potentially expensive query without executing it. - :arg body: The data stream modifications - """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") + ``_ - return await client._perform_request( - "POST", "/_data_stream/_modify", params=params, headers=headers, body=body + :param index: A comma-separated list of index names to restrict the operation; + use `_all` or empty string to perform the operation on all indices + :param type: A comma-separated list of document types to restrict the operation; + leave empty to perform the operation on all types + :param all_shards: Execute validation on all shards instead of one random shard + per index + :param 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) + :param analyze_wildcard: Specify whether wildcard and prefix queries should be + analyzed (default: false) + :param analyzer: The analyzer to use for the query string + :param default_operator: The default operator for query string query (AND or + OR) + :param df: The field to use as default where no field prefix is given in the + query string + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param explain: Return detailed information about the error + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param lenient: Specify whether format-based query failures (such as providing + text to a numeric field) should be ignored + :param q: Query in the Lucene query string syntax + :param query: + :param rewrite: Provide a more detailed explanation showing the actual Lucene + query that will be executed. + """ + if index not in SKIP_IN_PATH and type not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/{_quote(type)}/_validate/query" + elif index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_validate/query" + else: + __path = "/_validate/query" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if all_shards is not None: + __query["all_shards"] = all_shards + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if analyze_wildcard is not None: + __query["analyze_wildcard"] = analyze_wildcard + if analyzer is not None: + __query["analyzer"] = analyzer + if default_operator is not None: + __query["default_operator"] = default_operator + if df is not None: + __query["df"] = df + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if explain is not None: + __query["explain"] = explain + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if lenient is not None: + __query["lenient"] = lenient + if pretty is not None: + __query["pretty"] = pretty + if q is not None: + __query["q"] = q + if query is not None: + __body["query"] = query + if rewrite is not None: + __query["rewrite"] = rewrite + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "POST", __target, headers=__headers, body=__body ) diff --git a/elasticsearch/_async/client/indices.pyi b/elasticsearch/_async/client/indices.pyi deleted file mode 100644 index cde90aa62..000000000 --- a/elasticsearch/_async/client/indices.pyi +++ /dev/null @@ -1,1171 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import HeadApiResponse, ObjectApiResponse - -from ._base import NamespacedClient - -class IndicesClient(NamespacedClient): - async def analyze( - self, - *, - body: Optional[Any] = ..., - index: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def refresh( - self, - *, - index: Optional[Any] = ..., - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def flush( - self, - *, - index: Optional[Any] = ..., - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - force: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - wait_if_ongoing: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def create( - self, - index: Any, - *, - body: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - wait_for_active_shards: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def clone( - self, - index: Any, - target: Any, - *, - body: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - wait_for_active_shards: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get( - self, - index: Any, - *, - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - flat_settings: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - include_defaults: Optional[Any] = ..., - local: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def open( - self, - index: Any, - *, - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - wait_for_active_shards: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def close( - self, - index: Any, - *, - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - wait_for_active_shards: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def delete( - self, - index: Any, - *, - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def exists( - self, - index: Any, - *, - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - flat_settings: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - include_defaults: Optional[Any] = ..., - local: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> HeadApiResponse: ... - async def exists_type( - self, - index: Any, - doc_type: Any, - *, - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - local: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> HeadApiResponse: ... - async def put_mapping( - self, - index: Any, - *, - body: Any, - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - write_index_only: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_mapping( - self, - *, - index: Optional[Any] = ..., - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - local: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def put_alias( - self, - index: Any, - name: Any, - *, - body: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def exists_alias( - self, - name: Any, - *, - index: Optional[Any] = ..., - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - local: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> HeadApiResponse: ... - async def get_alias( - self, - *, - index: Optional[Any] = ..., - name: Optional[Any] = ..., - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - local: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def update_aliases( - self, - *, - body: Any, - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def delete_alias( - self, - index: Any, - name: Any, - *, - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def put_template( - self, - name: Any, - *, - body: Any, - create: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - order: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def exists_template( - self, - name: Any, - *, - flat_settings: Optional[Any] = ..., - local: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> HeadApiResponse: ... - async def get_template( - self, - *, - name: Optional[Any] = ..., - flat_settings: Optional[Any] = ..., - local: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def delete_template( - self, - name: Any, - *, - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_settings( - self, - *, - index: Optional[Any] = ..., - name: Optional[Any] = ..., - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - flat_settings: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - include_defaults: Optional[Any] = ..., - local: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def put_settings( - self, - *, - body: Any, - index: Optional[Any] = ..., - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - flat_settings: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - preserve_existing: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def stats( - self, - *, - index: Optional[Any] = ..., - metric: Optional[Any] = ..., - completion_fields: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - fielddata_fields: Optional[Any] = ..., - fields: Optional[Any] = ..., - forbid_closed_indices: Optional[Any] = ..., - groups: Optional[Any] = ..., - include_segment_file_sizes: Optional[Any] = ..., - include_unloaded_segments: Optional[Any] = ..., - level: Optional[Any] = ..., - types: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def segments( - self, - *, - index: Optional[Any] = ..., - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - verbose: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def clear_cache( - self, - *, - index: Optional[Any] = ..., - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - fielddata: Optional[Any] = ..., - fields: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - query: Optional[Any] = ..., - request: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def recovery( - self, - *, - index: Optional[Any] = ..., - active_only: Optional[Any] = ..., - detailed: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def shard_stores( - self, - *, - index: Optional[Any] = ..., - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - status: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def forcemerge( - self, - *, - index: Optional[Any] = ..., - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - flush: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - max_num_segments: Optional[Any] = ..., - only_expunge_deletes: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def shrink( - self, - index: Any, - target: Any, - *, - body: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - wait_for_active_shards: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def split( - self, - index: Any, - target: Any, - *, - body: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - wait_for_active_shards: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def rollover( - self, - alias: Any, - *, - body: Optional[Any] = ..., - new_index: Optional[Any] = ..., - dry_run: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - wait_for_active_shards: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def unfreeze( - self, - index: Any, - *, - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - wait_for_active_shards: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def reload_search_analyzers( - self, - index: Any, - *, - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_field_mapping( - self, - fields: Any, - *, - index: Optional[Any] = ..., - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - include_defaults: Optional[Any] = ..., - local: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def validate_query( - self, - *, - body: Optional[Any] = ..., - index: Optional[Any] = ..., - doc_type: Optional[Any] = ..., - all_shards: Optional[Any] = ..., - allow_no_indices: Optional[Any] = ..., - analyze_wildcard: Optional[Any] = ..., - analyzer: Optional[Any] = ..., - default_operator: Optional[Any] = ..., - df: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - explain: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - lenient: Optional[Any] = ..., - q: Optional[Any] = ..., - rewrite: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def create_data_stream( - self, - name: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def delete_data_stream( - self, - name: Any, - *, - expand_wildcards: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def delete_index_template( - self, - name: Any, - *, - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_index_template( - self, - *, - name: Optional[Any] = ..., - flat_settings: Optional[Any] = ..., - local: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def put_index_template( - self, - name: Any, - *, - body: Any, - cause: Optional[Any] = ..., - create: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def exists_index_template( - self, - name: Any, - *, - flat_settings: Optional[Any] = ..., - local: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> HeadApiResponse: ... - async def simulate_index_template( - self, - name: Any, - *, - body: Optional[Any] = ..., - cause: Optional[Any] = ..., - create: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_data_stream( - self, - *, - name: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def simulate_template( - self, - *, - body: Optional[Any] = ..., - name: Optional[Any] = ..., - cause: Optional[Any] = ..., - create: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def resolve_index( - self, - name: Any, - *, - expand_wildcards: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def add_block( - self, - index: Any, - block: Any, - *, - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def data_streams_stats( - self, - *, - name: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def migrate_to_data_stream( - self, - name: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def promote_data_stream( - self, - name: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def disk_usage( - self, - index: Any, - *, - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - flush: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - run_expensive_tasks: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def field_usage_stats( - self, - index: Any, - *, - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - fields: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def modify_data_stream( - self, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_async/client/ingest.py b/elasticsearch/_async/client/ingest.py index 2baa5ae99..b0b24b0d6 100644 --- a/elasticsearch/_async/client/ingest.py +++ b/elasticsearch/_async/client/ingest.py @@ -15,125 +15,297 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params +from .utils import SKIP_IN_PATH, _quote, _quote_query, _rewrite_parameters class IngestClient(NamespacedClient): - @query_params("master_timeout", "summary") - async def get_pipeline(self, id=None, params=None, headers=None): + @_rewrite_parameters() + async def delete_pipeline( + self, + *, + id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ - Returns a pipeline. + Deletes a pipeline. - ``_ + ``_ - :arg id: Comma separated list of pipeline ids. Wildcards - supported - :arg master_timeout: Explicit operation timeout for connection - to master node - :arg summary: Return pipelines without their definitions - (default: false) + :param id: Pipeline ID + :param master_timeout: Explicit operation timeout for connection to master node + :param timeout: Explicit operation timeout """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", _make_path("_ingest", "pipeline", id), params=params, headers=headers - ) + if id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/_ingest/pipeline/{_quote(id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("DELETE", __target, headers=__headers) - @query_params("if_version", "master_timeout", "timeout") - async def put_pipeline(self, id, body, params=None, headers=None): + @_rewrite_parameters() + async def geo_ip_stats( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Creates or updates a pipeline. - - ``_ + Returns statistical information about geoip databases - :arg id: Pipeline ID - :arg body: The ingest definition - :arg if_version: Required version for optimistic concurrency - control for pipeline updates - :arg master_timeout: Explicit operation timeout for connection - to master node - :arg timeout: Explicit operation timeout + ``_ """ - client, params = _deprecated_options(self, params) - for param in (id, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "PUT", - _make_path("_ingest", "pipeline", id), - params=params, - headers=headers, - body=body, - ) + __path = "/_ingest/geoip/stats" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) - @query_params("master_timeout", "timeout") - async def delete_pipeline(self, id, params=None, headers=None): + @_rewrite_parameters() + async def get_pipeline( + self, + *, + id: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + summary: Optional[bool] = None, + ) -> Any: """ - Deletes a pipeline. + Returns a pipeline. - ``_ + ``_ - :arg id: Pipeline ID - :arg master_timeout: Explicit operation timeout for connection - to master node - :arg timeout: Explicit operation timeout + :param id: Comma separated list of pipeline ids. Wildcards supported + :param master_timeout: Explicit operation timeout for connection to master node + :param summary: Return pipelines without their definitions (default: false) """ - client, params = _deprecated_options(self, params) - if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'id'.") + if id not in SKIP_IN_PATH: + __path = f"/_ingest/pipeline/{_quote(id)}" + else: + __path = "/_ingest/pipeline" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if summary is not None: + __query["summary"] = summary + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) - return await client._perform_request( - "DELETE", - _make_path("_ingest", "pipeline", id), - params=params, - headers=headers, - ) - - @query_params("verbose") - async def simulate(self, body, id=None, params=None, headers=None): + @_rewrite_parameters() + async def processor_grok( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Allows to simulate a pipeline with example documents. - - ``_ + Returns a list of the built-in patterns. - :arg body: The simulate definition - :arg id: Pipeline ID - :arg verbose: Verbose mode. Display data output for each - processor in executed pipeline + ``_ """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return await client._perform_request( - "POST", - _make_path("_ingest", "pipeline", id, "_simulate"), - params=params, - headers=headers, - body=body, - ) + __path = "/_ingest/processor/grok" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) - @query_params() - async def processor_grok(self, params=None, headers=None): + @_rewrite_parameters( + body_fields=True, + parameter_aliases={"_meta": "meta"}, + ) + async def put_pipeline( + self, + *, + id: Any, + description: Optional[str] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + meta: Optional[Any] = None, + on_failure: Optional[List[Any]] = None, + pretty: Optional[bool] = None, + processors: Optional[List[Any]] = None, + timeout: Optional[Any] = None, + version: Optional[Any] = None, + ) -> Any: """ - Returns a list of the built-in patterns. + Creates or updates a pipeline. - ``_ + ``_ + + :param id: ID of the ingest pipeline to create or update. + :param description: Description of the ingest pipeline. + :param master_timeout: Period to wait for a connection to the master node. If + no response is received before the timeout expires, the request fails and + returns an error. + :param meta: Optional metadata about the ingest pipeline. May have any contents. + This map is not automatically generated by Elasticsearch. + :param on_failure: Processors to run immediately after a processor failure. Each + processor supports a processor-level `on_failure` value. If a processor without + an `on_failure` value fails, Elasticsearch uses this pipeline-level parameter + as a fallback. The processors in this parameter run sequentially in the order + specified. Elasticsearch will not attempt to run the pipeline's remaining + processors. + :param processors: Processors used to perform transformations on documents before + indexing. Processors run sequentially in the order specified. + :param timeout: Period to wait for a response. If no response is received before + the timeout expires, the request fails and returns an error. + :param version: Version number used by external systems to track ingest pipelines. + This parameter is intended for external systems only. Elasticsearch does + not use or validate pipeline version numbers. """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", "/_ingest/processor/grok", params=params, headers=headers + if id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/_ingest/pipeline/{_quote(id)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if description is not None: + __body["description"] = description + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if meta is not None: + __body["_meta"] = meta + if on_failure is not None: + __body["on_failure"] = on_failure + if pretty is not None: + __query["pretty"] = pretty + if processors is not None: + __body["processors"] = processors + if timeout is not None: + __query["timeout"] = timeout + if version is not None: + __body["version"] = version + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "PUT", __target, headers=__headers, body=__body ) - @query_params() - async def geo_ip_stats(self, params=None, headers=None): + @_rewrite_parameters( + body_fields=True, + ) + async def simulate( + self, + *, + id: Optional[Any] = None, + docs: Optional[List[Any]] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pipeline: Optional[Any] = None, + pretty: Optional[bool] = None, + verbose: Optional[bool] = None, + ) -> Any: """ - Returns statistical information about geoip databases + Allows to simulate a pipeline with example documents. - ``_ + ``_ + + :param id: Pipeline ID + :param docs: + :param pipeline: + :param verbose: Verbose mode. Display data output for each processor in executed + pipeline """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", "/_ingest/geoip/stats", params=params, headers=headers + if id not in SKIP_IN_PATH: + __path = f"/_ingest/pipeline/{_quote(id)}/_simulate" + else: + __path = "/_ingest/pipeline/_simulate" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if docs is not None: + __body["docs"] = docs + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pipeline is not None: + __body["pipeline"] = pipeline + if pretty is not None: + __query["pretty"] = pretty + if verbose is not None: + __query["verbose"] = verbose + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "POST", __target, headers=__headers, body=__body ) diff --git a/elasticsearch/_async/client/ingest.pyi b/elasticsearch/_async/client/ingest.pyi deleted file mode 100644 index f9e4678d4..000000000 --- a/elasticsearch/_async/client/ingest.pyi +++ /dev/null @@ -1,134 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class IngestClient(NamespacedClient): - async def get_pipeline( - self, - *, - id: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - summary: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def put_pipeline( - self, - id: Any, - *, - body: Any, - if_version: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def delete_pipeline( - self, - id: Any, - *, - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def simulate( - self, - *, - body: Any, - id: Optional[Any] = ..., - verbose: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def processor_grok( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def geo_ip_stats( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_async/client/license.py b/elasticsearch/_async/client/license.py index b825e7a5c..5e0872488 100644 --- a/elasticsearch/_async/client/license.py +++ b/elasticsearch/_async/client/license.py @@ -15,111 +15,276 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import _deprecated_options, query_params +from .utils import _quote_query, _rewrite_parameters class LicenseClient(NamespacedClient): - @query_params() - async def delete(self, params=None, headers=None): + @_rewrite_parameters() + async def delete( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Deletes licensing information for the cluster ``_ """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "DELETE", "/_license", params=params, headers=headers - ) + __path = "/_license" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("DELETE", __target, headers=__headers) - @query_params("accept_enterprise", "local") - async def get(self, params=None, headers=None): + @_rewrite_parameters() + async def get( + self, + *, + accept_enterprise: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ 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 local: Return local information, do not retrieve the state - from master node (default: false) + :param accept_enterprise: Supported for backwards compatibility with 7.x. If + this param is used it must be set to true + :param local: Return local information, do not retrieve the state from master + node (default: false) """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", "/_license", params=params, headers=headers - ) + __path = "/_license" + __query: Dict[str, Any] = {} + if accept_enterprise is not None: + __query["accept_enterprise"] = accept_enterprise + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) - @query_params() - async def get_basic_status(self, params=None, headers=None): + @_rewrite_parameters() + async def get_basic_status( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Retrieves information about the status of the basic license. ``_ """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", "/_license/basic_status", params=params, headers=headers - ) + __path = "/_license/basic_status" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) - @query_params() - async def get_trial_status(self, params=None, headers=None): + @_rewrite_parameters() + async def get_trial_status( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Retrieves information about the status of the trial license. ``_ """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", "/_license/trial_status", params=params, headers=headers - ) + __path = "/_license/trial_status" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) - @query_params("acknowledge") - async def post(self, body=None, params=None, headers=None): + @_rewrite_parameters( + body_fields=True, + ) + async def post( + self, + *, + acknowledge: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + license: Optional[Any] = None, + licenses: Optional[List[Any]] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Updates the license for the cluster. ``_ - :arg body: licenses to be installed - :arg acknowledge: whether the user has acknowledged acknowledge - messages (default: false) + :param acknowledge: whether the user has acknowledged acknowledge messages (default: + false) + :param license: + :param licenses: """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "PUT", "/_license", params=params, headers=headers, body=body + __path = "/_license" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if acknowledge is not None: + __query["acknowledge"] = acknowledge + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if license is not None: + __body["license"] = license + if licenses is not None: + __body["licenses"] = licenses + if pretty is not None: + __query["pretty"] = pretty + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "PUT", __target, headers=__headers, body=__body ) - @query_params("acknowledge") - async def post_start_basic(self, params=None, headers=None): + @_rewrite_parameters() + async def post_start_basic( + self, + *, + acknowledge: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Starts an indefinite basic license. ``_ - :arg acknowledge: whether the user has acknowledged acknowledge - messages (default: false) + :param acknowledge: whether the user has acknowledged acknowledge messages (default: + false) """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "POST", "/_license/start_basic", params=params, headers=headers - ) + __path = "/_license/start_basic" + __query: Dict[str, Any] = {} + if acknowledge is not None: + __query["acknowledge"] = acknowledge + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) - @query_params("acknowledge", "doc_type") - async def post_start_trial(self, params=None, headers=None): + @_rewrite_parameters() + async def post_start_trial( + self, + *, + acknowledge: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + type_query_string: Optional[str] = None, + ) -> Any: """ starts a limited time trial license. ``_ - :arg acknowledge: whether the user has acknowledged acknowledge - messages (default: false) - :arg doc_type: The type of trial license to generate (default: - "trial") + :param acknowledge: whether the user has acknowledged acknowledge messages (default: + false) + :param type_query_string: """ - client, params = _deprecated_options(self, params) - if params and "doc_type" in params: - params["type"] = params.pop("doc_type") - - return await client._perform_request( - "POST", "/_license/start_trial", params=params, headers=headers - ) + __path = "/_license/start_trial" + __query: Dict[str, Any] = {} + if acknowledge is not None: + __query["acknowledge"] = acknowledge + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if type_query_string is not None: + __query["type_query_string"] = type_query_string + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) diff --git a/elasticsearch/_async/client/license.pyi b/elasticsearch/_async/client/license.pyi deleted file mode 100644 index cb0bdb061..000000000 --- a/elasticsearch/_async/client/license.pyi +++ /dev/null @@ -1,143 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class LicenseClient(NamespacedClient): - async def delete( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get( - self, - *, - accept_enterprise: Optional[Any] = ..., - local: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_basic_status( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_trial_status( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def post( - self, - *, - body: Optional[Any] = ..., - acknowledge: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def post_start_basic( - self, - *, - acknowledge: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def post_start_trial( - self, - *, - acknowledge: Optional[Any] = ..., - doc_type: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_async/client/logstash.py b/elasticsearch/_async/client/logstash.py index 8223cbb50..b72965a30 100644 --- a/elasticsearch/_async/client/logstash.py +++ b/elasticsearch/_async/client/logstash.py @@ -15,70 +15,126 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params +from .utils import SKIP_IN_PATH, _quote, _quote_query, _rewrite_parameters class LogstashClient(NamespacedClient): - @query_params() - async def delete_pipeline(self, id, params=None, headers=None): + @_rewrite_parameters() + async def delete_pipeline( + self, + *, + id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Deletes Logstash Pipelines used by Central Management - ``_ + ``_ - :arg id: The ID of the Pipeline + :param id: The ID of the Pipeline """ - client, params = _deprecated_options(self, params) if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'id'.") - - return await client._perform_request( - "DELETE", - _make_path("_logstash", "pipeline", id), - params=params, - headers=headers, - ) + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/_logstash/pipeline/{_quote(id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("DELETE", __target, headers=__headers) - @query_params() - async def get_pipeline(self, id, params=None, headers=None): + @_rewrite_parameters() + async def get_pipeline( + self, + *, + id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Retrieves Logstash Pipelines used by Central Management - ``_ + ``_ - :arg id: A comma-separated list of Pipeline IDs + :param id: A comma-separated list of Pipeline IDs """ - client, params = _deprecated_options(self, params) if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'id'.") + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/_logstash/pipeline/{_quote(id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) - return await client._perform_request( - "GET", - _make_path("_logstash", "pipeline", id), - params=params, - headers=headers, - ) - - @query_params() - async def put_pipeline(self, id, body, params=None, headers=None): + @_rewrite_parameters( + body_name="pipeline", + ) + async def put_pipeline( + self, + *, + id: Any, + pipeline: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Adds and updates Logstash Pipelines used for Central Management - ``_ + ``_ - :arg id: The ID of the Pipeline - :arg body: The Pipeline to add or update + :param id: The ID of the Pipeline + :param pipeline: """ - client, params = _deprecated_options(self, params) - for param in (id, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "PUT", - _make_path("_logstash", "pipeline", id), - params=params, - headers=headers, - body=body, + if id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'id'") + if pipeline is None: + raise ValueError("Empty value passed for parameter 'pipeline'") + __path = f"/_logstash/pipeline/{_quote(id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + __body = pipeline + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "PUT", __target, headers=__headers, body=__body ) diff --git a/elasticsearch/_async/client/logstash.pyi b/elasticsearch/_async/client/logstash.pyi deleted file mode 100644 index 02fbf8504..000000000 --- a/elasticsearch/_async/client/logstash.pyi +++ /dev/null @@ -1,76 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class LogstashClient(NamespacedClient): - async def delete_pipeline( - self, - id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_pipeline( - self, - id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def put_pipeline( - self, - id: Any, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_async/client/migration.py b/elasticsearch/_async/client/migration.py index 97b8d61c9..adb5bb146 100644 --- a/elasticsearch/_async/client/migration.py +++ b/elasticsearch/_async/client/migration.py @@ -15,50 +15,49 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import _deprecated_options, _make_path, query_params +from .utils import SKIP_IN_PATH, _quote, _quote_query, _rewrite_parameters class MigrationClient(NamespacedClient): - @query_params() - async def deprecations(self, index=None, params=None, headers=None): + @_rewrite_parameters() + async def deprecations( + self, + *, + index: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ 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 - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", - _make_path(index, "_migration", "deprecations"), - params=params, - headers=headers, - ) - - @query_params() - async def get_feature_upgrade_status(self, params=None, headers=None): - """ - Find out whether system features need to be upgraded or not - - ``_ - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", "/_migration/system_features", params=params, headers=headers - ) - - @query_params() - async def post_feature_upgrade(self, params=None, headers=None): - """ - Begin upgrades for system features + ``_ - ``_ + :param index: Comma-separate list of data streams or indices to check. Wildcard + (*) expressions are supported. """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "POST", "/_migration/system_features", params=params, headers=headers - ) + if index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_migration/deprecations" + else: + __path = "/_migration/deprecations" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) diff --git a/elasticsearch/_async/client/migration.pyi b/elasticsearch/_async/client/migration.pyi deleted file mode 100644 index 864c6324e..000000000 --- a/elasticsearch/_async/client/migration.pyi +++ /dev/null @@ -1,73 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class MigrationClient(NamespacedClient): - async def deprecations( - self, - *, - index: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_feature_upgrade_status( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def post_feature_upgrade( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_async/client/ml.py b/elasticsearch/_async/client/ml.py index f11401c86..7c45927e1 100644 --- a/elasticsearch/_async/client/ml.py +++ b/elasticsearch/_async/client/ml.py @@ -15,1933 +15,3910 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params +from .utils import SKIP_IN_PATH, _quote, _quote_query, _rewrite_parameters class MlClient(NamespacedClient): - @query_params("allow_no_jobs", "allow_no_match", "force", "timeout") - 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 - :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) - :arg allow_no_match: Whether to ignore if a wildcard expression - matches no jobs. (This includes `_all` string or when no jobs have been - specified) - :arg force: True if the job should be forcefully closed - :arg timeout: Controls the time to wait until a job has closed. - Default to 30 minutes - """ - client, params = _deprecated_options(self, params) + @_rewrite_parameters() + async def close_job( + self, + *, + job_id: Any, + allow_no_match: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + force: Optional[bool] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: + """ + Closes one or more anomaly detection jobs. A job can be opened and closed multiple + times throughout its lifecycle. + + ``_ + + :param job_id: Identifier for the anomaly detection job. It can be a job identifier, + a group name, or a wildcard expression. You can close multiple anomaly detection + jobs in a single API request by using a group name, a comma-separated list + of jobs, or a wildcard expression. You can close all jobs by using `_all` + or by specifying `*` as the job identifier. + :param allow_no_match: Specifies what to do when the request: contains wildcard + expressions and there are no jobs that match; contains the `_all` string + or no identifiers and there are no matches; or contains wildcard expressions + and there are only partial matches. By default, it returns an empty jobs + array when there are no matches and the subset of results when there are + partial matches. If `false`, the request returns a 404 status code when there + are no matches or only partial matches. + :param force: Use to close a failed job, or to forcefully close a job which has + not responded to its initial close request; the request returns without performing + the associated actions such as flushing buffers and persisting the model + snapshots. If you want the job to be in a consistent state after the close + job API returns, do not set to `true`. This parameter should be used only + in situations where the job has already failed or where you are not interested + in results the job might have recently produced or might produce in the future. + :param timeout: Controls the time to wait until a job has closed. + """ if job_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'job_id'.") - - return await client._perform_request( - "POST", - _make_path("_ml", "anomaly_detectors", job_id, "_close"), - params=params, - headers=headers, - body=body, - ) - - @query_params() - async def delete_calendar(self, calendar_id, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'job_id'") + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}/_close" + __query: Dict[str, Any] = {} + if allow_no_match is not None: + __query["allow_no_match"] = allow_no_match + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if force is not None: + __query["force"] = force + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters() + async def delete_calendar( + self, + *, + calendar_id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Deletes a calendar. - ``_ + ``_ - :arg calendar_id: The ID of the calendar to delete + :param calendar_id: A string that uniquely identifies a calendar. """ - client, params = _deprecated_options(self, params) if calendar_id in SKIP_IN_PATH: - raise ValueError( - "Empty value passed for a required argument 'calendar_id'." - ) - - return await client._perform_request( - "DELETE", - _make_path("_ml", "calendars", calendar_id), - params=params, - headers=headers, - ) - - @query_params() + raise ValueError("Empty value passed for parameter 'calendar_id'") + __path = f"/_ml/calendars/{_quote(calendar_id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() async def delete_calendar_event( - self, calendar_id, event_id, params=None, headers=None - ): + self, + *, + calendar_id: Any, + event_id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ 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 + :param calendar_id: The ID of the calendar to modify + :param event_id: The ID of the event to remove from the calendar """ - client, params = _deprecated_options(self, params) - for param in (calendar_id, event_id): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "DELETE", - _make_path("_ml", "calendars", calendar_id, "events", event_id), - params=params, - headers=headers, - ) - - @query_params() - async def delete_calendar_job(self, calendar_id, job_id, params=None, headers=None): + if calendar_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'calendar_id'") + if event_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'event_id'") + __path = f"/_ml/calendars/{_quote(calendar_id)}/events/{_quote(event_id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + async def delete_calendar_job( + self, + *, + calendar_id: Any, + job_id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ 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 + :param calendar_id: A string that uniquely identifies a calendar. + :param job_id: An identifier for the anomaly detection jobs. It can be a job + identifier, a group name, or a comma-separated list of jobs or groups. + """ + if calendar_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'calendar_id'") + if job_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'job_id'") + __path = f"/_ml/calendars/{_quote(calendar_id)}/jobs/{_quote(job_id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + async def delete_data_frame_analytics( + self, + *, + id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + force: Optional[bool] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ - client, params = _deprecated_options(self, params) - for param in (calendar_id, job_id): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") + Deletes an existing data frame analytics job. - return await client._perform_request( - "DELETE", - _make_path("_ml", "calendars", calendar_id, "jobs", job_id), - params=params, - headers=headers, - ) + ``_ - @query_params("force") - async def delete_datafeed(self, datafeed_id, params=None, headers=None): + :param id: Identifier for the data frame analytics job. + :param force: If `true`, it deletes a job that is not stopped; this method is + quicker than stopping and deleting the job. + :param timeout: The time to wait for the job to be deleted. + """ + if id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/_ml/data_frame/analytics/{_quote(id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if force is not None: + __query["force"] = force + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + async def delete_datafeed( + self, + *, + datafeed_id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + force: Optional[bool] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Deletes an existing datafeed. - ``_ + ``_ - :arg datafeed_id: The ID of the datafeed to delete - :arg force: True if the datafeed should be forcefully deleted + :param datafeed_id: A numerical character string that uniquely identifies the + datafeed. This identifier can contain lowercase alphanumeric characters (a-z + and 0-9), hyphens, and underscores. It must start and end with alphanumeric + characters. + :param force: Use to forcefully delete a started datafeed; this method is quicker + than stopping and deleting the datafeed. """ - client, params = _deprecated_options(self, params) if datafeed_id in SKIP_IN_PATH: - raise ValueError( - "Empty value passed for a required argument 'datafeed_id'." - ) - - return await client._perform_request( - "DELETE", - _make_path("_ml", "datafeeds", datafeed_id), - params=params, - headers=headers, - ) - - @query_params("requests_per_second", "timeout") + raise ValueError("Empty value passed for parameter 'datafeed_id'") + __path = f"/_ml/datafeeds/{_quote(datafeed_id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if force is not None: + __query["force"] = force + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) async def delete_expired_data( - self, body=None, job_id=None, params=None, headers=None - ): + self, + *, + job_id: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + requests_per_second: Optional[float] = None, + timeout: Optional[Any] = None, + ) -> Any: """ Deletes expired and unused machine learning data. - ``_ - - :arg body: deleting expired data parameters - :arg job_id: The ID of the job(s) to perform expired data - hygiene for - :arg requests_per_second: The desired requests per second for - the deletion processes. - :arg timeout: How long can the underlying delete processes run - until they are canceled - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "DELETE", - _make_path("_ml", "_delete_expired_data", job_id), - params=params, - headers=headers, - body=body, - ) - - @query_params() - async def delete_filter(self, filter_id, params=None, headers=None): + ``_ + + :param job_id: Identifier for an anomaly detection job. It can be a job identifier, + a group name, or a wildcard expression. + :param requests_per_second: The desired requests per second for the deletion + processes. The default behavior is no throttling. + :param timeout: How long can the underlying delete processes run until they are + canceled. + """ + if job_id not in SKIP_IN_PATH: + __path = f"/_ml/_delete_expired_data/{_quote(job_id)}" + else: + __path = "/_ml/_delete_expired_data" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if requests_per_second is not None: + __body["requests_per_second"] = requests_per_second + if timeout is not None: + __body["timeout"] = timeout + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "DELETE", __target, headers=__headers, body=__body + ) + + @_rewrite_parameters() + async def delete_filter( + self, + *, + filter_id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Deletes a filter. - ``_ + ``_ - :arg filter_id: The ID of the filter to delete + :param filter_id: A string that uniquely identifies a filter. """ - client, params = _deprecated_options(self, params) if filter_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'filter_id'.") - - return await client._perform_request( - "DELETE", - _make_path("_ml", "filters", filter_id), - params=params, - headers=headers, - ) - - @query_params("allow_no_forecasts", "timeout") + raise ValueError("Empty value passed for parameter 'filter_id'") + __path = f"/_ml/filters/{_quote(filter_id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() async def delete_forecast( - self, job_id, forecast_id=None, params=None, headers=None - ): + self, + *, + job_id: Any, + forecast_id: Optional[Any] = None, + allow_no_forecasts: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ 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 - delimited list. Leaving blank implies `_all` - :arg allow_no_forecasts: Whether to ignore if `_all` matches no - forecasts - :arg timeout: Controls the time to wait until the forecast(s) - are deleted. Default to 30 seconds + :param job_id: Identifier for the anomaly detection job. + :param forecast_id: A comma-separated list of forecast identifiers. If you do + not specify this optional parameter or if you specify `_all` or `*` the API + deletes all forecasts from the job. + :param allow_no_forecasts: Specifies whether an error occurs when there are no + forecasts. In particular, if this parameter is set to `false` and there are + no forecasts associated with the job, attempts to delete all forecasts return + an error. + :param timeout: Specifies the period of time to wait for the completion of the + delete operation. When this period of time elapses, the API fails and returns + an error. """ - client, params = _deprecated_options(self, params) if job_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'job_id'.") - - return await client._perform_request( - "DELETE", - _make_path("_ml", "anomaly_detectors", job_id, "_forecast", forecast_id), - params=params, - headers=headers, - ) - - @query_params("force", "wait_for_completion") - async def delete_job(self, job_id, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'job_id'") + if job_id not in SKIP_IN_PATH and forecast_id not in SKIP_IN_PATH: + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}/_forecast/{_quote(forecast_id)}" + elif job_id not in SKIP_IN_PATH: + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}/_forecast" + else: + raise ValueError("Couldn't find a path for the given parameters") + __query: Dict[str, Any] = {} + if allow_no_forecasts is not None: + __query["allow_no_forecasts"] = allow_no_forecasts + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + async def delete_job( + self, + *, + job_id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + force: Optional[bool] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + wait_for_completion: Optional[bool] = None, + ) -> Any: """ 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 - :arg wait_for_completion: Should this request wait until the - operation has completed before returning Default: True + :param job_id: Identifier for the anomaly detection job. + :param force: Use to forcefully delete an opened job; this method is quicker + than closing and deleting the job. + :param wait_for_completion: Specifies whether the request should return immediately + or wait until the job deletion completes. """ - client, params = _deprecated_options(self, params) if job_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'job_id'.") - - return await client._perform_request( - "DELETE", - _make_path("_ml", "anomaly_detectors", job_id), - params=params, - headers=headers, - ) - - @query_params() + raise ValueError("Empty value passed for parameter 'job_id'") + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if force is not None: + __query["force"] = force + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if wait_for_completion is not None: + __query["wait_for_completion"] = wait_for_completion + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() async def delete_model_snapshot( - self, job_id, snapshot_id, params=None, headers=None - ): + self, + *, + job_id: Any, + snapshot_id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ 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 + :param job_id: Identifier for the anomaly detection job. + :param snapshot_id: Identifier for the model snapshot. + """ + if job_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'job_id'") + if snapshot_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'snapshot_id'") + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}/model_snapshots/{_quote(snapshot_id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + async def delete_trained_model( + self, + *, + model_id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: + """ + Deletes an existing trained inference model that is currently not referenced + by an ingest pipeline. + + ``_ + + :param model_id: The unique identifier of the trained model. + """ + if model_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'model_id'") + __path = f"/_ml/trained_models/{_quote(model_id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + async def delete_trained_model_alias( + self, + *, + model_id: Any, + model_alias: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - client, params = _deprecated_options(self, params) - for param in (job_id, snapshot_id): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") + Deletes a model alias that refers to the trained model - return await client._perform_request( - "DELETE", - _make_path( - "_ml", "anomaly_detectors", job_id, "model_snapshots", snapshot_id - ), - params=params, - headers=headers, - ) + ``_ - @query_params("advance_time", "calc_interim", "end", "skip_time", "start") - async def flush_job(self, job_id, body=None, params=None, headers=None): + :param model_id: The trained model ID to which the model alias refers. + :param model_alias: The model alias to delete. """ - Forces any buffered data to be processed by the job. + if model_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'model_id'") + if model_alias in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'model_alias'") + __path = f"/_ml/trained_models/{_quote(model_id)}/model_aliases/{_quote(model_alias)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + async def estimate_model_memory( + self, + *, + analysis_config: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + max_bucket_cardinality: Optional[Dict[Any, int]] = None, + overall_cardinality: Optional[Dict[Any, int]] = None, + pretty: Optional[bool] = None, + ) -> Any: + """ + Estimates the model memory - ``_ - - :arg job_id: The name of the job to flush - :arg body: Flush parameters - :arg advance_time: Advances time to the given value generating - results and updating the model for the advanced interval - :arg calc_interim: Calculates interim results for the most - recent bucket or all buckets within the latency period - :arg end: When used in conjunction with calc_interim, specifies - the range of buckets on which to calculate interim results - :arg skip_time: Skips time to the given value without generating - results or updating the model for the skipped interval - :arg start: When used in conjunction with calc_interim, - specifies the range of buckets on which to calculate interim results - """ - client, params = _deprecated_options(self, params) - if job_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'job_id'.") - - return await client._perform_request( - "POST", - _make_path("_ml", "anomaly_detectors", job_id, "_flush"), - params=params, - headers=headers, - body=body, - ) + ``_ + + :param analysis_config: For a list of the properties that you can specify in + the `analysis_config` component of the body of this API. + :param max_bucket_cardinality: Estimates of the highest cardinality in a single + bucket that is observed for influencer fields over the time period that the + job analyzes data. To produce a good answer, values must be provided for + all influencer fields. Providing values for fields that are not listed as + `influencers` has no effect on the estimation. + :param overall_cardinality: Estimates of the cardinality that is observed for + fields over the whole time period that the job analyzes data. To produce + a good answer, values must be provided for fields referenced in the `by_field_name`, + `over_field_name` and `partition_field_name` of any detectors. Providing + values for other fields has no effect on the estimation. It can be omitted + from the request if no detectors have a `by_field_name`, `over_field_name` + or `partition_field_name`. + """ + __path = "/_ml/anomaly_detectors/_estimate_model_memory" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if analysis_config is not None: + __body["analysis_config"] = analysis_config + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if max_bucket_cardinality is not None: + __body["max_bucket_cardinality"] = max_bucket_cardinality + if overall_cardinality is not None: + __body["overall_cardinality"] = overall_cardinality + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "POST", __target, headers=__headers, body=__body + ) + + @_rewrite_parameters( + body_fields=True, + ) + async def evaluate_data_frame( + self, + *, + evaluation: Any, + index: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + query: Optional[Any] = None, + ) -> Any: + """ + Evaluates the data frame analytics for an annotated index. - @query_params("duration", "expires_in", "max_model_memory") - async def forecast(self, job_id, params=None, headers=None): + ``_ + + :param evaluation: Defines the type of evaluation you want to perform. + :param index: Defines the index in which the evaluation will be performed. + :param query: A query clause that retrieves a subset of data from the source + index. + """ + if evaluation is None: + raise ValueError("Empty value passed for parameter 'evaluation'") + if index is None: + raise ValueError("Empty value passed for parameter 'index'") + __path = "/_ml/data_frame/_evaluate" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if evaluation is not None: + __body["evaluation"] = evaluation + if index is not None: + __body["index"] = index + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if query is not None: + __body["query"] = query + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "POST", __target, headers=__headers, body=__body + ) + + @_rewrite_parameters( + body_fields=True, + ) + async def explain_data_frame_analytics( + self, + *, + analysis: Any, + id: Optional[Any] = None, + allow_lazy_start: Optional[bool] = None, + analyzed_fields: Optional[Any] = None, + description: Optional[str] = None, + dest: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + max_num_threads: Optional[int] = None, + model_memory_limit: Optional[str] = None, + pretty: Optional[bool] = None, + source: Optional[Any] = None, + ) -> Any: """ - Predicts the future behavior of a time series by using its historical behavior. + Explains a data frame analytics config. + + ``_ + + :param analysis: The analysis configuration, which contains the information necessary + to perform one of the following types of analysis: classification, outlier + detection, or regression. + :param id: Identifier for the data frame analytics job. This identifier can contain + lowercase alphanumeric characters (a-z and 0-9), hyphens, and underscores. + It must start and end with alphanumeric characters. + :param allow_lazy_start: Specifies whether this job can start when there is insufficient + machine learning node capacity for it to be immediately assigned to a node. + :param analyzed_fields: Specify includes and/or excludes patterns to select which + fields will be included in the analysis. The patterns specified in excludes + are applied last, therefore excludes takes precedence. In other words, if + the same field is specified in both includes and excludes, then the field + will not be included in the analysis. + :param description: A description of the job. + :param dest: The destination configuration, consisting of index and optionally + results_field (ml by default). + :param max_num_threads: The maximum number of threads to be used by the analysis. + The default value is 1. Using more threads may decrease the time necessary + to complete the analysis at the cost of using more CPU. Note that the process + may use additional threads for operational functionality other than the analysis + itself. + :param model_memory_limit: The approximate maximum amount of memory resources + that are permitted for analytical processing. The default value for data + frame analytics jobs is 1gb. If your elasticsearch.yml file contains an xpack.ml.max_model_memory_limit + setting, an error occurs when you try to create data frame analytics jobs + that have model_memory_limit values greater than that setting. + :param source: The configuration of how to source the analysis data. It requires + an index. Optionally, query and _source may be specified. + """ + if analysis is None: + raise ValueError("Empty value passed for parameter 'analysis'") + if id not in SKIP_IN_PATH: + __path = f"/_ml/data_frame/analytics/{_quote(id)}/_explain" + else: + __path = "/_ml/data_frame/analytics/_explain" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if analysis is not None: + __body["analysis"] = analysis + if allow_lazy_start is not None: + __body["allow_lazy_start"] = allow_lazy_start + if analyzed_fields is not None: + __body["analyzed_fields"] = analyzed_fields + if description is not None: + __body["description"] = description + if dest is not None: + __body["dest"] = dest + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if max_num_threads is not None: + __body["max_num_threads"] = max_num_threads + if model_memory_limit is not None: + __body["model_memory_limit"] = model_memory_limit + if pretty is not None: + __query["pretty"] = pretty + if source is not None: + __body["source"] = source + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "POST", __target, headers=__headers, body=__body + ) + + @_rewrite_parameters( + body_fields=True, + ) + async def flush_job( + self, + *, + job_id: Any, + advance_time: Optional[Any] = None, + calc_interim: Optional[bool] = None, + end: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + skip_time: Optional[str] = None, + start: Optional[Any] = None, + ) -> Any: + """ + Forces any buffered data to be processed by the job. - ``_ + ``_ - :arg job_id: The ID of the job to forecast for - :arg duration: The duration of the forecast - :arg expires_in: The time interval after which the forecast - expires. Expired forecasts will be deleted at the first opportunity. - :arg max_model_memory: The max memory able to be used by the - forecast. Default is 20mb. + :param job_id: Identifier for the anomaly detection job. + :param advance_time: Refer to the description for the `advance_time` query parameter. + :param calc_interim: Refer to the description for the `calc_interim` query parameter. + :param end: Refer to the description for the `end` query parameter. + :param skip_time: Refer to the description for the `skip_time` query parameter. + :param start: Refer to the description for the `start` query parameter. """ - client, params = _deprecated_options(self, params) if job_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'job_id'.") + raise ValueError("Empty value passed for parameter 'job_id'") + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}/_flush" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if advance_time is not None: + __body["advance_time"] = advance_time + if calc_interim is not None: + __body["calc_interim"] = calc_interim + if end is not None: + __body["end"] = end + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if skip_time is not None: + __body["skip_time"] = skip_time + if start is not None: + __body["start"] = start + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "POST", __target, headers=__headers, body=__body + ) + + @_rewrite_parameters( + body_fields=True, + ) + async def forecast( + self, + *, + job_id: Any, + duration: Optional[Any] = None, + error_trace: Optional[bool] = None, + expires_in: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + max_model_memory: Optional[str] = None, + pretty: Optional[bool] = None, + ) -> Any: + """ + Predicts the future behavior of a time series by using its historical behavior. - return await client._perform_request( - "POST", - _make_path("_ml", "anomaly_detectors", job_id, "_forecast"), - params=params, - headers=headers, - ) + ``_ - @query_params( - "anomaly_score", - "desc", - "end", - "exclude_interim", - "expand", - "from_", - "size", - "sort", - "start", + :param job_id: Identifier for the anomaly detection job. The job must be open + when you create a forecast; otherwise, an error occurs. + :param duration: Refer to the description for the `duration` query parameter. + :param expires_in: Refer to the description for the `expires_in` query parameter. + :param max_model_memory: Refer to the description for the `max_model_memory` + query parameter. + """ + if job_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'job_id'") + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}/_forecast" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if duration is not None: + __body["duration"] = duration + if error_trace is not None: + __query["error_trace"] = error_trace + if expires_in is not None: + __body["expires_in"] = expires_in + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if max_model_memory is not None: + __body["max_model_memory"] = max_model_memory + if pretty is not None: + __query["pretty"] = pretty + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request( + "POST", __target, headers=__headers, body=__body + ) + + @_rewrite_parameters( + body_fields=True, + parameter_aliases={"from": "from_"}, ) async def get_buckets( - self, job_id, body=None, timestamp=None, params=None, headers=None - ): + self, + *, + job_id: Any, + timestamp: Optional[Any] = None, + anomaly_score: Optional[float] = None, + desc: Optional[bool] = None, + end: Optional[Any] = None, + error_trace: Optional[bool] = None, + exclude_interim: Optional[bool] = None, + expand: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + from_: Optional[int] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + size: Optional[int] = None, + sort: Optional[Any] = None, + start: Optional[Any] = None, + ) -> Any: """ 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 - :arg timestamp: The timestamp of the desired single bucket - result - :arg anomaly_score: Filter for the most anomalous buckets - :arg desc: Set the sort direction - :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 size: specifies a max number of buckets to get - :arg sort: Sort buckets by a particular field - :arg start: Start time filter for buckets - """ - client, params = _deprecated_options(self, params) - if params and "from_" in params: - params["from"] = params.pop("from_") - + ``_ + + :param job_id: Identifier for the anomaly detection job. + :param timestamp: The timestamp of a single bucket result. If you do not specify + this parameter, the API returns information about all buckets. + :param anomaly_score: Returns buckets with anomaly scores greater or equal than + this value. + :param desc: If `true`, the buckets are sorted in descending order. + :param end: Returns buckets with timestamps earlier than this time. `-1` means + it is unset and results are not limited to specific timestamps. + :param exclude_interim: If `true`, the output excludes interim results. + :param expand: If true, the output includes anomaly records. + :param from_: Skips the specified number of buckets. + :param size: Specifies the maximum number of buckets to obtain. + :param sort: Specifies the sort field for the requested buckets. + :param start: Returns buckets with timestamps after this time. `-1` means it + is unset and results are not limited to specific timestamps. + """ if job_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'job_id'.") - - return await client._perform_request( - "POST", - _make_path( - "_ml", "anomaly_detectors", job_id, "results", "buckets", timestamp - ), - params=params, - headers=headers, - body=body, - ) - - @query_params("end", "from_", "job_id", "size", "start") - async def get_calendar_events(self, calendar_id, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'job_id'") + if job_id not in SKIP_IN_PATH and timestamp not in SKIP_IN_PATH: + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}/results/buckets/{_quote(timestamp)}" + elif job_id not in SKIP_IN_PATH: + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}/results/buckets" + else: + raise ValueError("Couldn't find a path for the given parameters") + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if anomaly_score is not None: + __body["anomaly_score"] = anomaly_score + if desc is not None: + __body["desc"] = desc + if end is not None: + __body["end"] = end + if error_trace is not None: + __query["error_trace"] = error_trace + if exclude_interim is not None: + __body["exclude_interim"] = exclude_interim + if expand is not None: + __body["expand"] = expand + if filter_path is not None: + __query["filter_path"] = filter_path + if from_ is not None: + __query["from"] = from_ + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if size is not None: + __query["size"] = size + if sort is not None: + __body["sort"] = sort + if start is not None: + __body["start"] = start + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "POST", __target, headers=__headers, body=__body + ) + + @_rewrite_parameters( + parameter_aliases={"from": "from_"}, + ) + async def get_calendar_events( + self, + *, + calendar_id: Any, + end: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + from_: Optional[int] = None, + human: Optional[bool] = None, + job_id: Optional[Any] = None, + pretty: Optional[bool] = None, + size: Optional[int] = None, + start: Optional[str] = None, + ) -> Any: """ 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 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 - :arg start: Get events after this time + :param calendar_id: A string that uniquely identifies a calendar. You can get + information for multiple calendars by using a comma-separated list of ids + or a wildcard expression. You can get information for all calendars by using + `_all` or `*` or by omitting the calendar identifier. + :param end: Specifies to get events with timestamps earlier than this time. + :param from_: Skips the specified number of events. + :param job_id: Specifies to get events for a specific anomaly detection job identifier + or job group. It must be used with a calendar identifier of `_all` or `*`. + :param size: Specifies the maximum number of events to obtain. + :param start: Specifies to get events with timestamps after this time. """ - client, params = _deprecated_options(self, params) - if params and "from_" in params: - params["from"] = params.pop("from_") - if calendar_id in SKIP_IN_PATH: - raise ValueError( - "Empty value passed for a required argument 'calendar_id'." - ) - - return await client._perform_request( - "GET", - _make_path("_ml", "calendars", calendar_id, "events"), - params=params, - headers=headers, - ) - - @query_params("from_", "size") + raise ValueError("Empty value passed for parameter 'calendar_id'") + __path = f"/_ml/calendars/{_quote(calendar_id)}/events" + __query: Dict[str, Any] = {} + if end is not None: + __query["end"] = end + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if from_ is not None: + __query["from"] = from_ + if human is not None: + __query["human"] = human + if job_id is not None: + __query["job_id"] = job_id + if pretty is not None: + __query["pretty"] = pretty + if size is not None: + __query["size"] = size + if start is not None: + __query["start"] = start + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + parameter_aliases={"from": "from_"}, + ) async def get_calendars( - self, body=None, calendar_id=None, params=None, headers=None - ): + self, + *, + calendar_id: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + from_: Optional[int] = None, + human: Optional[bool] = None, + page: Optional[Any] = None, + pretty: Optional[bool] = None, + size: Optional[int] = None, + ) -> Any: """ Retrieves configuration information for calendars. - ``_ + ``_ + + :param calendar_id: A string that uniquely identifies a calendar. You can get + information for multiple calendars by using a comma-separated list of ids + or a wildcard expression. You can get information for all calendars by using + `_all` or `*` or by omitting the calendar identifier. + :param from_: Skips the specified number of calendars. This parameter is supported + only when you omit the calendar identifier. + :param page: This object is supported only when you omit the calendar identifier. + :param size: Specifies the maximum number of calendars to obtain. This parameter + is supported only when you omit the calendar identifier. + """ + if calendar_id not in SKIP_IN_PATH: + __path = f"/_ml/calendars/{_quote(calendar_id)}" + else: + __path = "/_ml/calendars" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if from_ is not None: + __query["from"] = from_ + if human is not None: + __query["human"] = human + if page is not None: + __body["page"] = page + if pretty is not None: + __query["pretty"] = pretty + if size is not None: + __query["size"] = size + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "POST", __target, headers=__headers, body=__body + ) + + @_rewrite_parameters( + body_fields=True, + parameter_aliases={"from": "from_"}, + ) + async def get_categories( + self, + *, + job_id: Any, + category_id: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + from_: Optional[int] = None, + human: Optional[bool] = None, + page: Optional[Any] = None, + partition_field_value: Optional[str] = None, + pretty: Optional[bool] = None, + size: Optional[int] = None, + ) -> Any: + """ + Retrieves anomaly detection job results for one or more categories. + + ``_ - :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 size: specifies a max number of calendars to get + :param job_id: Identifier for the anomaly detection job. + :param category_id: Identifier for the category, which is unique in the job. + If you specify neither the category ID nor the partition_field_value, the + API returns information about all categories. If you specify only the partition_field_value, + it returns information about all categories for the specified partition. + :param from_: Skips the specified number of categories. + :param page: + :param partition_field_value: Only return categories for the specified partition. + :param size: Specifies the maximum number of categories to obtain. """ - client, params = _deprecated_options(self, params) - if params and "from_" in params: - params["from"] = params.pop("from_") + if job_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'job_id'") + if job_id not in SKIP_IN_PATH and category_id not in SKIP_IN_PATH: + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}/results/categories/{_quote(category_id)}" + elif job_id not in SKIP_IN_PATH: + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}/results/categories" + else: + raise ValueError("Couldn't find a path for the given parameters") + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if from_ is not None: + __query["from"] = from_ + if human is not None: + __query["human"] = human + if page is not None: + __body["page"] = page + if partition_field_value is not None: + __query["partition_field_value"] = partition_field_value + if pretty is not None: + __query["pretty"] = pretty + if size is not None: + __query["size"] = size + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "POST", __target, headers=__headers, body=__body + ) + + @_rewrite_parameters( + parameter_aliases={"from": "from_"}, + ) + async def get_data_frame_analytics( + self, + *, + id: Optional[Any] = None, + allow_no_match: Optional[bool] = None, + error_trace: Optional[bool] = None, + exclude_generated: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + from_: Optional[int] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + size: Optional[int] = None, + ) -> Any: + """ + Retrieves configuration information for data frame analytics jobs. - return await client._perform_request( - "POST", - _make_path("_ml", "calendars", calendar_id), - params=params, - headers=headers, - body=body, - ) + ``_ + + :param id: Identifier for the data frame analytics job. If you do not specify + this option, the API returns information for the first hundred data frame + analytics jobs. + :param allow_no_match: Specifies what to do when the request: 1. Contains wildcard + expressions and there are no data frame analytics jobs that match. 2. Contains + the `_all` string or no identifiers and there are no matches. 3. Contains + wildcard expressions and there are only partial matches. The default value + returns an empty data_frame_analytics array when there are no matches and + the subset of results when there are partial matches. If this parameter is + `false`, the request returns a 404 status code when there are no matches + or only partial matches. + :param exclude_generated: Indicates if certain fields should be removed from + the configuration on retrieval. This allows the configuration to be in an + acceptable format to be retrieved and then added to another cluster. + :param from_: Skips the specified number of data frame analytics jobs. + :param size: Specifies the maximum number of data frame analytics jobs to obtain. + """ + if id not in SKIP_IN_PATH: + __path = f"/_ml/data_frame/analytics/{_quote(id)}" + else: + __path = "/_ml/data_frame/analytics" + __query: Dict[str, Any] = {} + if allow_no_match is not None: + __query["allow_no_match"] = allow_no_match + if error_trace is not None: + __query["error_trace"] = error_trace + if exclude_generated is not None: + __query["exclude_generated"] = exclude_generated + if filter_path is not None: + __query["filter_path"] = filter_path + if from_ is not None: + __query["from"] = from_ + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if size is not None: + __query["size"] = size + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + parameter_aliases={"from": "from_"}, + ) + async def get_data_frame_analytics_stats( + self, + *, + id: Optional[Any] = None, + allow_no_match: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + from_: Optional[int] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + size: Optional[int] = None, + verbose: Optional[bool] = None, + ) -> Any: + """ + Retrieves usage information for data frame analytics jobs. - @query_params("allow_no_datafeeds", "allow_no_match") - async def get_datafeed_stats(self, datafeed_id=None, params=None, headers=None): + ``_ + + :param id: Identifier for the data frame analytics job. If you do not specify + this option, the API returns information for the first hundred data frame + analytics jobs. + :param allow_no_match: Specifies what to do when the request: 1. Contains wildcard + expressions and there are no data frame analytics jobs that match. 2. Contains + the `_all` string or no identifiers and there are no matches. 3. Contains + wildcard expressions and there are only partial matches. The default value + returns an empty data_frame_analytics array when there are no matches and + the subset of results when there are partial matches. If this parameter is + `false`, the request returns a 404 status code when there are no matches + or only partial matches. + :param from_: Skips the specified number of data frame analytics jobs. + :param size: Specifies the maximum number of data frame analytics jobs to obtain. + :param verbose: Defines whether the stats response should be verbose. + """ + if id not in SKIP_IN_PATH: + __path = f"/_ml/data_frame/analytics/{_quote(id)}/_stats" + else: + __path = "/_ml/data_frame/analytics/_stats" + __query: Dict[str, Any] = {} + if allow_no_match is not None: + __query["allow_no_match"] = allow_no_match + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if from_ is not None: + __query["from"] = from_ + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if size is not None: + __query["size"] = size + if verbose is not None: + __query["verbose"] = verbose + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def get_datafeed_stats( + self, + *, + datafeed_id: Optional[Any] = None, + allow_no_match: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ 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) - :arg allow_no_match: Whether to ignore if a wildcard expression - matches no datafeeds. (This includes `_all` string or when no datafeeds - have been specified) - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", - _make_path("_ml", "datafeeds", datafeed_id, "_stats"), - params=params, - headers=headers, - ) - - @query_params("allow_no_datafeeds", "allow_no_match", "exclude_generated") - async def get_datafeeds(self, datafeed_id=None, params=None, headers=None): + ``_ + + :param datafeed_id: Identifier for the datafeed. It can be a datafeed identifier + or a wildcard expression. If you do not specify one of these options, the + API returns information about all datafeeds. + :param allow_no_match: Specifies what to do when the request: 1. Contains wildcard + expressions and there are no datafeeds that match. 2. Contains the `_all` + string or no identifiers and there are no matches. 3. Contains wildcard expressions + and there are only partial matches. The default value is `true`, which returns + an empty `datafeeds` array when there are no matches and the subset of results + when there are partial matches. If this parameter is `false`, the request + returns a `404` status code when there are no matches or only partial matches. + """ + if datafeed_id not in SKIP_IN_PATH: + __path = f"/_ml/datafeeds/{_quote(datafeed_id)}/_stats" + else: + __path = "/_ml/datafeeds/_stats" + __query: Dict[str, Any] = {} + if allow_no_match is not None: + __query["allow_no_match"] = allow_no_match + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def get_datafeeds( + self, + *, + datafeed_id: Optional[Any] = None, + allow_no_match: Optional[bool] = None, + error_trace: Optional[bool] = None, + exclude_generated: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ 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) - :arg allow_no_match: Whether to ignore if a wildcard expression - matches no datafeeds. (This includes `_all` string or when no datafeeds - have been specified) - :arg exclude_generated: Omits fields that are illegal to set on - datafeed PUT - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", - _make_path("_ml", "datafeeds", datafeed_id), - params=params, - headers=headers, - ) - - @query_params("from_", "size") - async def get_filters(self, filter_id=None, params=None, headers=None): + ``_ + + :param datafeed_id: Identifier for the datafeed. It can be a datafeed identifier + or a wildcard expression. If you do not specify one of these options, the + API returns information about all datafeeds. + :param allow_no_match: Specifies what to do when the request: 1. Contains wildcard + expressions and there are no datafeeds that match. 2. Contains the `_all` + string or no identifiers and there are no matches. 3. Contains wildcard expressions + and there are only partial matches. The default value is `true`, which returns + an empty `datafeeds` array when there are no matches and the subset of results + when there are partial matches. If this parameter is `false`, the request + returns a `404` status code when there are no matches or only partial matches. + :param exclude_generated: Indicates if certain fields should be removed from + the configuration on retrieval. This allows the configuration to be in an + acceptable format to be retrieved and then added to another cluster. + """ + if datafeed_id not in SKIP_IN_PATH: + __path = f"/_ml/datafeeds/{_quote(datafeed_id)}" + else: + __path = "/_ml/datafeeds" + __query: Dict[str, Any] = {} + if allow_no_match is not None: + __query["allow_no_match"] = allow_no_match + if error_trace is not None: + __query["error_trace"] = error_trace + if exclude_generated is not None: + __query["exclude_generated"] = exclude_generated + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + parameter_aliases={"from": "from_"}, + ) + async def get_filters( + self, + *, + filter_id: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + from_: Optional[int] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + size: Optional[int] = None, + ) -> Any: """ Retrieves filters. - ``_ - - :arg filter_id: The ID of the filter to fetch - :arg from\\_: skips a number of filters - :arg size: specifies a max number of filters to get - """ - client, params = _deprecated_options(self, params) - if params and "from_" in params: - params["from"] = params.pop("from_") - - return await client._perform_request( - "GET", - _make_path("_ml", "filters", filter_id), - params=params, - headers=headers, - ) - - @query_params( - "desc", - "end", - "exclude_interim", - "from_", - "influencer_score", - "size", - "sort", - "start", + ``_ + + :param filter_id: A string that uniquely identifies a filter. + :param from_: Skips the specified number of filters. + :param size: Specifies the maximum number of filters to obtain. + """ + if filter_id not in SKIP_IN_PATH: + __path = f"/_ml/filters/{_quote(filter_id)}" + else: + __path = "/_ml/filters" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if from_ is not None: + __query["from"] = from_ + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if size is not None: + __query["size"] = size + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + parameter_aliases={"from": "from_"}, ) - async def get_influencers(self, job_id, body=None, params=None, headers=None): + async def get_influencers( + self, + *, + job_id: Any, + desc: Optional[bool] = None, + end: Optional[Any] = None, + error_trace: Optional[bool] = None, + exclude_interim: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + from_: Optional[int] = None, + human: Optional[bool] = None, + influencer_score: Optional[float] = None, + page: Optional[Any] = None, + pretty: Optional[bool] = None, + size: Optional[int] = None, + sort: Optional[Any] = None, + start: Optional[Any] = None, + ) -> Any: """ Retrieves anomaly detection job results for one or more influencers. - ``_ - - :arg job_id: Identifier for the anomaly detection job - :arg body: Influencer selection criteria - :arg desc: whether the results should be sorted in decending - order - :arg end: end timestamp for the requested influencers - :arg exclude_interim: Exclude interim results - :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 - :arg sort: sort field for the requested influencers - :arg start: start timestamp for the requested influencers - """ - client, params = _deprecated_options(self, params) - if params and "from_" in params: - params["from"] = params.pop("from_") - + ``_ + + :param job_id: Identifier for the anomaly detection job. + :param desc: If true, the results are sorted in descending order. + :param end: Returns influencers with timestamps earlier than this time. The default + value means it is unset and results are not limited to specific timestamps. + :param exclude_interim: If true, the output excludes interim results. By default, + interim results are included. + :param from_: Skips the specified number of influencers. + :param influencer_score: Returns influencers with anomaly scores greater than + or equal to this value. + :param page: + :param size: Specifies the maximum number of influencers to obtain. + :param sort: Specifies the sort field for the requested influencers. By default, + the influencers are sorted by the `influencer_score` value. + :param start: Returns influencers with timestamps after this time. The default + value means it is unset and results are not limited to specific timestamps. + """ if job_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'job_id'.") - - return await client._perform_request( - "POST", - _make_path("_ml", "anomaly_detectors", job_id, "results", "influencers"), - params=params, - headers=headers, - body=body, - ) - - @query_params("allow_no_jobs", "allow_no_match") - async def get_job_stats(self, job_id=None, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'job_id'") + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}/results/influencers" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if desc is not None: + __query["desc"] = desc + if end is not None: + __query["end"] = end + if error_trace is not None: + __query["error_trace"] = error_trace + if exclude_interim is not None: + __query["exclude_interim"] = exclude_interim + if filter_path is not None: + __query["filter_path"] = filter_path + if from_ is not None: + __query["from"] = from_ + if human is not None: + __query["human"] = human + if influencer_score is not None: + __query["influencer_score"] = influencer_score + if page is not None: + __body["page"] = page + if pretty is not None: + __query["pretty"] = pretty + if size is not None: + __query["size"] = size + if sort is not None: + __query["sort"] = sort + if start is not None: + __query["start"] = start + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "POST", __target, headers=__headers, body=__body + ) + + @_rewrite_parameters() + async def get_job_stats( + self, + *, + job_id: Optional[Any] = None, + allow_no_match: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ 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) - :arg allow_no_match: Whether to ignore if a wildcard expression - matches no jobs. (This includes `_all` string or when no jobs have been - specified) - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", - _make_path("_ml", "anomaly_detectors", job_id, "_stats"), - params=params, - headers=headers, - ) - - @query_params("allow_no_jobs", "allow_no_match", "exclude_generated") - async def get_jobs(self, job_id=None, params=None, headers=None): + ``_ + + :param job_id: Identifier for the anomaly detection job. It can be a job identifier, + a group name, a comma-separated list of jobs, or a wildcard expression. If + you do not specify one of these options, the API returns information for + all anomaly detection jobs. + :param allow_no_match: Specifies what to do when the request: 1. Contains wildcard + expressions and there are no jobs that match. 2. Contains the _all string + or no identifiers and there are no matches. 3. Contains wildcard expressions + and there are only partial matches. If `true`, the API returns an empty `jobs` + array when there are no matches and the subset of results when there are + partial matches. If `false`, the API returns a `404` status code when there + are no matches or only partial matches. + """ + if job_id not in SKIP_IN_PATH: + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}/_stats" + else: + __path = "/_ml/anomaly_detectors/_stats" + __query: Dict[str, Any] = {} + if allow_no_match is not None: + __query["allow_no_match"] = allow_no_match + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def get_jobs( + self, + *, + job_id: Optional[Any] = None, + allow_no_match: Optional[bool] = None, + error_trace: Optional[bool] = None, + exclude_generated: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ 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) - :arg allow_no_match: Whether to ignore if a wildcard expression - matches no jobs. (This includes `_all` string or when no jobs have been - specified) - :arg exclude_generated: Omits fields that are illegal to set on - job PUT - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", - _make_path("_ml", "anomaly_detectors", job_id), - params=params, - headers=headers, - ) - - @query_params( - "allow_no_jobs", - "allow_no_match", - "bucket_span", - "end", - "exclude_interim", - "overall_score", - "start", - "top_n", + ``_ + + :param job_id: Identifier for the anomaly detection job. It can be a job identifier, + a group name, or a wildcard expression. If you do not specify one of these + options, the API returns information for all anomaly detection jobs. + :param allow_no_match: Specifies what to do when the request: 1. Contains wildcard + expressions and there are no jobs that match. 2. Contains the _all string + or no identifiers and there are no matches. 3. Contains wildcard expressions + and there are only partial matches. The default value is `true`, which returns + an empty `jobs` array when there are no matches and the subset of results + when there are partial matches. If this parameter is `false`, the request + returns a `404` status code when there are no matches or only partial matches. + :param exclude_generated: Indicates if certain fields should be removed from + the configuration on retrieval. This allows the configuration to be in an + acceptable format to be retrieved and then added to another cluster. + """ + if job_id not in SKIP_IN_PATH: + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}" + else: + __path = "/_ml/anomaly_detectors" + __query: Dict[str, Any] = {} + if allow_no_match is not None: + __query["allow_no_match"] = allow_no_match + if error_trace is not None: + __query["error_trace"] = error_trace + if exclude_generated is not None: + __query["exclude_generated"] = exclude_generated + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + parameter_aliases={"from": "from_"}, ) - async def get_overall_buckets(self, job_id, body=None, params=None, headers=None): + async def get_model_snapshots( + self, + *, + job_id: Any, + snapshot_id: Optional[Any] = None, + desc: Optional[bool] = None, + end: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + from_: Optional[int] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + size: Optional[int] = None, + sort: Optional[Any] = None, + start: Optional[Any] = None, + ) -> Any: + """ + Retrieves information about model snapshots. + + ``_ + + :param job_id: Identifier for the anomaly detection job. + :param snapshot_id: A numerical character string that uniquely identifies the + model snapshot. + :param desc: If true, the results are sorted in descending order. + :param end: Returns snapshots with timestamps earlier than this time. Defaults + to unset, which means results are not limited to specific timestamps. + :param from_: Skips the specified number of snapshots. + :param size: Specifies the maximum number of snapshots to obtain. + :param sort: Specifies the sort field for the requested snapshots. By default, + the snapshots are sorted by their timestamp. + :param start: Returns snapshots with timestamps after this time. Defaults to + unset, which means results are not limited to specific timestamps. + """ + if job_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'job_id'") + if job_id not in SKIP_IN_PATH and snapshot_id not in SKIP_IN_PATH: + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}/model_snapshots/{_quote(snapshot_id)}" + elif job_id not in SKIP_IN_PATH: + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}/model_snapshots" + else: + raise ValueError("Couldn't find a path for the given parameters") + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if desc is not None: + __query["desc"] = desc + if end is not None: + __body["end"] = end + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if from_ is not None: + __query["from"] = from_ + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if size is not None: + __query["size"] = size + if sort is not None: + __query["sort"] = sort + if start is not None: + __body["start"] = start + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "POST", __target, headers=__headers, body=__body + ) + + @_rewrite_parameters() + async def get_overall_buckets( + self, + *, + job_id: Any, + allow_no_match: Optional[bool] = None, + bucket_span: Optional[Any] = None, + end: Optional[Any] = None, + error_trace: Optional[bool] = None, + exclude_interim: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + overall_score: Optional[Union[float, str]] = None, + pretty: Optional[bool] = None, + start: Optional[Any] = None, + top_n: Optional[int] = None, + ) -> Any: """ 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 - :arg body: Overall bucket selection details if not provided in - URI - :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) - :arg allow_no_match: Whether to ignore if a wildcard expression - matches no jobs. (This includes `_all` string or when no jobs have been - specified) - :arg bucket_span: The span of the overall buckets. Defaults to - the longest job bucket_span - :arg end: Returns overall buckets with timestamps earlier than - this time - :arg exclude_interim: If true overall buckets that include - interim buckets will be excluded - :arg overall_score: Returns overall buckets with overall scores - higher than this value - :arg start: Returns overall buckets with timestamps after this - time - :arg top_n: The number of top job bucket scores to be used in - the overall_score calculation - """ - client, params = _deprecated_options(self, params) + ``_ + + :param job_id: Identifier for the anomaly detection job. It can be a job identifier, + a group name, a comma-separated list of jobs or groups, or a wildcard expression. + You can summarize the bucket results for all anomaly detection jobs by using + `_all` or by specifying `*` as the ``. + :param allow_no_match: Specifies what to do when the request: 1. Contains wildcard + expressions and there are no jobs that match. 2. Contains the `_all` string + or no identifiers and there are no matches. 3. Contains wildcard expressions + and there are only partial matches. If `true`, the request returns an empty + `jobs` array when there are no matches and the subset of results when there + are partial matches. If this parameter is `false`, the request returns a + `404` status code when there are no matches or only partial matches. + :param bucket_span: The span of the overall buckets. Must be greater or equal + to the largest bucket span of the specified anomaly detection jobs, which + is the default value. By default, an overall bucket has a span equal to the + largest bucket span of the specified anomaly detection jobs. To override + that behavior, use the optional `bucket_span` parameter. + :param end: Returns overall buckets with timestamps earlier than this time. + :param exclude_interim: If `true`, the output excludes interim results. + :param overall_score: Returns overall buckets with overall scores greater than + or equal to this value. + :param start: Returns overall buckets with timestamps after this time. + :param top_n: The number of top anomaly detection job bucket scores to be used + in the `overall_score` calculation. + """ if job_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'job_id'.") - - return await client._perform_request( - "POST", - _make_path( - "_ml", "anomaly_detectors", job_id, "results", "overall_buckets" - ), - params=params, - headers=headers, - body=body, - ) - - @query_params( - "desc", - "end", - "exclude_interim", - "from_", - "record_score", - "size", - "sort", - "start", + raise ValueError("Empty value passed for parameter 'job_id'") + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}/results/overall_buckets" + __query: Dict[str, Any] = {} + if allow_no_match is not None: + __query["allow_no_match"] = allow_no_match + if bucket_span is not None: + __query["bucket_span"] = bucket_span + if end is not None: + __query["end"] = end + if error_trace is not None: + __query["error_trace"] = error_trace + if exclude_interim is not None: + __query["exclude_interim"] = exclude_interim + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if overall_score is not None: + __query["overall_score"] = overall_score + if pretty is not None: + __query["pretty"] = pretty + if start is not None: + __query["start"] = start + if top_n is not None: + __query["top_n"] = top_n + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + parameter_aliases={"from": "from_"}, ) - async def get_records(self, job_id, body=None, params=None, headers=None): + async def get_records( + self, + *, + job_id: Any, + desc: Optional[bool] = None, + end: Optional[Any] = None, + error_trace: Optional[bool] = None, + exclude_interim: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + from_: Optional[int] = None, + human: Optional[bool] = None, + page: Optional[Any] = None, + pretty: Optional[bool] = None, + record_score: Optional[float] = None, + size: Optional[int] = None, + sort: Optional[Any] = None, + start: Optional[Any] = None, + ) -> Any: """ 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 record_score: Returns records with anomaly scores greater - or equal than this value - :arg size: specifies a max number of records to get - :arg sort: Sort records by a particular field - :arg start: Start time filter for records + ``_ + + :param job_id: Identifier for the anomaly detection job. + :param desc: If true, the results are sorted in descending order. + :param end: Returns records with timestamps earlier than this time. The default + value means results are not limited to specific timestamps. + :param exclude_interim: If true, the output excludes interim results. + :param from_: Skips the specified number of records. + :param page: + :param record_score: Returns records with anomaly scores greater or equal than + this value. + :param size: Specifies the maximum number of records to obtain. + :param sort: Specifies the sort field for the requested records. + :param start: Returns records with timestamps earlier than this time. The default + value means results are not limited to specific timestamps. """ - client, params = _deprecated_options(self, params) - if params and "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 client._perform_request( - "POST", - _make_path("_ml", "anomaly_detectors", job_id, "results", "records"), - params=params, - headers=headers, - body=body, - ) + raise ValueError("Empty value passed for parameter 'job_id'") + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}/results/records" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if desc is not None: + __body["desc"] = desc + if end is not None: + __body["end"] = end + if error_trace is not None: + __query["error_trace"] = error_trace + if exclude_interim is not None: + __body["exclude_interim"] = exclude_interim + if filter_path is not None: + __query["filter_path"] = filter_path + if from_ is not None: + __query["from"] = from_ + if human is not None: + __query["human"] = human + if page is not None: + __body["page"] = page + if pretty is not None: + __query["pretty"] = pretty + if record_score is not None: + __body["record_score"] = record_score + if size is not None: + __query["size"] = size + if sort is not None: + __body["sort"] = sort + if start is not None: + __body["start"] = start + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "POST", __target, headers=__headers, body=__body + ) + + @_rewrite_parameters( + parameter_aliases={"from": "from_"}, + ) + async def get_trained_models( + self, + *, + model_id: Optional[Any] = None, + allow_no_match: Optional[bool] = None, + decompress_definition: Optional[bool] = None, + error_trace: Optional[bool] = None, + exclude_generated: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + from_: Optional[int] = None, + human: Optional[bool] = None, + include: Optional[Any] = None, + pretty: Optional[bool] = None, + size: Optional[int] = None, + tags: Optional[str] = None, + ) -> Any: + """ + Retrieves configuration information for a trained inference model. - @query_params() - async def info(self, params=None, headers=None): + ``_ + + :param model_id: The unique identifier of the trained model. + :param allow_no_match: Specifies what to do when the request: - Contains wildcard + expressions and there are no models that match. - Contains the _all string + or no identifiers and there are no matches. - Contains wildcard expressions + and there are only partial matches. If true, it returns an empty array when + there are no matches and the subset of results when there are partial matches. + :param decompress_definition: Specifies whether the included model definition + should be returned as a JSON map (true) or in a custom compressed format + (false). + :param exclude_generated: Indicates if certain fields should be removed from + the configuration on retrieval. This allows the configuration to be in an + acceptable format to be retrieved and then added to another cluster. + :param from_: Skips the specified number of models. + :param include: A comma delimited string of optional fields to include in the + response body. + :param size: Specifies the maximum number of models to obtain. + :param tags: A comma delimited string of tags. A trained model can have many + tags, or none. When supplied, only trained models that contain all the supplied + tags are returned. + """ + if model_id not in SKIP_IN_PATH: + __path = f"/_ml/trained_models/{_quote(model_id)}" + else: + __path = "/_ml/trained_models" + __query: Dict[str, Any] = {} + if allow_no_match is not None: + __query["allow_no_match"] = allow_no_match + if decompress_definition is not None: + __query["decompress_definition"] = decompress_definition + if error_trace is not None: + __query["error_trace"] = error_trace + if exclude_generated is not None: + __query["exclude_generated"] = exclude_generated + if filter_path is not None: + __query["filter_path"] = filter_path + if from_ is not None: + __query["from"] = from_ + if human is not None: + __query["human"] = human + if include is not None: + __query["include"] = include + if pretty is not None: + __query["pretty"] = pretty + if size is not None: + __query["size"] = size + if tags is not None: + __query["tags"] = tags + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + parameter_aliases={"from": "from_"}, + ) + async def get_trained_models_stats( + self, + *, + model_id: Optional[Any] = None, + allow_no_match: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + from_: Optional[int] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + size: Optional[int] = None, + ) -> Any: """ - Returns defaults and limits used by machine learning. + Retrieves usage information for trained inference models. - ``_ + ``_ + + :param model_id: The unique identifier of the trained model or a model alias. + :param allow_no_match: Specifies what to do when the request: - Contains wildcard + expressions and there are no models that match. - Contains the _all string + or no identifiers and there are no matches. - Contains wildcard expressions + and there are only partial matches. If true, it returns an empty array when + there are no matches and the subset of results when there are partial matches. + :param from_: Skips the specified number of models. + :param size: Specifies the maximum number of models to obtain. + """ + if model_id not in SKIP_IN_PATH: + __path = f"/_ml/trained_models/{_quote(model_id)}/_stats" + else: + __path = "/_ml/trained_models/_stats" + __query: Dict[str, Any] = {} + if allow_no_match is not None: + __query["allow_no_match"] = allow_no_match + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if from_ is not None: + __query["from"] = from_ + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if size is not None: + __query["size"] = size + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def info( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", "/_ml/info", params=params, headers=headers - ) + Returns defaults and limits used by machine learning. - @query_params() - async def open_job(self, job_id, params=None, headers=None): + ``_ + """ + __path = "/_ml/info" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + async def open_job( + self, + *, + job_id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ Opens one or more anomaly detection jobs. - ``_ + ``_ - :arg job_id: The ID of the job to open + :param job_id: Identifier for the anomaly detection job. + :param timeout: Controls the time to wait until a job has opened. """ - client, params = _deprecated_options(self, params) if job_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'job_id'.") - - return await client._perform_request( - "POST", - _make_path("_ml", "anomaly_detectors", job_id, "_open"), - params=params, - headers=headers, - ) - - @query_params() - async def post_calendar_events(self, calendar_id, body, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'job_id'") + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}/_open" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __body["timeout"] = timeout + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request( + "POST", __target, headers=__headers, body=__body + ) + + @_rewrite_parameters( + body_fields=True, + ) + async def post_calendar_events( + self, + *, + calendar_id: Any, + events: List[Any], + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Posts scheduled events in a calendar. - ``_ + ``_ - :arg calendar_id: The ID of the calendar to modify - :arg body: A list of events + :param calendar_id: A string that uniquely identifies a calendar. + :param events: A list of one of more scheduled events. The event’s start and + end times can be specified as integer milliseconds since the epoch or as + a string in ISO 8601 format. """ - client, params = _deprecated_options(self, params) - for param in (calendar_id, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "POST", - _make_path("_ml", "calendars", calendar_id, "events"), - params=params, - headers=headers, - body=body, - ) - - @query_params("reset_end", "reset_start") - async def post_data(self, job_id, body, params=None, headers=None): + if calendar_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'calendar_id'") + if events is None: + raise ValueError("Empty value passed for parameter 'events'") + __path = f"/_ml/calendars/{_quote(calendar_id)}/events" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if events is not None: + __body["events"] = events + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "POST", __target, headers=__headers, body=__body + ) + + @_rewrite_parameters( + body_name="data", + ) + async def post_data( + self, + *, + job_id: Any, + data: List[Any], + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + reset_end: Optional[Any] = None, + reset_start: Optional[Any] = None, + ) -> Any: """ 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 - :arg reset_end: Optional parameter to specify the end of the - bucket resetting range - :arg reset_start: Optional parameter to specify the start of the - bucket resetting range - """ - client, params = _deprecated_options(self, params) - for param in (job_id, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - headers["content-type"] = "application/x-ndjson" - return await client._perform_request( - "POST", - _make_path("_ml", "anomaly_detectors", job_id, "_data"), - params=params, - headers=headers, - body=body, - ) + ``_ - @query_params() - async def preview_datafeed( - self, body=None, datafeed_id=None, params=None, headers=None - ): + :param job_id: Identifier for the anomaly detection job. The job must have a + state of open to receive and process the data. + :param data: + :param reset_end: Specifies the end of the bucket resetting range. + :param reset_start: Specifies the start of the bucket resetting range. """ - Previews a datafeed. - - ``_ + if job_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'job_id'") + if data is None: + raise ValueError("Empty value passed for parameter 'data'") + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}/_data" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if reset_end is not None: + __query["reset_end"] = reset_end + if reset_start is not None: + __query["reset_start"] = reset_start + __body = data + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = { + "accept": "application/json", + "content-type": "application/x-ndjson", + } + return await self._perform_request( + "POST", __target, headers=__headers, body=__body + ) + + @_rewrite_parameters( + body_fields=True, + ) + async def preview_data_frame_analytics( + self, + *, + id: Optional[Any] = None, + config: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: + """ + Previews that will be analyzed given a data frame analytics config. - :arg body: The datafeed config and job config with which to - execute the preview - :arg datafeed_id: The ID of the datafeed to preview + ``_ + + :param id: Identifier for the data frame analytics job. + :param config: A data frame analytics config as described in Create data frame + analytics jobs. Note that id and dest don’t need to be provided in the context + of this API. + """ + if id not in SKIP_IN_PATH: + __path = f"/_ml/data_frame/analytics/{_quote(id)}/_preview" + else: + __path = "/_ml/data_frame/analytics/_preview" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if config is not None: + __body["config"] = config + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "POST", __target, headers=__headers, body=__body + ) + + @_rewrite_parameters( + body_fields=True, + ) + async def preview_datafeed( + self, + *, + datafeed_id: Optional[Any] = None, + datafeed_config: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + job_config: Optional[Any] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "POST", - _make_path("_ml", "datafeeds", datafeed_id, "_preview"), - params=params, - headers=headers, - body=body, - ) + Previews a datafeed. - @query_params() - async def put_calendar(self, calendar_id, body=None, params=None, headers=None): + ``_ + + :param datafeed_id: A numerical character string that uniquely identifies the + datafeed. This identifier can contain lowercase alphanumeric characters (a-z + and 0-9), hyphens, and underscores. It must start and end with alphanumeric + characters. NOTE: If you use this path parameter, you cannot provide datafeed + or anomaly detection job configuration details in the request body. + :param datafeed_config: The datafeed definition to preview. + :param job_config: The configuration details for the anomaly detection job that + is associated with the datafeed. If the `datafeed_config` object does not + include a `job_id` that references an existing anomaly detection job, you + must supply this `job_config` object. If you include both a `job_id` and + a `job_config`, the latter information is used. You cannot specify a `job_config` + object unless you also supply a `datafeed_config` object. + """ + if datafeed_id not in SKIP_IN_PATH: + __path = f"/_ml/datafeeds/{_quote(datafeed_id)}/_preview" + else: + __path = "/_ml/datafeeds/_preview" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if datafeed_config is not None: + __body["datafeed_config"] = datafeed_config + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if job_config is not None: + __body["job_config"] = job_config + if pretty is not None: + __query["pretty"] = pretty + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "POST", __target, headers=__headers, body=__body + ) + + @_rewrite_parameters( + body_fields=True, + ) + async def put_calendar( + self, + *, + calendar_id: Any, + description: Optional[str] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Instantiates a calendar. - ``_ + ``_ - :arg calendar_id: The ID of the calendar to create - :arg body: The calendar details + :param calendar_id: A string that uniquely identifies a calendar. + :param description: A description of the calendar. """ - client, params = _deprecated_options(self, params) if calendar_id in SKIP_IN_PATH: - raise ValueError( - "Empty value passed for a required argument 'calendar_id'." - ) - - return await client._perform_request( - "PUT", - _make_path("_ml", "calendars", calendar_id), - params=params, - headers=headers, - body=body, - ) - - @query_params() - async def put_calendar_job(self, calendar_id, job_id, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'calendar_id'") + __path = f"/_ml/calendars/{_quote(calendar_id)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if description is not None: + __body["description"] = description + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "PUT", __target, headers=__headers, body=__body + ) + + @_rewrite_parameters() + async def put_calendar_job( + self, + *, + calendar_id: Any, + job_id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ 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 + :param calendar_id: A string that uniquely identifies a calendar. + :param job_id: An identifier for the anomaly detection jobs. It can be a job + identifier, a group name, or a comma-separated list of jobs or groups. """ - client, params = _deprecated_options(self, params) - for param in (calendar_id, job_id): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "PUT", - _make_path("_ml", "calendars", calendar_id, "jobs", job_id), - params=params, - headers=headers, - ) + if calendar_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'calendar_id'") + if job_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'job_id'") + __path = f"/_ml/calendars/{_quote(calendar_id)}/jobs/{_quote(job_id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("PUT", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + async def put_data_frame_analytics( + self, + *, + id: Any, + analysis: Any, + dest: Any, + source: Any, + allow_lazy_start: Optional[bool] = None, + analyzed_fields: Optional[Any] = None, + description: Optional[str] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + max_num_threads: Optional[int] = None, + model_memory_limit: Optional[str] = None, + pretty: Optional[bool] = None, + ) -> Any: + """ + Instantiates a data frame analytics job. - @query_params( - "allow_no_indices", "expand_wildcards", "ignore_throttled", "ignore_unavailable" + ``_ + + :param id: Identifier for the data frame analytics job. This identifier can contain + lowercase alphanumeric characters (a-z and 0-9), hyphens, and underscores. + It must start and end with alphanumeric characters. + :param analysis: The analysis configuration, which contains the information necessary + to perform one of the following types of analysis: classification, outlier + detection, or regression. + :param dest: The destination configuration. + :param source: The configuration of how to source the analysis data. + :param allow_lazy_start: Specifies whether this job can start when there is insufficient + machine learning node capacity for it to be immediately assigned to a node. + If set to false and a machine learning node with capacity to run the job + cannot be immediately found, the API returns an error. If set to true, the + API does not return an error; the job waits in the `starting` state until + sufficient machine learning node capacity is available. This behavior is + also affected by the cluster-wide `xpack.ml.max_lazy_ml_nodes` setting. + :param analyzed_fields: Specifies `includes` and/or `excludes` patterns to select + which fields will be included in the analysis. The patterns specified in + `excludes` are applied last, therefore `excludes` takes precedence. In other + words, if the same field is specified in both `includes` and `excludes`, + then the field will not be included in the analysis. If `analyzed_fields` + is not set, only the relevant fields will be included. For example, all the + numeric fields for outlier detection. The supported fields vary for each + type of analysis. Outlier detection requires numeric or `boolean` data to + analyze. The algorithms don’t support missing values therefore fields that + have data types other than numeric or boolean are ignored. Documents where + included fields contain missing values, null values, or an array are also + ignored. Therefore the `dest` index may contain documents that don’t have + an outlier score. Regression supports fields that are numeric, `boolean`, + `text`, `keyword`, and `ip` data types. It is also tolerant of missing values. + Fields that are supported are included in the analysis, other fields are + ignored. Documents where included fields contain an array with two or more + values are also ignored. Documents in the `dest` index that don’t contain + a results field are not included in the regression analysis. Classification + supports fields that are numeric, `boolean`, `text`, `keyword`, and `ip` + data types. It is also tolerant of missing values. Fields that are supported + are included in the analysis, other fields are ignored. Documents where included + fields contain an array with two or more values are also ignored. Documents + in the `dest` index that don’t contain a results field are not included in + the classification analysis. Classification analysis can be improved by mapping + ordinal variable values to a single number. For example, in case of age ranges, + you can model the values as `0-14 = 0`, `15-24 = 1`, `25-34 = 2`, and so + on. + :param description: A description of the job. + :param max_num_threads: The maximum number of threads to be used by the analysis. + Using more threads may decrease the time necessary to complete the analysis + at the cost of using more CPU. Note that the process may use additional threads + for operational functionality other than the analysis itself. + :param model_memory_limit: The approximate maximum amount of memory resources + that are permitted for analytical processing. If your `elasticsearch.yml` + file contains an `xpack.ml.max_model_memory_limit` setting, an error occurs + when you try to create data frame analytics jobs that have `model_memory_limit` + values greater than that setting. + """ + if id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'id'") + if analysis is None: + raise ValueError("Empty value passed for parameter 'analysis'") + if dest is None: + raise ValueError("Empty value passed for parameter 'dest'") + if source is None: + raise ValueError("Empty value passed for parameter 'source'") + __path = f"/_ml/data_frame/analytics/{_quote(id)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if analysis is not None: + __body["analysis"] = analysis + if dest is not None: + __body["dest"] = dest + if source is not None: + __body["source"] = source + if allow_lazy_start is not None: + __body["allow_lazy_start"] = allow_lazy_start + if analyzed_fields is not None: + __body["analyzed_fields"] = analyzed_fields + if description is not None: + __body["description"] = description + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if max_num_threads is not None: + __body["max_num_threads"] = max_num_threads + if model_memory_limit is not None: + __body["model_memory_limit"] = model_memory_limit + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "PUT", __target, headers=__headers, body=__body + ) + + @_rewrite_parameters( + body_fields=True, ) - async def put_datafeed(self, datafeed_id, body, params=None, headers=None): + async def put_datafeed( + self, + *, + datafeed_id: Any, + aggregations: Optional[Dict[str, Any]] = None, + allow_no_indices: Optional[bool] = None, + chunking_config: Optional[Any] = None, + delayed_data_check_config: Optional[Any] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + frequency: Optional[Any] = None, + human: Optional[bool] = None, + ignore_throttled: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + indices: Optional[List[str]] = None, + indices_options: Optional[Any] = None, + job_id: Optional[Any] = None, + max_empty_searches: Optional[int] = None, + pretty: Optional[bool] = None, + query: Optional[Any] = None, + query_delay: Optional[Any] = None, + runtime_mappings: Optional[Any] = None, + script_fields: Optional[Dict[str, Any]] = None, + scroll_size: Optional[int] = None, + ) -> Any: """ Instantiates a datafeed. - ``_ - - :arg datafeed_id: The ID of the datafeed to create - :arg body: The datafeed config - :arg allow_no_indices: Ignore if the source indices expressions - resolves to no concrete indices (default: true) - :arg expand_wildcards: Whether source index expressions should - get expanded to open or closed indices (default: open) Valid choices: - open, closed, hidden, none, all - :arg ignore_throttled: Ignore indices that are marked as - throttled (default: true) - :arg ignore_unavailable: Ignore unavailable indexes (default: - false) - """ - client, params = _deprecated_options(self, params) - for param in (datafeed_id, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "PUT", - _make_path("_ml", "datafeeds", datafeed_id), - params=params, - headers=headers, - body=body, - ) - - @query_params() - async def put_filter(self, filter_id, body, params=None, headers=None): + ``_ + + :param datafeed_id: A numerical character string that uniquely identifies the + datafeed. This identifier can contain lowercase alphanumeric characters (a-z + and 0-9), hyphens, and underscores. It must start and end with alphanumeric + characters. + :param aggregations: If set, the datafeed performs aggregation searches. Support + for aggregations is limited and should be used only with low cardinality + data. + :param allow_no_indices: Ignore if the source indices expressions resolves to + no concrete indices (default: true) + :param chunking_config: Datafeeds might be required to search over long time + periods, for several months or years. This search is split into time chunks + in order to ensure the load on Elasticsearch is managed. Chunking configuration + controls how the size of these time chunks are calculated; it is an advanced + configuration option. + :param delayed_data_check_config: Specifies whether the datafeed checks for missing + data and the size of the window. The datafeed can optionally search over + indices that have already been read in an effort to determine whether any + data has subsequently been added to the index. If missing data is found, + it is a good indication that the `query_delay` is set too low and the data + is being indexed after the datafeed has passed that moment in time. This + check runs only on real-time datafeeds. + :param expand_wildcards: Whether source index expressions should get expanded + to open or closed indices (default: open) + :param frequency: The interval at which scheduled queries are made while the + datafeed runs in real time. The default value is either the bucket span for + short bucket spans, or, for longer bucket spans, a sensible fraction of the + bucket span. When `frequency` is shorter than the bucket span, interim results + for the last (partial) bucket are written then eventually overwritten by + the full bucket results. If the datafeed uses aggregations, this value must + be divisible by the interval of the date histogram aggregation. + :param ignore_throttled: Ignore indices that are marked as throttled (default: + true) + :param ignore_unavailable: Ignore unavailable indexes (default: false) + :param indices: An array of index names. Wildcards are supported. If any of the + indices are in remote clusters, the machine learning nodes must have the + `remote_cluster_client` role. + :param indices_options: Specifies index expansion options that are used during + search + :param job_id: Identifier for the anomaly detection job. + :param max_empty_searches: If a real-time datafeed has never seen any data (including + during any initial training period), it automatically stops and closes the + associated job after this many real-time searches return no documents. In + other words, it stops after `frequency` times `max_empty_searches` of real-time + operation. If not set, a datafeed with no end time that sees no data remains + started until it is explicitly stopped. By default, it is not set. + :param query: The Elasticsearch query domain-specific language (DSL). This value + corresponds to the query object in an Elasticsearch search POST body. All + the options that are supported by Elasticsearch can be used, as this object + is passed verbatim to Elasticsearch. + :param query_delay: The number of seconds behind real time that data is queried. + For example, if data from 10:04 a.m. might not be searchable in Elasticsearch + until 10:06 a.m., set this property to 120 seconds. The default value is + randomly selected between `60s` and `120s`. This randomness improves the + query performance when there are multiple jobs running on the same node. + :param runtime_mappings: Specifies runtime fields for the datafeed search. + :param script_fields: Specifies scripts that evaluate custom expressions and + returns script fields to the datafeed. The detector configuration objects + in a job can contain functions that use these script fields. + :param scroll_size: The size parameter that is used in Elasticsearch searches + when the datafeed does not use aggregations. The maximum value is the value + of `index.max_result_window`, which is 10,000 by default. + """ + if datafeed_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'datafeed_id'") + __path = f"/_ml/datafeeds/{_quote(datafeed_id)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if aggregations is not None: + __body["aggregations"] = aggregations + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if chunking_config is not None: + __body["chunking_config"] = chunking_config + if delayed_data_check_config is not None: + __body["delayed_data_check_config"] = delayed_data_check_config + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if frequency is not None: + __body["frequency"] = frequency + if human is not None: + __query["human"] = human + if ignore_throttled is not None: + __query["ignore_throttled"] = ignore_throttled + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if indices is not None: + __body["indices"] = indices + if indices_options is not None: + __body["indices_options"] = indices_options + if job_id is not None: + __body["job_id"] = job_id + if max_empty_searches is not None: + __body["max_empty_searches"] = max_empty_searches + if pretty is not None: + __query["pretty"] = pretty + if query is not None: + __body["query"] = query + if query_delay is not None: + __body["query_delay"] = query_delay + if runtime_mappings is not None: + __body["runtime_mappings"] = runtime_mappings + if script_fields is not None: + __body["script_fields"] = script_fields + if scroll_size is not None: + __body["scroll_size"] = scroll_size + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "PUT", __target, headers=__headers, body=__body + ) + + @_rewrite_parameters( + body_fields=True, + ) + async def put_filter( + self, + *, + filter_id: Any, + description: Optional[str] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + items: Optional[List[str]] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Instantiates a filter. - ``_ + ``_ - :arg filter_id: The ID of the filter to create - :arg body: The filter details + :param filter_id: A string that uniquely identifies a filter. + :param description: A description of the filter. + :param items: The items of the filter. A wildcard `*` can be used at the beginning + or the end of an item. Up to 10000 items are allowed in each filter. """ - client, params = _deprecated_options(self, params) - for param in (filter_id, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "PUT", - _make_path("_ml", "filters", filter_id), - params=params, - headers=headers, - body=body, - ) - - @query_params( - "allow_no_indices", "expand_wildcards", "ignore_throttled", "ignore_unavailable" + if filter_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'filter_id'") + __path = f"/_ml/filters/{_quote(filter_id)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if description is not None: + __body["description"] = description + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if items is not None: + __body["items"] = items + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "PUT", __target, headers=__headers, body=__body + ) + + @_rewrite_parameters( + body_fields=True, ) - async def put_job(self, job_id, body, params=None, headers=None): + async def put_job( + self, + *, + job_id: Any, + analysis_config: Any, + background_persist_interval: Any, + data_description: Any, + allow_lazy_open: Optional[bool] = None, + analysis_limits: Optional[Any] = None, + custom_settings: Optional[Any] = None, + daily_model_snapshot_retention_after_days: Optional[int] = None, + datafeed_config: Optional[Any] = None, + description: Optional[str] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + groups: Optional[List[str]] = None, + human: Optional[bool] = None, + model_plot_config: Optional[Any] = None, + model_snapshot_retention_days: Optional[int] = None, + pretty: Optional[bool] = None, + renormalization_window_days: Optional[int] = None, + results_index_name: Optional[Any] = None, + results_retention_days: Optional[int] = None, + ) -> Any: """ Instantiates an anomaly detection job. - ``_ - - :arg job_id: The ID of the job to create - :arg body: The job - :arg allow_no_indices: Ignore if the source indices expressions - resolves to no concrete indices (default: true). Only set if - datafeed_config is provided. - :arg expand_wildcards: Whether source index expressions should - get expanded to open or closed indices (default: open). Only set if - datafeed_config is provided. Valid choices: open, closed, hidden, none, - all - :arg ignore_throttled: Ignore indices that are marked as - throttled (default: true). Only set if datafeed_config is provided. - :arg ignore_unavailable: Ignore unavailable indexes (default: - false). Only set if datafeed_config is provided. - """ - client, params = _deprecated_options(self, params) - for param in (job_id, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "PUT", - _make_path("_ml", "anomaly_detectors", job_id), - params=params, - headers=headers, - body=body, - ) - - @query_params("enabled", "timeout") - 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 - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "POST", "/_ml/set_upgrade_mode", params=params, headers=headers - ) - - @query_params("end", "start", "timeout") - 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 - :arg end: The end time when the datafeed should stop. When not - set, the datafeed continues in real time - :arg start: The start time from where the datafeed should begin - :arg timeout: Controls the time to wait until a datafeed has - started. Default to 20 seconds - """ - client, params = _deprecated_options(self, params) - if datafeed_id in SKIP_IN_PATH: - raise ValueError( - "Empty value passed for a required argument 'datafeed_id'." - ) - - return await client._perform_request( - "POST", - _make_path("_ml", "datafeeds", datafeed_id, "_start"), - params=params, - headers=headers, - body=body, - ) - - @query_params("allow_no_datafeeds", "allow_no_match", "force", "timeout") - async def stop_datafeed(self, datafeed_id, body=None, params=None, headers=None): + ``_ + + :param job_id: The identifier for the anomaly detection job. This identifier + can contain lowercase alphanumeric characters (a-z and 0-9), hyphens, and + underscores. It must start and end with alphanumeric characters. + :param analysis_config: Specifies how to analyze the data. After you create a + job, you cannot change the analysis configuration; all the properties are + informational. + :param background_persist_interval: Advanced configuration option. The time between + each periodic persistence of the model. The default value is a randomized + value between 3 to 4 hours, which avoids all jobs persisting at exactly the + same time. The smallest allowed value is 1 hour. For very large models (several + GB), persistence could take 10-20 minutes, so do not set the `background_persist_interval` + value too low. + :param data_description: Defines the format of the input data when you send data + to the job by using the post data API. Note that when configure a datafeed, + these properties are automatically set. When data is received via the post + data API, it is not stored in Elasticsearch. Only the results for anomaly + detection are retained. + :param allow_lazy_open: Advanced configuration option. Specifies whether this + job can open when there is insufficient machine learning node capacity for + it to be immediately assigned to a node. By default, if a machine learning + node with capacity to run the job cannot immediately be found, the open anomaly + detection jobs API returns an error. However, this is also subject to the + cluster-wide `xpack.ml.max_lazy_ml_nodes` setting. If this option is set + to true, the open anomaly detection jobs API does not return an error and + the job waits in the opening state until sufficient machine learning node + capacity is available. + :param analysis_limits: Limits can be applied for the resources required to hold + the mathematical models in memory. These limits are approximate and can be + set per job. They do not control the memory used by other processes, for + example the Elasticsearch Java processes. + :param custom_settings: Advanced configuration option. Contains custom meta data + about the job. + :param daily_model_snapshot_retention_after_days: Advanced configuration option, + which affects the automatic removal of old model snapshots for this job. + It specifies a period of time (in days) after which only the first snapshot + per day is retained. This period is relative to the timestamp of the most + recent snapshot for this job. Valid values range from 0 to `model_snapshot_retention_days`. + :param datafeed_config: Defines a datafeed for the anomaly detection job. If + Elasticsearch security features are enabled, your datafeed remembers which + roles the user who created it had at the time of creation and runs the query + using those same roles. If you provide secondary authorization headers, those + credentials are used instead. + :param description: A description of the job. + :param groups: A list of job groups. A job can belong to no groups or many. + :param model_plot_config: This advanced configuration option stores model information + along with the results. It provides a more detailed view into anomaly detection. + If you enable model plot it can add considerable overhead to the performance + of the system; it is not feasible for jobs with many entities. Model plot + provides a simplified and indicative view of the model and its bounds. It + does not display complex features such as multivariate correlations or multimodal + data. As such, anomalies may occasionally be reported which cannot be seen + in the model plot. Model plot config can be configured when the job is created + or updated later. It must be disabled if performance issues are experienced. + :param model_snapshot_retention_days: Advanced configuration option, which affects + the automatic removal of old model snapshots for this job. It specifies the + maximum period of time (in days) that snapshots are retained. This period + is relative to the timestamp of the most recent snapshot for this job. By + default, snapshots ten days older than the newest snapshot are deleted. + :param renormalization_window_days: Advanced configuration option. The period + over which adjustments to the score are applied, as new data is seen. The + default value is the longer of 30 days or 100 bucket spans. + :param results_index_name: A text string that affects the name of the machine + learning results index. By default, the job generates an index named `.ml-anomalies-shared`. + :param results_retention_days: Advanced configuration option. The period of time + (in days) that results are retained. Age is calculated relative to the timestamp + of the latest bucket result. If this property has a non-null value, once + per day at 00:30 (server time), results that are the specified number of + days older than the latest bucket result are deleted from Elasticsearch. + The default value is null, which means all results are retained. Annotations + generated by the system also count as results for retention purposes; they + are deleted after the same number of days as results. Annotations added by + users are retained forever. """ - Stops one or more datafeeds. - - ``_ - - :arg datafeed_id: The ID of the datafeed to stop - :arg body: The URL params optionally sent in the body - :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) - :arg allow_no_match: Whether to ignore if a wildcard expression - matches no datafeeds. (This includes `_all` string or when no datafeeds - have been specified) - :arg force: True if the datafeed should be forcefully stopped. - :arg timeout: Controls the time to wait until a datafeed has - stopped. Default to 20 seconds - """ - client, params = _deprecated_options(self, params) - if datafeed_id in SKIP_IN_PATH: + if job_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'job_id'") + if analysis_config is None: + raise ValueError("Empty value passed for parameter 'analysis_config'") + if background_persist_interval is None: raise ValueError( - "Empty value passed for a required argument 'datafeed_id'." + "Empty value passed for parameter 'background_persist_interval'" ) - - return await client._perform_request( - "POST", - _make_path("_ml", "datafeeds", datafeed_id, "_stop"), - params=params, - headers=headers, - body=body, - ) - - @query_params( - "allow_no_indices", "expand_wildcards", "ignore_throttled", "ignore_unavailable" + if data_description is None: + raise ValueError("Empty value passed for parameter 'data_description'") + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if analysis_config is not None: + __body["analysis_config"] = analysis_config + if background_persist_interval is not None: + __body["background_persist_interval"] = background_persist_interval + if data_description is not None: + __body["data_description"] = data_description + if allow_lazy_open is not None: + __body["allow_lazy_open"] = allow_lazy_open + if analysis_limits is not None: + __body["analysis_limits"] = analysis_limits + if custom_settings is not None: + __body["custom_settings"] = custom_settings + if daily_model_snapshot_retention_after_days is not None: + __body[ + "daily_model_snapshot_retention_after_days" + ] = daily_model_snapshot_retention_after_days + if datafeed_config is not None: + __body["datafeed_config"] = datafeed_config + if description is not None: + __body["description"] = description + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if groups is not None: + __body["groups"] = groups + if human is not None: + __query["human"] = human + if model_plot_config is not None: + __body["model_plot_config"] = model_plot_config + if model_snapshot_retention_days is not None: + __body["model_snapshot_retention_days"] = model_snapshot_retention_days + if pretty is not None: + __query["pretty"] = pretty + if renormalization_window_days is not None: + __body["renormalization_window_days"] = renormalization_window_days + if results_index_name is not None: + __body["results_index_name"] = results_index_name + if results_retention_days is not None: + __body["results_retention_days"] = results_retention_days + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "PUT", __target, headers=__headers, body=__body + ) + + @_rewrite_parameters( + body_fields=True, ) - 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 - :arg allow_no_indices: Ignore if the source indices expressions - resolves to no concrete indices (default: true) - :arg expand_wildcards: Whether source index expressions should - get expanded to open or closed indices (default: open) Valid choices: - open, closed, hidden, none, all - :arg ignore_throttled: Ignore indices that are marked as - throttled (default: true) - :arg ignore_unavailable: Ignore unavailable indexes (default: - false) - """ - client, params = _deprecated_options(self, params) - for param in (datafeed_id, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "POST", - _make_path("_ml", "datafeeds", datafeed_id, "_update"), - params=params, - headers=headers, - body=body, - ) - - @query_params() - 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 - """ - client, params = _deprecated_options(self, params) - for param in (filter_id, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "POST", - _make_path("_ml", "filters", filter_id, "_update"), - params=params, - headers=headers, - body=body, - ) - - @query_params() - 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 - """ - client, params = _deprecated_options(self, params) - for param in (job_id, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "POST", - _make_path("_ml", "anomaly_detectors", job_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 - """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return await client._perform_request( - "POST", - "/_ml/anomaly_detectors/_validate", - params=params, - headers=headers, - body=body, - ) - - @query_params() - async def validate_detector(self, body, params=None, headers=None): - """ - Validates an anomaly detection detector. - - ``_ - - :arg body: The detector + async def put_trained_model( + self, + *, + model_id: Any, + inference_config: Any, + input: Any, + compressed_definition: Optional[str] = None, + definition: Optional[Any] = None, + description: Optional[str] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + metadata: Optional[Any] = None, + pretty: Optional[bool] = None, + tags: Optional[List[str]] = None, + ) -> Any: """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return await client._perform_request( - "POST", - "/_ml/anomaly_detectors/_validate/detector", - params=params, - headers=headers, - body=body, - ) - - @query_params("force", "timeout") - async def delete_data_frame_analytics(self, id, params=None, headers=None): - """ - Deletes an existing data frame analytics job. - - ``_ + Creates an inference trained model. - :arg id: The ID of the data frame analytics to delete - :arg force: True if the job should be forcefully deleted - :arg timeout: Controls the time to wait until a job is deleted. - Defaults to 1 minute + ``_ + + :param model_id: The unique identifier of the trained model. + :param inference_config: The default configuration for inference. This can be + either a regression or classification configuration. It must match the underlying + definition.trained_model's target_type. + :param input: The input field names for the model definition. + :param compressed_definition: The compressed (GZipped and Base64 encoded) inference + definition of the model. If compressed_definition is specified, then definition + cannot be specified. + :param definition: The inference definition for the model. If definition is specified, + then compressed_definition cannot be specified. + :param description: A human-readable description of the inference trained model. + :param metadata: An object map that contains metadata about the model. + :param tags: An array of tags to organize the model. """ - client, params = _deprecated_options(self, params) - if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'id'.") - - return await client._perform_request( - "DELETE", - _make_path("_ml", "data_frame", "analytics", id), - params=params, - headers=headers, - ) - - @query_params() - async def evaluate_data_frame(self, body, params=None, headers=None): + if model_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'model_id'") + if inference_config is None: + raise ValueError("Empty value passed for parameter 'inference_config'") + if input is None: + raise ValueError("Empty value passed for parameter 'input'") + __path = f"/_ml/trained_models/{_quote(model_id)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if inference_config is not None: + __body["inference_config"] = inference_config + if input is not None: + __body["input"] = input + if compressed_definition is not None: + __body["compressed_definition"] = compressed_definition + if definition is not None: + __body["definition"] = definition + if description is not None: + __body["description"] = description + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if metadata is not None: + __body["metadata"] = metadata + if pretty is not None: + __query["pretty"] = pretty + if tags is not None: + __body["tags"] = tags + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "PUT", __target, headers=__headers, body=__body + ) + + @_rewrite_parameters() + async def put_trained_model_alias( + self, + *, + model_id: Any, + model_alias: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + reassign: Optional[bool] = None, + ) -> Any: + """ + Creates a new model alias (or reassigns an existing one) to refer to the trained + model + + ``_ + + :param model_id: The identifier for the trained model that the alias refers to. + :param model_alias: The alias to create or update. This value cannot end in numbers. + :param reassign: Specifies whether the alias gets reassigned to the specified + trained model if it is already assigned to a different model. If the alias + is already assigned and this parameter is false, the API returns an error. """ - Evaluates the data frame analytics for an annotated index. - - ``_ - - :arg body: The evaluation definition + if model_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'model_id'") + if model_alias in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'model_alias'") + __path = f"/_ml/trained_models/{_quote(model_id)}/model_aliases/{_quote(model_alias)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if reassign is not None: + __query["reassign"] = reassign + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("PUT", __target, headers=__headers) + + @_rewrite_parameters() + async def reset_job( + self, + *, + job_id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + wait_for_completion: Optional[bool] = None, + ) -> Any: """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") + Resets an existing anomaly detection job. - return await client._perform_request( - "POST", - "/_ml/data_frame/_evaluate", - params=params, - headers=headers, - body=body, - ) + ``_ - @query_params("allow_no_match", "exclude_generated", "from_", "size") - async def get_data_frame_analytics(self, id=None, params=None, headers=None): + :param job_id: The ID of the job to reset. + :param wait_for_completion: Should this request wait until the operation has + completed before returning. """ - 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 exclude_generated: Omits fields that are illegal to set on - data frame analytics PUT - :arg from\\_: skips a number of analytics - :arg size: specifies a max number of analytics to get Default: - 100 - """ - client, params = _deprecated_options(self, params) - if params and "from_" in params: - params["from"] = params.pop("from_") - - return await client._perform_request( - "GET", - _make_path("_ml", "data_frame", "analytics", id), - params=params, - headers=headers, - ) - - @query_params("allow_no_match", "from_", "size", "verbose") - async def get_data_frame_analytics_stats(self, id=None, params=None, headers=None): + if job_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'job_id'") + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}/_reset" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if wait_for_completion is not None: + __query["wait_for_completion"] = wait_for_completion + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + async def revert_model_snapshot( + self, + *, + job_id: Any, + snapshot_id: Any, + delete_intervening_results: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Retrieves usage information for data frame analytics jobs. + Reverts to a specific snapshot. - ``_ - - :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 size: specifies a max number of analytics to get Default: - 100 - :arg verbose: whether the stats response should be verbose - """ - client, params = _deprecated_options(self, params) - if params and "from_" in params: - params["from"] = params.pop("from_") - - return await client._perform_request( - "GET", - _make_path("_ml", "data_frame", "analytics", id, "_stats"), - params=params, - headers=headers, - ) + ``_ - @query_params() - async def put_data_frame_analytics(self, id, body, params=None, headers=None): + :param job_id: Identifier for the anomaly detection job. + :param snapshot_id: You can specify `empty` as the . Reverting to + the empty snapshot means the anomaly detection job starts learning a new + model from scratch when it is started. + :param delete_intervening_results: If true, deletes the results in the time period + between the latest results and the time of the reverted snapshot. It also + resets the model to accept records for this time period. If you choose not + to delete intervening results when reverting a snapshot, the job will not + accept input data that is older than the current time. If you want to resend + data, then delete the intervening results. """ - Instantiates a data frame analytics job. - - ``_ - - :arg id: The ID of the data frame analytics to create - :arg body: The data frame analytics configuration + if job_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'job_id'") + if snapshot_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'snapshot_id'") + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}/model_snapshots/{_quote(snapshot_id)}/_revert" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if delete_intervening_results is not None: + __body["delete_intervening_results"] = delete_intervening_results + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "POST", __target, headers=__headers, body=__body + ) + + @_rewrite_parameters() + async def set_upgrade_mode( + self, + *, + enabled: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ - client, params = _deprecated_options(self, params) - for param in (id, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "PUT", - _make_path("_ml", "data_frame", "analytics", id), - params=params, - headers=headers, - body=body, - ) + Sets a cluster wide upgrade_mode setting that prepares machine learning indices + for an upgrade. - @query_params("timeout") + ``_ + + :param enabled: When `true`, it enables `upgrade_mode` which temporarily halts + all job and datafeed tasks and prohibits new job and datafeed tasks from + starting. + :param timeout: The time to wait for the request to be completed. + """ + __path = "/_ml/set_upgrade_mode" + __query: Dict[str, Any] = {} + if enabled is not None: + __query["enabled"] = enabled + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters() async def start_data_frame_analytics( - self, id, body=None, params=None, headers=None - ): + self, + *, + id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ 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 - :arg timeout: Controls the time to wait until the task has - started. Defaults to 20 seconds + :param id: Identifier for the data frame analytics job. This identifier can contain + lowercase alphanumeric characters (a-z and 0-9), hyphens, and underscores. + It must start and end with alphanumeric characters. + :param timeout: Controls the amount of time to wait until the data frame analytics + job starts. """ - client, params = _deprecated_options(self, params) if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'id'.") - - return await client._perform_request( - "POST", - _make_path("_ml", "data_frame", "analytics", id, "_start"), - params=params, - headers=headers, - body=body, - ) - - @query_params("allow_no_match", "force", "timeout") - async def stop_data_frame_analytics(self, id, body=None, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/_ml/data_frame/analytics/{_quote(id)}/_start" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + async def start_datafeed( + self, + *, + datafeed_id: Any, + end: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + start: Optional[Any] = None, + timeout: Optional[Any] = None, + ) -> Any: """ - Stops one or more data frame analytics jobs. + Starts one or more datafeeds. - ``_ + ``_ - :arg id: The ID of the data frame analytics to stop - :arg body: The stop data frame analytics parameters - :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) - :arg force: True if the data frame analytics should be - forcefully stopped - :arg timeout: Controls the time to wait until the task has - stopped. Defaults to 20 seconds + :param datafeed_id: A numerical character string that uniquely identifies the + datafeed. This identifier can contain lowercase alphanumeric characters (a-z + and 0-9), hyphens, and underscores. It must start and end with alphanumeric + characters. + :param end: Refer to the description for the `end` query parameter. + :param start: Refer to the description for the `start` query parameter. + :param timeout: Refer to the description for the `timeout` query parameter. """ - client, params = _deprecated_options(self, params) - if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'id'.") - - return await client._perform_request( - "POST", - _make_path("_ml", "data_frame", "analytics", id, "_stop"), - params=params, - headers=headers, - body=body, - ) - - @query_params("timeout") - async def delete_trained_model(self, model_id, params=None, headers=None): + if datafeed_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'datafeed_id'") + __path = f"/_ml/datafeeds/{_quote(datafeed_id)}/_start" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if end is not None: + __body["end"] = end + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if start is not None: + __body["start"] = start + if timeout is not None: + __body["timeout"] = timeout + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "POST", __target, headers=__headers, body=__body + ) + + @_rewrite_parameters() + async def stop_data_frame_analytics( + self, + *, + id: Any, + allow_no_match: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + force: Optional[bool] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ - Deletes an existing trained inference model that is currently not referenced by - an ingest pipeline. - - ``_ + Stops one or more data frame analytics jobs. - :arg model_id: The ID of the trained model to delete - :arg timeout: Controls the amount of time to wait for the model - to be deleted. Default: 30s + ``_ + + :param id: Identifier for the data frame analytics job. This identifier can contain + lowercase alphanumeric characters (a-z and 0-9), hyphens, and underscores. + It must start and end with alphanumeric characters. + :param allow_no_match: Specifies what to do when the request: 1. Contains wildcard + expressions and there are no data frame analytics jobs that match. 2. Contains + the _all string or no identifiers and there are no matches. 3. Contains wildcard + expressions and there are only partial matches. The default value is true, + which returns an empty data_frame_analytics array when there are no matches + and the subset of results when there are partial matches. If this parameter + is false, the request returns a 404 status code when there are no matches + or only partial matches. + :param force: If true, the data frame analytics job is stopped forcefully. + :param timeout: Controls the amount of time to wait until the data frame analytics + job stops. Defaults to 20 seconds. """ - client, params = _deprecated_options(self, params) - if model_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'model_id'.") - - return await client._perform_request( - "DELETE", - _make_path("_ml", "trained_models", model_id), - params=params, - headers=headers, - ) - - @query_params( - "allow_no_match", - "decompress_definition", - "exclude_generated", - "from_", - "include", - "include_model_definition", - "size", - "tags", + if id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/_ml/data_frame/analytics/{_quote(id)}/_stop" + __query: Dict[str, Any] = {} + if allow_no_match is not None: + __query["allow_no_match"] = allow_no_match + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if force is not None: + __query["force"] = force + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, ) - 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 - matches no trained models. (This includes `_all` string or when no - trained models have been specified) Default: True - :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 exclude_generated: Omits fields that are illegal to set on - model PUT - :arg from\\_: skips a number of trained models - :arg include: A comma-separate list of fields to optionally - include. Valid options are 'definition' and 'total_feature_importance'. - Default is none. - :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. - :arg size: specifies a max number of trained models to get - Default: 100 - :arg tags: A comma-separated list of tags that the model must - have. - """ - client, params = _deprecated_options(self, params) - if params and "from_" in params: - params["from"] = params.pop("from_") - - return await client._perform_request( - "GET", - _make_path("_ml", "trained_models", model_id), - params=params, - headers=headers, - ) - - @query_params("allow_no_match", "from_", "size") - 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 size: specifies a max number of trained models to get - Default: 100 - """ - client, params = _deprecated_options(self, params) - if params and "from_" in params: - params["from"] = params.pop("from_") - - return await client._perform_request( - "GET", - _make_path("_ml", "trained_models", model_id, "_stats"), - params=params, - headers=headers, - ) - - @query_params("defer_definition_decompression") - 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 - :arg defer_definition_decompression: If set to `true` and a - `compressed_definition` is provided, the request defers definition - decompression and skips relevant validations. - """ - client, params = _deprecated_options(self, params) - for param in (model_id, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "PUT", - _make_path("_ml", "trained_models", model_id), - params=params, - headers=headers, - body=body, - ) - - @query_params() - async def estimate_model_memory(self, body, params=None, headers=None): + async def stop_datafeed( + self, + *, + datafeed_id: Any, + allow_no_match: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + force: Optional[bool] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ - Estimates the model memory + Stops one or more datafeeds. - ``_ + ``_ - :arg body: The analysis config, plus cardinality estimates for - fields it references + :param datafeed_id: Identifier for the datafeed. You can stop multiple datafeeds + in a single API request by using a comma-separated list of datafeeds or a + wildcard expression. You can close all datafeeds by using `_all` or by specifying + `*` as the identifier. + :param allow_no_match: Refer to the description for the `allow_no_match` query + parameter. + :param force: Refer to the description for the `force` query parameter. + :param timeout: Refer to the description for the `timeout` query parameter. """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return await client._perform_request( - "POST", - "/_ml/anomaly_detectors/_estimate_model_memory", - params=params, - headers=headers, - body=body, - ) - - @query_params() - async def explain_data_frame_analytics( - self, body=None, id=None, params=None, headers=None - ): + if datafeed_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'datafeed_id'") + __path = f"/_ml/datafeeds/{_quote(datafeed_id)}/_stop" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if allow_no_match is not None: + __body["allow_no_match"] = allow_no_match + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if force is not None: + __body["force"] = force + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __body["timeout"] = timeout + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "POST", __target, headers=__headers, body=__body + ) + + @_rewrite_parameters( + body_fields=True, + ) + async def update_data_frame_analytics( + self, + *, + id: Any, + allow_lazy_start: Optional[bool] = None, + description: Optional[str] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + max_num_threads: Optional[int] = None, + model_memory_limit: Optional[str] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Explains a data frame analytics config. - - ``_ + Updates certain properties of a data frame analytics job. - :arg body: The data frame analytics config to explain - :arg id: The ID of the data frame analytics to explain + ``_ + + :param id: Identifier for the data frame analytics job. This identifier can contain + lowercase alphanumeric characters (a-z and 0-9), hyphens, and underscores. + It must start and end with alphanumeric characters. + :param allow_lazy_start: Specifies whether this job can start when there is insufficient + machine learning node capacity for it to be immediately assigned to a node. + :param description: A description of the job. + :param max_num_threads: The maximum number of threads to be used by the analysis. + Using more threads may decrease the time necessary to complete the analysis + at the cost of using more CPU. Note that the process may use additional threads + for operational functionality other than the analysis itself. + :param model_memory_limit: The approximate maximum amount of memory resources + that are permitted for analytical processing. The default value for data + frame analytics jobs is 1gb. If your elasticsearch.yml file contains an `xpack.ml.max_model_memory_limit` + setting, an error occurs when you try to create data frame analytics jobs + that have model_memory_limit values greater than that setting. """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "POST", - _make_path("_ml", "data_frame", "analytics", id, "_explain"), - params=params, - headers=headers, - body=body, - ) - - @query_params("from_", "partition_field_value", "size") - async def get_categories( - self, job_id, body=None, category_id=None, params=None, headers=None - ): + if id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/_ml/data_frame/analytics/{_quote(id)}/_update" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if allow_lazy_start is not None: + __body["allow_lazy_start"] = allow_lazy_start + if description is not None: + __body["description"] = description + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if max_num_threads is not None: + __body["max_num_threads"] = max_num_threads + if model_memory_limit is not None: + __body["model_memory_limit"] = model_memory_limit + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "POST", __target, headers=__headers, body=__body + ) + + @_rewrite_parameters( + body_fields=True, + ) + async def update_filter( + self, + *, + filter_id: Any, + add_items: Optional[List[str]] = None, + description: Optional[str] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + remove_items: Optional[List[str]] = None, + ) -> Any: """ - Retrieves anomaly detection job results for one or more categories. + Updates the description of a filter, adds items, or removes items. - ``_ + ``_ - :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 partition_field_value: Specifies the partition to retrieve - categories for. This is optional, and should never be used for jobs - where per-partition categorization is disabled. - :arg size: specifies a max number of categories to get + :param filter_id: A string that uniquely identifies a filter. + :param add_items: The items to add to the filter. + :param description: A description for the filter. + :param remove_items: The items to remove from the filter. """ - client, params = _deprecated_options(self, params) - if params and "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 client._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") - async def get_model_snapshots( - self, job_id, body=None, snapshot_id=None, params=None, headers=None - ): + if filter_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'filter_id'") + __path = f"/_ml/filters/{_quote(filter_id)}/_update" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if add_items is not None: + __body["add_items"] = add_items + if description is not None: + __body["description"] = description + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if remove_items is not None: + __body["remove_items"] = remove_items + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "POST", __target, headers=__headers, body=__body + ) + + @_rewrite_parameters( + body_fields=True, + ) + async def update_job( + self, + *, + job_id: Any, + allow_lazy_open: Optional[bool] = None, + analysis_limits: Optional[Any] = None, + background_persist_interval: Optional[Any] = None, + categorization_filters: Optional[List[str]] = None, + custom_settings: Optional[Dict[str, Any]] = None, + daily_model_snapshot_retention_after_days: Optional[int] = None, + description: Optional[str] = None, + detectors: Optional[List[Any]] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + groups: Optional[List[str]] = None, + human: Optional[bool] = None, + model_plot_config: Optional[Any] = None, + model_snapshot_retention_days: Optional[int] = None, + per_partition_categorization: Optional[Any] = None, + pretty: Optional[bool] = None, + renormalization_window_days: Optional[int] = None, + results_retention_days: Optional[int] = None, + ) -> Any: """ - Retrieves information about model snapshots. - - ``_ + Updates certain properties of an anomaly detection job. - :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 + ``_ + + :param job_id: Identifier for the job. + :param allow_lazy_open: Advanced configuration option. Specifies whether this + job can open when there is insufficient machine learning node capacity for + it to be immediately assigned to a node. If `false` and a machine learning + node with capacity to run the job cannot immediately be found, the open anomaly + detection jobs API returns an error. However, this is also subject to the + cluster-wide `xpack.ml.max_lazy_ml_nodes` setting. If this option is set + to `true`, the open anomaly detection jobs API does not return an error and + the job waits in the opening state until sufficient machine learning node + capacity is available. + :param analysis_limits: + :param background_persist_interval: Advanced configuration option. The time between + each periodic persistence of the model. The default value is a randomized + value between 3 to 4 hours, which avoids all jobs persisting at exactly the + same time. The smallest allowed value is 1 hour. For very large models (several + GB), persistence could take 10-20 minutes, so do not set the value too low. + If the job is open when you make the update, you must stop the datafeed, + close the job, then reopen the job and restart the datafeed for the changes + to take effect. + :param categorization_filters: + :param custom_settings: Advanced configuration option. Contains custom meta data + about the job. For example, it can contain custom URL information as shown + in Adding custom URLs to machine learning results. + :param daily_model_snapshot_retention_after_days: Advanced configuration option, + which affects the automatic removal of old model snapshots for this job. + It specifies a period of time (in days) after which only the first snapshot + per day is retained. This period is relative to the timestamp of the most + recent snapshot for this job. Valid values range from 0 to `model_snapshot_retention_days`. + For jobs created before version 7.8.0, the default value matches `model_snapshot_retention_days`. + :param description: A description of the job. + :param detectors: An array of detector update objects. + :param groups: A list of job groups. A job can belong to no groups or many. + :param model_plot_config: + :param model_snapshot_retention_days: Advanced configuration option, which affects + the automatic removal of old model snapshots for this job. It specifies the + maximum period of time (in days) that snapshots are retained. This period + is relative to the timestamp of the most recent snapshot for this job. + :param per_partition_categorization: Settings related to how categorization interacts + with partition fields. + :param renormalization_window_days: Advanced configuration option. The period + over which adjustments to the score are applied, as new data is seen. + :param results_retention_days: Advanced configuration option. The period of time + (in days) that results are retained. Age is calculated relative to the timestamp + of the latest bucket result. If this property has a non-null value, once + per day at 00:30 (server time), results that are the specified number of + days older than the latest bucket result are deleted from Elasticsearch. + The default value is null, which means all results are retained. """ - client, params = _deprecated_options(self, params) - if params and "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 client._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") - 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? - """ - client, params = _deprecated_options(self, params) - for param in (job_id, snapshot_id): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "POST", - _make_path( - "_ml", - "anomaly_detectors", - job_id, - "model_snapshots", - snapshot_id, - "_revert", - ), - params=params, - headers=headers, - body=body, - ) - - @query_params() + raise ValueError("Empty value passed for parameter 'job_id'") + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}/_update" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if allow_lazy_open is not None: + __body["allow_lazy_open"] = allow_lazy_open + if analysis_limits is not None: + __body["analysis_limits"] = analysis_limits + if background_persist_interval is not None: + __body["background_persist_interval"] = background_persist_interval + if categorization_filters is not None: + __body["categorization_filters"] = categorization_filters + if custom_settings is not None: + __body["custom_settings"] = custom_settings + if daily_model_snapshot_retention_after_days is not None: + __body[ + "daily_model_snapshot_retention_after_days" + ] = daily_model_snapshot_retention_after_days + if description is not None: + __body["description"] = description + if detectors is not None: + __body["detectors"] = detectors + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if groups is not None: + __body["groups"] = groups + if human is not None: + __query["human"] = human + if model_plot_config is not None: + __body["model_plot_config"] = model_plot_config + if model_snapshot_retention_days is not None: + __body["model_snapshot_retention_days"] = model_snapshot_retention_days + if per_partition_categorization is not None: + __body["per_partition_categorization"] = per_partition_categorization + if pretty is not None: + __query["pretty"] = pretty + if renormalization_window_days is not None: + __body["renormalization_window_days"] = renormalization_window_days + if results_retention_days is not None: + __body["results_retention_days"] = results_retention_days + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "POST", __target, headers=__headers, body=__body + ) + + @_rewrite_parameters( + body_fields=True, + ) async def update_model_snapshot( - self, job_id, snapshot_id, body, params=None, headers=None - ): + self, + *, + job_id: Any, + snapshot_id: Any, + description: Optional[str] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + retain: Optional[bool] = None, + ) -> Any: """ 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 - """ - client, params = _deprecated_options(self, params) - 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 client._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 update_data_frame_analytics(self, id, body, params=None, headers=None): + :param job_id: Identifier for the anomaly detection job. + :param snapshot_id: Identifier for the model snapshot. + :param description: A description of the model snapshot. + :param retain: If `true`, this snapshot will not be deleted during automatic + cleanup of snapshots older than `model_snapshot_retention_days`. However, + this snapshot will be deleted when the job is deleted. """ - Updates certain properties of a data frame analytics job. - - ``_ - - :arg id: The ID of the data frame analytics to update - :arg body: The data frame analytics settings to update - """ - client, params = _deprecated_options(self, params) - for param in (id, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "POST", - _make_path("_ml", "data_frame", "analytics", id, "_update"), - params=params, - headers=headers, - body=body, - ) - - @query_params("timeout", "wait_for_completion") + if job_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'job_id'") + if snapshot_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'snapshot_id'") + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}/model_snapshots/{_quote(snapshot_id)}/_update" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if description is not None: + __body["description"] = description + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if retain is not None: + __body["retain"] = retain + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "POST", __target, headers=__headers, body=__body + ) + + @_rewrite_parameters() async def upgrade_job_snapshot( - self, job_id, snapshot_id, params=None, headers=None - ): + self, + *, + job_id: Any, + snapshot_id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + wait_for_completion: Optional[bool] = None, + ) -> Any: """ Upgrades a given job snapshot to the current major version. - ``_ - - :arg job_id: The ID of the job - :arg snapshot_id: The ID of the snapshot - :arg timeout: How long should the API wait for the job to be - opened and the old snapshot to be loaded. - :arg wait_for_completion: Should the request wait until the task - is complete before responding to the caller. Default is false. - """ - client, params = _deprecated_options(self, params) - for param in (job_id, snapshot_id): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "POST", - _make_path( - "_ml", - "anomaly_detectors", - job_id, - "model_snapshots", - snapshot_id, - "_upgrade", - ), - params=params, - headers=headers, - ) - - @query_params() - async def delete_trained_model_alias( - self, model_id, model_alias, params=None, headers=None - ): - """ - Deletes a model alias that refers to the trained model - - ``_ - - :arg model_id: The trained model where the model alias is - assigned - :arg model_alias: The trained model alias to delete - """ - client, params = _deprecated_options(self, params) - for param in (model_id, model_alias): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "DELETE", - _make_path("_ml", "trained_models", model_id, "model_aliases", model_alias), - params=params, - headers=headers, - ) - - @query_params("reassign") - async def put_trained_model_alias( - self, model_id, model_alias, params=None, headers=None - ): - """ - Creates a new model alias (or reassigns an existing one) to refer to the - trained model - - ``_ - - :arg model_id: The trained model where the model alias should be - assigned - :arg model_alias: The trained model alias to update - :arg reassign: If the model_alias already exists and points to a - separate model_id, this parameter must be true. Defaults to false. - """ - client, params = _deprecated_options(self, params) - for param in (model_id, model_alias): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "PUT", - _make_path("_ml", "trained_models", model_id, "model_aliases", model_alias), - params=params, - headers=headers, - ) - - @query_params() - async def preview_data_frame_analytics( - self, body=None, id=None, params=None, headers=None - ): - """ - Previews that will be analyzed given a data frame analytics config. - - ``_ - - :arg body: The data frame analytics config to preview - :arg id: The ID of the data frame analytics to preview - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "POST", - _make_path("_ml", "data_frame", "analytics", id, "_preview"), - params=params, - headers=headers, - body=body, - ) - - @query_params("timeout") - async def infer_trained_model_deployment( - self, model_id, body, params=None, headers=None - ): - """ - Evaluate a trained model. - - ``_ - - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - - :arg model_id: The unique identifier of the trained model. - :arg body: The docs to apply inference on - :arg timeout: Controls the amount of time to wait for inference - results. Default: 10s - """ - client, params = _deprecated_options(self, params) - for param in (model_id, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "POST", - _make_path("_ml", "trained_models", model_id, "deployment", "_infer"), - params=params, - headers=headers, - body=body, - ) - - @query_params("wait_for_completion") - async def reset_job(self, job_id, params=None, headers=None): - """ - Resets an existing anomaly detection job. - - ``_ + ``_ - :arg job_id: The ID of the job to reset - :arg wait_for_completion: Should this request wait until the - operation has completed before returning Default: True + :param job_id: Identifier for the anomaly detection job. + :param snapshot_id: A numerical character string that uniquely identifies the + model snapshot. + :param timeout: Controls the time to wait for the request to complete. + :param wait_for_completion: When true, the API won’t respond until the upgrade + is complete. Otherwise, it responds as soon as the upgrade task is assigned + to a node. """ - client, params = _deprecated_options(self, params) if job_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'job_id'.") - - return await client._perform_request( - "POST", - _make_path("_ml", "anomaly_detectors", job_id, "_reset"), - params=params, - headers=headers, - ) - - @query_params("timeout", "wait_for") - async def start_trained_model_deployment(self, model_id, params=None, headers=None): - """ - Start a trained model deployment. - - ``_ - - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - - :arg model_id: The unique identifier of the trained model. - :arg timeout: Controls the amount of time to wait for the model - to deploy. Default: 20s - :arg wait_for: The allocation status for which to wait Valid - choices: starting, started, fully_allocated Default: started - """ - client, params = _deprecated_options(self, params) - if model_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'model_id'.") - - return await client._perform_request( - "POST", - _make_path("_ml", "trained_models", model_id, "deployment", "_start"), - params=params, - headers=headers, - ) - - @query_params() - async def stop_trained_model_deployment(self, model_id, params=None, headers=None): - """ - Stop a trained model deployment. - - ``_ - - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - - :arg model_id: The unique identifier of the trained model. - """ - client, params = _deprecated_options(self, params) - if model_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'model_id'.") - - return await client._perform_request( - "POST", - _make_path("_ml", "trained_models", model_id, "deployment", "_stop"), - params=params, - headers=headers, - ) - - @query_params() - async def get_trained_model_deployment_stats( - self, model_id, params=None, headers=None - ): - """ - Get information about trained model deployments. - - ``_ - - :arg model_id: The ID of the trained model deployment stats to - fetch - """ - client, params = _deprecated_options(self, params) - if model_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'model_id'.") - - return await client._perform_request( - "GET", - _make_path("_ml", "trained_models", model_id, "deployment", "_stats"), - params=params, - headers=headers, - ) - - @query_params() - async def put_trained_model_definition_part( - self, model_id, part, body, params=None, headers=None - ): - """ - Creates part of a trained model definition - - ``_ - - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - - :arg model_id: The ID of the trained model for this definition - part - :arg part: The part number - :arg body: The trained model definition part + raise ValueError("Empty value passed for parameter 'job_id'") + if snapshot_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'snapshot_id'") + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}/model_snapshots/{_quote(snapshot_id)}/_upgrade" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if wait_for_completion is not None: + __query["wait_for_completion"] = wait_for_completion + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + async def validate( + self, + *, + analysis_config: Optional[Any] = None, + analysis_limits: Optional[Any] = None, + data_description: Optional[Any] = None, + description: Optional[str] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + job_id: Optional[Any] = None, + model_plot: Optional[Any] = None, + model_snapshot_retention_days: Optional[int] = None, + pretty: Optional[bool] = None, + results_index_name: Optional[Any] = None, + ) -> Any: """ - client, params = _deprecated_options(self, params) - for param in (model_id, part, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") + Validates an anomaly detection job. - return await client._perform_request( - "PUT", - _make_path("_ml", "trained_models", model_id, "definition", part), - params=params, - headers=headers, - body=body, - ) + ``_ - @query_params() - async def put_trained_model_vocabulary( - self, model_id, body, params=None, headers=None - ): + :param analysis_config: + :param analysis_limits: + :param data_description: + :param description: + :param job_id: + :param model_plot: + :param model_snapshot_retention_days: + :param results_index_name: + """ + __path = "/_ml/anomaly_detectors/_validate" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if analysis_config is not None: + __body["analysis_config"] = analysis_config + if analysis_limits is not None: + __body["analysis_limits"] = analysis_limits + if data_description is not None: + __body["data_description"] = data_description + if description is not None: + __body["description"] = description + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if job_id is not None: + __body["job_id"] = job_id + if model_plot is not None: + __body["model_plot"] = model_plot + if model_snapshot_retention_days is not None: + __body["model_snapshot_retention_days"] = model_snapshot_retention_days + if pretty is not None: + __query["pretty"] = pretty + if results_index_name is not None: + __body["results_index_name"] = results_index_name + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "POST", __target, headers=__headers, body=__body + ) + + @_rewrite_parameters( + body_name="detector", + ) + async def validate_detector( + self, + *, + detector: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Creates a trained model vocabulary - - ``_ - - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version + Validates an anomaly detection detector. - :arg model_id: The ID of the trained model for this vocabulary - :arg body: The trained model vocabulary - """ - client, params = _deprecated_options(self, params) - for param in (model_id, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") + ``_ - return await client._perform_request( - "PUT", - _make_path("_ml", "trained_models", model_id, "vocabulary"), - params=params, - headers=headers, - body=body, + :param detector: + """ + if detector is None: + raise ValueError("Empty value passed for parameter 'detector'") + __path = "/_ml/anomaly_detectors/_validate/detector" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + __body = detector + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "POST", __target, headers=__headers, body=__body ) diff --git a/elasticsearch/_async/client/ml.pyi b/elasticsearch/_async/client/ml.pyi deleted file mode 100644 index 0d2b1ecfe..000000000 --- a/elasticsearch/_async/client/ml.pyi +++ /dev/null @@ -1,1398 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class MlClient(NamespacedClient): - async def close_job( - self, - job_id: Any, - *, - body: Optional[Any] = ..., - allow_no_jobs: Optional[Any] = ..., - allow_no_match: Optional[Any] = ..., - force: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def delete_calendar( - self, - calendar_id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def delete_calendar_event( - self, - calendar_id: Any, - event_id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def delete_calendar_job( - self, - calendar_id: Any, - job_id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def delete_datafeed( - self, - datafeed_id: Any, - *, - force: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def delete_expired_data( - self, - *, - body: Optional[Any] = ..., - job_id: Optional[Any] = ..., - requests_per_second: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def delete_filter( - self, - filter_id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def delete_forecast( - self, - job_id: Any, - *, - forecast_id: Optional[Any] = ..., - allow_no_forecasts: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def delete_job( - self, - job_id: Any, - *, - force: Optional[Any] = ..., - wait_for_completion: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def delete_model_snapshot( - self, - job_id: Any, - snapshot_id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def flush_job( - self, - job_id: Any, - *, - body: Optional[Any] = ..., - advance_time: Optional[Any] = ..., - calc_interim: Optional[Any] = ..., - end: Optional[Any] = ..., - skip_time: Optional[Any] = ..., - start: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def forecast( - self, - job_id: Any, - *, - duration: Optional[Any] = ..., - expires_in: Optional[Any] = ..., - max_model_memory: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_buckets( - self, - job_id: Any, - *, - body: Optional[Any] = ..., - timestamp: Optional[Any] = ..., - anomaly_score: Optional[Any] = ..., - desc: Optional[Any] = ..., - end: Optional[Any] = ..., - exclude_interim: Optional[Any] = ..., - expand: Optional[Any] = ..., - from_: Optional[Any] = ..., - size: Optional[Any] = ..., - sort: Optional[Any] = ..., - start: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_calendar_events( - self, - calendar_id: Any, - *, - end: Optional[Any] = ..., - from_: Optional[Any] = ..., - job_id: Optional[Any] = ..., - size: Optional[Any] = ..., - start: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_calendars( - self, - *, - body: Optional[Any] = ..., - calendar_id: Optional[Any] = ..., - from_: Optional[Any] = ..., - size: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_datafeed_stats( - self, - *, - datafeed_id: Optional[Any] = ..., - allow_no_datafeeds: Optional[Any] = ..., - allow_no_match: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_datafeeds( - self, - *, - datafeed_id: Optional[Any] = ..., - allow_no_datafeeds: Optional[Any] = ..., - allow_no_match: Optional[Any] = ..., - exclude_generated: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_filters( - self, - *, - filter_id: Optional[Any] = ..., - from_: Optional[Any] = ..., - size: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_influencers( - self, - job_id: Any, - *, - body: Optional[Any] = ..., - desc: Optional[Any] = ..., - end: Optional[Any] = ..., - exclude_interim: Optional[Any] = ..., - from_: Optional[Any] = ..., - influencer_score: Optional[Any] = ..., - size: Optional[Any] = ..., - sort: Optional[Any] = ..., - start: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_job_stats( - self, - *, - job_id: Optional[Any] = ..., - allow_no_jobs: Optional[Any] = ..., - allow_no_match: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_jobs( - self, - *, - job_id: Optional[Any] = ..., - allow_no_jobs: Optional[Any] = ..., - allow_no_match: Optional[Any] = ..., - exclude_generated: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_overall_buckets( - self, - job_id: Any, - *, - body: Optional[Any] = ..., - allow_no_jobs: Optional[Any] = ..., - allow_no_match: Optional[Any] = ..., - bucket_span: Optional[Any] = ..., - end: Optional[Any] = ..., - exclude_interim: Optional[Any] = ..., - overall_score: Optional[Any] = ..., - start: Optional[Any] = ..., - top_n: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_records( - self, - job_id: Any, - *, - body: Optional[Any] = ..., - desc: Optional[Any] = ..., - end: Optional[Any] = ..., - exclude_interim: Optional[Any] = ..., - from_: Optional[Any] = ..., - record_score: Optional[Any] = ..., - size: Optional[Any] = ..., - sort: Optional[Any] = ..., - start: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def info( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def open_job( - self, - job_id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def post_calendar_events( - self, - calendar_id: Any, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def post_data( - self, - job_id: Any, - *, - body: Any, - reset_end: Optional[Any] = ..., - reset_start: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def preview_datafeed( - self, - *, - body: Optional[Any] = ..., - datafeed_id: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def put_calendar( - self, - calendar_id: Any, - *, - body: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def put_calendar_job( - self, - calendar_id: Any, - job_id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def put_datafeed( - self, - datafeed_id: Any, - *, - body: Any, - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - ignore_throttled: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def put_filter( - self, - filter_id: Any, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def put_job( - self, - job_id: Any, - *, - body: Any, - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - ignore_throttled: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def set_upgrade_mode( - self, - *, - enabled: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def start_datafeed( - self, - datafeed_id: Any, - *, - body: Optional[Any] = ..., - end: Optional[Any] = ..., - start: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def stop_datafeed( - self, - datafeed_id: Any, - *, - body: Optional[Any] = ..., - allow_no_datafeeds: Optional[Any] = ..., - allow_no_match: Optional[Any] = ..., - force: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def update_datafeed( - self, - datafeed_id: Any, - *, - body: Any, - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - ignore_throttled: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def update_filter( - self, - filter_id: Any, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def update_job( - self, - job_id: Any, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def validate( - self, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def validate_detector( - self, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def delete_data_frame_analytics( - self, - id: Any, - *, - force: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def evaluate_data_frame( - self, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_data_frame_analytics( - self, - *, - id: Optional[Any] = ..., - allow_no_match: Optional[Any] = ..., - exclude_generated: Optional[Any] = ..., - from_: Optional[Any] = ..., - size: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_data_frame_analytics_stats( - self, - *, - id: Optional[Any] = ..., - allow_no_match: Optional[Any] = ..., - from_: Optional[Any] = ..., - size: Optional[Any] = ..., - verbose: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def put_data_frame_analytics( - self, - id: Any, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def start_data_frame_analytics( - self, - id: Any, - *, - body: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def stop_data_frame_analytics( - self, - id: Any, - *, - body: Optional[Any] = ..., - allow_no_match: Optional[Any] = ..., - force: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def delete_trained_model( - self, - model_id: Any, - *, - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_trained_models( - self, - *, - model_id: Optional[Any] = ..., - allow_no_match: Optional[Any] = ..., - decompress_definition: Optional[Any] = ..., - exclude_generated: Optional[Any] = ..., - from_: Optional[Any] = ..., - include: Optional[Any] = ..., - include_model_definition: Optional[Any] = ..., - size: Optional[Any] = ..., - tags: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_trained_models_stats( - self, - *, - model_id: Optional[Any] = ..., - allow_no_match: Optional[Any] = ..., - from_: Optional[Any] = ..., - size: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def put_trained_model( - self, - model_id: Any, - *, - body: Any, - defer_definition_decompression: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def estimate_model_memory( - self, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def explain_data_frame_analytics( - self, - *, - body: Optional[Any] = ..., - id: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_categories( - self, - job_id: Any, - *, - body: Optional[Any] = ..., - category_id: Optional[Any] = ..., - from_: Optional[Any] = ..., - partition_field_value: Optional[Any] = ..., - size: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_model_snapshots( - self, - job_id: Any, - *, - body: Optional[Any] = ..., - snapshot_id: Optional[Any] = ..., - desc: Optional[Any] = ..., - end: Optional[Any] = ..., - from_: Optional[Any] = ..., - size: Optional[Any] = ..., - sort: Optional[Any] = ..., - start: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def revert_model_snapshot( - self, - job_id: Any, - snapshot_id: Any, - *, - body: Optional[Any] = ..., - delete_intervening_results: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def update_model_snapshot( - self, - job_id: Any, - snapshot_id: Any, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def update_data_frame_analytics( - self, - id: Any, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def upgrade_job_snapshot( - self, - job_id: Any, - snapshot_id: Any, - *, - timeout: Optional[Any] = ..., - wait_for_completion: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def delete_trained_model_alias( - self, - model_id: Any, - model_alias: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def put_trained_model_alias( - self, - model_id: Any, - model_alias: Any, - *, - reassign: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def preview_data_frame_analytics( - self, - *, - body: Optional[Any] = ..., - id: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def infer_trained_model_deployment( - self, - model_id: Any, - *, - body: Any, - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def reset_job( - self, - job_id: Any, - *, - wait_for_completion: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def start_trained_model_deployment( - self, - model_id: Any, - *, - timeout: Optional[Any] = ..., - wait_for: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def stop_trained_model_deployment( - self, - model_id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_trained_model_deployment_stats( - self, - model_id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def put_trained_model_definition_part( - self, - model_id: Any, - part: Any, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def put_trained_model_vocabulary( - self, - model_id: Any, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_async/client/monitoring.py b/elasticsearch/_async/client/monitoring.py index 8900e6945..4ee86af22 100644 --- a/elasticsearch/_async/client/monitoring.py +++ b/elasticsearch/_async/client/monitoring.py @@ -15,36 +15,71 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params +from .utils import _quote_query, _rewrite_parameters class MonitoringClient(NamespacedClient): - @query_params("interval", "system_api_version", "system_id") - async def bulk(self, body, doc_type=None, params=None, headers=None): + @_rewrite_parameters( + body_name="operations", + ) + async def bulk( + self, + *, + interval: Any, + operations: List[Any], + system_api_version: str, + system_id: str, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Used by the monitoring features to send monitoring data. ``_ - :arg body: The operation definition and data (action-data - pairs), separated by newlines - :arg doc_type: Default document type for items which don't - provide one - :arg interval: Collection interval (e.g., '10s' or '10000ms') of - the payload - :arg system_api_version: API Version of the monitored system - :arg system_id: Identifier of the monitored system + :param interval: Collection interval (e.g., '10s' or '10000ms') of the payload + :param operations: + :param system_api_version: + :param system_id: Identifier of the monitored system """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - headers["content-type"] = "application/x-ndjson" - return await client._perform_request( - "POST", - _make_path("_monitoring", doc_type, "bulk"), - params=params, - headers=headers, - body=body, + if interval is None: + raise ValueError("Empty value passed for parameter 'interval'") + if operations is None: + raise ValueError("Empty value passed for parameter 'operations'") + if system_api_version is None: + raise ValueError("Empty value passed for parameter 'system_api_version'") + if system_id is None: + raise ValueError("Empty value passed for parameter 'system_id'") + __path = "/_monitoring/bulk" + __query: Dict[str, Any] = {} + if interval is not None: + __query["interval"] = interval + if system_api_version is not None: + __query["system_api_version"] = system_api_version + if system_id is not None: + __query["system_id"] = system_id + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + __body = operations + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = { + "accept": "application/json", + "content-type": "application/x-ndjson", + } + return await self._perform_request( + "PUT", __target, headers=__headers, body=__body ) diff --git a/elasticsearch/_async/client/monitoring.pyi b/elasticsearch/_async/client/monitoring.pyi deleted file mode 100644 index 85de25ded..000000000 --- a/elasticsearch/_async/client/monitoring.pyi +++ /dev/null @@ -1,45 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class MonitoringClient(NamespacedClient): - async def bulk( - self, - *, - body: Any, - doc_type: Optional[Any] = ..., - interval: Optional[Any] = ..., - system_api_version: Optional[Any] = ..., - system_id: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_async/client/nodes.py b/elasticsearch/_async/client/nodes.py index 7c08241de..9f1828ed8 100644 --- a/elasticsearch/_async/client/nodes.py +++ b/elasticsearch/_async/client/nodes.py @@ -15,242 +15,347 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params +from .utils import SKIP_IN_PATH, _quote, _quote_query, _rewrite_parameters class NodesClient(NamespacedClient): - @query_params("timeout") - async def reload_secure_settings( - self, body=None, node_id=None, params=None, headers=None - ): + @_rewrite_parameters() + async def hot_threads( + self, + *, + node_id: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_idle_threads: Optional[bool] = None, + interval: Optional[Any] = None, + pretty: Optional[bool] = None, + snapshots: Optional[int] = None, + thread_type: Optional[Any] = None, + threads: Optional[int] = None, + timeout: Optional[Any] = None, + ) -> Any: """ - Reloads secure settings. + Returns information about hot threads on each node in the cluster. - ``_ + ``_ - :arg body: An object containing the password for the - elasticsearch keystore - :arg node_id: A comma-separated list of node IDs to span the - reload/reinit call. Should stay empty because reloading usually involves - all cluster nodes. - :arg timeout: Explicit operation timeout + :param 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 + :param ignore_idle_threads: Don't show threads that are in known-idle places, + such as waiting on a socket select or pulling from an empty task queue (default: + true) + :param interval: The interval for the second sampling of threads + :param snapshots: Number of samples of thread stacktrace (default: 10) + :param thread_type: + :param threads: Specify the number of threads to provide information for (default: + 3) + :param timeout: Explicit operation timeout """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "POST", - _make_path("_nodes", node_id, "reload_secure_settings"), - params=params, - headers=headers, - body=body, - ) + if node_id not in SKIP_IN_PATH: + __path = f"/_nodes/{_quote(node_id)}/hot_threads" + else: + __path = "/_nodes/hot_threads" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_idle_threads is not None: + __query["ignore_idle_threads"] = ignore_idle_threads + if interval is not None: + __query["interval"] = interval + if pretty is not None: + __query["pretty"] = pretty + if snapshots is not None: + __query["snapshots"] = snapshots + if thread_type is not None: + __query["thread_type"] = thread_type + if threads is not None: + __query["threads"] = threads + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain"} + return await self._perform_request("GET", __target, headers=__headers) - @query_params("flat_settings", "timeout") - async def info(self, node_id=None, metric=None, params=None, headers=None): + @_rewrite_parameters() + async def info( + self, + *, + node_id: Optional[Any] = None, + metric: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + flat_settings: Optional[bool] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ 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 - the node you're connecting to, leave empty to get information from all - nodes - :arg metric: A comma-separated list of metrics you wish - returned. Use `_all` to retrieve all metrics and `_none` to retrieve the - node identity without any additional metrics. Valid choices: settings, - os, process, jvm, thread_pool, transport, http, plugins, ingest, - indices, aggregations, _all, _none - :arg flat_settings: Return settings in flat format (default: - false) - :arg timeout: Explicit operation timeout + :param node_id: Comma-separated list of node IDs or names used to limit returned + information. + :param metric: Limits the information returned to the specific metrics. Supports + a comma-separated list, such as http,ingest. + :param flat_settings: If true, returns settings in flat format. + :param master_timeout: Period to wait for a connection to the master node. If + no response is received before the timeout expires, the request fails and + returns an error. + :param timeout: Period to wait for a response. If no response is received before + the timeout expires, the request fails and returns an error. """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", _make_path("_nodes", node_id, metric), params=params, headers=headers - ) + if node_id not in SKIP_IN_PATH and metric not in SKIP_IN_PATH: + __path = f"/_nodes/{_quote(node_id)}/{_quote(metric)}" + elif node_id not in SKIP_IN_PATH: + __path = f"/_nodes/{_quote(node_id)}" + elif metric not in SKIP_IN_PATH: + __path = f"/_nodes/{_quote(metric)}" + else: + __path = "/_nodes" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if flat_settings is not None: + __query["flat_settings"] = flat_settings + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) - @query_params( - "doc_type", - "ignore_idle_threads", - "interval", - "snapshots", - "sort", - "threads", - "timeout", + @_rewrite_parameters( + body_fields=True, ) - 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 - the node you're connecting to, leave empty to get information from all - nodes - :arg doc_type: The type to sample (default: cpu) Valid choices: - cpu, wait, block, mem - :arg ignore_idle_threads: Don't show threads that are in known- - idle places, such as waiting on a socket select or pulling from an empty - task queue (default: true) - :arg interval: The interval for the second sampling of threads - :arg snapshots: Number of samples of thread stacktrace (default: - 10) - :arg sort: The sort order for 'cpu' type (default: total) Valid - choices: cpu, total - :arg threads: Specify the number of threads to provide - information for (default: 3) - :arg timeout: Explicit operation timeout - """ - client, params = _deprecated_options(self, params) - if params and "doc_type" in params: - params["type"] = params.pop("doc_type") - - return await client._perform_request( - "GET", - _make_path("_nodes", node_id, "hot_threads"), - params=params, - headers=headers, - ) - - @query_params("timeout") - async def usage(self, node_id=None, metric=None, params=None, headers=None): + async def reload_secure_settings( + self, + *, + node_id: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + secure_settings_password: Optional[Any] = None, + timeout: Optional[Any] = None, + ) -> Any: """ - Returns low-level information about REST actions usage on nodes. + Reloads secure settings. - ``_ + ``_ - :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, rest_actions - :arg timeout: Explicit operation timeout + :param node_id: A comma-separated list of node IDs to span the reload/reinit + call. Should stay empty because reloading usually involves all cluster nodes. + :param secure_settings_password: + :param timeout: Explicit operation timeout """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", - _make_path("_nodes", node_id, "usage", metric), - params=params, - headers=headers, + if node_id not in SKIP_IN_PATH: + __path = f"/_nodes/{_quote(node_id)}/reload_secure_settings" + else: + __path = "/_nodes/reload_secure_settings" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if secure_settings_password is not None: + __body["secure_settings_password"] = secure_settings_password + if timeout is not None: + __query["timeout"] = timeout + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "POST", __target, headers=__headers, body=__body ) - @query_params( - "completion_fields", - "fielddata_fields", - "fields", - "groups", - "include_segment_file_sizes", - "include_unloaded_segments", - "level", - "timeout", - "types", - ) + @_rewrite_parameters() async def stats( - self, node_id=None, metric=None, index_metric=None, params=None, headers=None - ): + self, + *, + node_id: Optional[Any] = None, + metric: Optional[Any] = None, + index_metric: Optional[Any] = None, + completion_fields: Optional[Any] = None, + error_trace: Optional[bool] = None, + fielddata_fields: Optional[Any] = None, + fields: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + groups: Optional[bool] = None, + human: Optional[bool] = None, + include_segment_file_sizes: Optional[bool] = None, + include_unloaded_segments: Optional[bool] = None, + level: Optional[Any] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + types: Optional[List[str]] = None, + ) -> Any: """ 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, indexing_pressure - :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, bulk, shard_stats - :arg completion_fields: A comma-separated list of fields for the - `completion` index metric (supports wildcards) - :arg fielddata_fields: A comma-separated list of fields for the - `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 include_unloaded_segments: If set to true segment stats - will include stats for segments that are not currently loaded into - memory - :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 - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", - _make_path("_nodes", node_id, "stats", metric, index_metric), - params=params, - headers=headers, - ) - - @query_params() - async def clear_repositories_metering_archive( - self, node_id, max_archive_version, params=None, headers=None - ): + :param node_id: Comma-separated list of node IDs or names used to limit returned + information. + :param metric: Limit the information returned to the specified metrics + :param index_metric: Limit the information returned for indices metric to the + specific index metrics. It can be used only if indices (or all) metric is + specified. + :param completion_fields: Comma-separated list or wildcard expressions of fields + to include in fielddata and suggest statistics. + :param fielddata_fields: Comma-separated list or wildcard expressions of fields + to include in fielddata statistics. + :param fields: Comma-separated list or wildcard expressions of fields to include + in the statistics. + :param groups: Comma-separated list of search groups to include in the search + statistics. + :param include_segment_file_sizes: If true, the call reports the aggregated disk + usage of each one of the Lucene index files (only applies if segment stats + are requested). + :param include_unloaded_segments: If set to true segment stats will include stats + for segments that are not currently loaded into memory + :param level: Indicates whether statistics are aggregated at the cluster, index, + or shard level. + :param master_timeout: Period to wait for a connection to the master node. If + no response is received before the timeout expires, the request fails and + returns an error. + :param timeout: Period to wait for a response. If no response is received before + the timeout expires, the request fails and returns an error. + :param types: A comma-separated list of document types for the indexing index + metric. """ - Removes the archived repositories metering information present in the cluster. - - ``_ - - .. warning:: + if ( + node_id not in SKIP_IN_PATH + and metric not in SKIP_IN_PATH + and index_metric not in SKIP_IN_PATH + ): + __path = f"/_nodes/{_quote(node_id)}/stats/{_quote(metric)}/{_quote(index_metric)}" + elif node_id not in SKIP_IN_PATH and metric not in SKIP_IN_PATH: + __path = f"/_nodes/{_quote(node_id)}/stats/{_quote(metric)}" + elif metric not in SKIP_IN_PATH and index_metric not in SKIP_IN_PATH: + __path = f"/_nodes/stats/{_quote(metric)}/{_quote(index_metric)}" + elif node_id not in SKIP_IN_PATH: + __path = f"/_nodes/{_quote(node_id)}/stats" + elif metric not in SKIP_IN_PATH: + __path = f"/_nodes/stats/{_quote(metric)}" + else: + __path = "/_nodes/stats" + __query: Dict[str, Any] = {} + if completion_fields is not None: + __query["completion_fields"] = completion_fields + if error_trace is not None: + __query["error_trace"] = error_trace + if fielddata_fields is not None: + __query["fielddata_fields"] = fielddata_fields + if fields is not None: + __query["fields"] = fields + if filter_path is not None: + __query["filter_path"] = filter_path + if groups is not None: + __query["groups"] = groups + if human is not None: + __query["human"] = human + if include_segment_file_sizes is not None: + __query["include_segment_file_sizes"] = include_segment_file_sizes + if include_unloaded_segments is not None: + __query["include_unloaded_segments"] = include_unloaded_segments + if level is not None: + __query["level"] = level + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if types is not None: + __query["types"] = types + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) - This API is **experimental** so may include breaking changes - or be removed in a future version - - :arg node_id: Comma-separated list of node IDs or names used to - limit returned information. - :arg max_archive_version: Specifies the maximum archive_version - to be cleared from the archive. + @_rewrite_parameters() + async def usage( + self, + *, + node_id: Optional[Any] = None, + metric: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ - client, params = _deprecated_options(self, params) - for param in (node_id, max_archive_version): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "DELETE", - _make_path( - "_nodes", node_id, "_repositories_metering", max_archive_version - ), - params=params, - headers=headers, - ) - - @query_params() - async def get_repositories_metering_info(self, node_id, params=None, headers=None): - """ - Returns cluster repositories metering information. - - ``_ - - .. warning:: + Returns low-level information about REST actions usage on nodes. - This API is **experimental** so may include breaking changes - or be removed in a future version + ``_ - :arg node_id: A comma-separated list of node IDs or names to - limit the returned information. + :param 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 + :param metric: Limit the information returned to the specified metrics + :param timeout: Explicit operation timeout """ - client, params = _deprecated_options(self, params) - if node_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'node_id'.") - - return await client._perform_request( - "GET", - _make_path("_nodes", node_id, "_repositories_metering"), - params=params, - headers=headers, - ) + if node_id not in SKIP_IN_PATH and metric not in SKIP_IN_PATH: + __path = f"/_nodes/{_quote(node_id)}/usage/{_quote(metric)}" + elif node_id not in SKIP_IN_PATH: + __path = f"/_nodes/{_quote(node_id)}/usage" + elif metric not in SKIP_IN_PATH: + __path = f"/_nodes/usage/{_quote(metric)}" + else: + __path = "/_nodes/usage" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) diff --git a/elasticsearch/_async/client/nodes.pyi b/elasticsearch/_async/client/nodes.pyi deleted file mode 100644 index d527c0df3..000000000 --- a/elasticsearch/_async/client/nodes.pyi +++ /dev/null @@ -1,169 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse, TextApiResponse - -from ._base import NamespacedClient - -class NodesClient(NamespacedClient): - async def reload_secure_settings( - self, - *, - body: Optional[Any] = ..., - node_id: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def info( - self, - *, - node_id: Optional[Any] = ..., - metric: Optional[Any] = ..., - flat_settings: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def hot_threads( - self, - *, - node_id: Optional[Any] = ..., - doc_type: Optional[Any] = ..., - ignore_idle_threads: Optional[Any] = ..., - interval: Optional[Any] = ..., - snapshots: Optional[Any] = ..., - sort: Optional[Any] = ..., - threads: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> TextApiResponse: ... - async def usage( - self, - *, - node_id: Optional[Any] = ..., - metric: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def stats( - self, - *, - node_id: Optional[Any] = ..., - metric: Optional[Any] = ..., - index_metric: Optional[Any] = ..., - completion_fields: Optional[Any] = ..., - fielddata_fields: Optional[Any] = ..., - fields: Optional[Any] = ..., - groups: Optional[Any] = ..., - include_segment_file_sizes: Optional[Any] = ..., - include_unloaded_segments: Optional[Any] = ..., - level: Optional[Any] = ..., - timeout: Optional[Any] = ..., - types: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def clear_repositories_metering_archive( - self, - node_id: Any, - max_archive_version: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_repositories_metering_info( - self, - node_id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_async/client/rollup.py b/elasticsearch/_async/client/rollup.py index 679fa67e5..4779a7d18 100644 --- a/elasticsearch/_async/client/rollup.py +++ b/elasticsearch/_async/client/rollup.py @@ -15,242 +15,427 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params +from .utils import SKIP_IN_PATH, _quote, _quote_query, _rewrite_parameters class RollupClient(NamespacedClient): - @query_params() - async def delete_job(self, id, params=None, headers=None): + @_rewrite_parameters() + async def delete_job( + self, + *, + id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Deletes an existing rollup job. ``_ - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - - :arg id: The ID of the job to delete + :param id: The ID of the job to delete """ - client, params = _deprecated_options(self, params) if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'id'.") - - return await client._perform_request( - "DELETE", _make_path("_rollup", "job", id), params=params, headers=headers - ) - - @query_params() - async def get_jobs(self, id=None, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/_rollup/job/{_quote(id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + async def get_jobs( + self, + *, + id: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Retrieves the configuration, stats, and status of rollup jobs. ``_ - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - - :arg id: The ID of the job(s) to fetch. Accepts glob patterns, - or left blank for all jobs + :param id: The ID of the job(s) to fetch. Accepts glob patterns, or left blank + for all jobs """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", _make_path("_rollup", "job", id), params=params, headers=headers - ) - - @query_params() - async def get_rollup_caps(self, id=None, params=None, headers=None): + if id not in SKIP_IN_PATH: + __path = f"/_rollup/job/{_quote(id)}" + else: + __path = "/_rollup/job" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def get_rollup_caps( + self, + *, + id: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Returns the capabilities of any rollup jobs that have been configured for a - specific index or index pattern. + Returns the capabilities of any rollup jobs that have been configured for a specific + index or index pattern. ``_ - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - - :arg id: The ID of the index to check rollup capabilities on, or - left blank for all jobs + :param id: The ID of the index to check rollup capabilities on, or left blank + for all jobs """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", _make_path("_rollup", "data", id), params=params, headers=headers - ) - - @query_params() - async def get_rollup_index_caps(self, index, params=None, headers=None): + if id not in SKIP_IN_PATH: + __path = f"/_rollup/data/{_quote(id)}" + else: + __path = "/_rollup/data" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def get_rollup_index_caps( + self, + *, + index: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Returns the rollup capabilities of all jobs inside of a rollup index (e.g. the index where rollup data is stored). ``_ - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - - :arg index: The rollup index or index pattern to obtain rollup - capabilities from. + :param index: The rollup index or index pattern to obtain rollup capabilities + from. """ - client, params = _deprecated_options(self, params) if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return await client._perform_request( - "GET", _make_path(index, "_rollup", "data"), params=params, headers=headers - ) - - @query_params() - async def put_job(self, id, body, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'index'") + __path = f"/{_quote(index)}/_rollup/data" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + async def put_job( + self, + *, + id: Any, + cron: Optional[str] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + groups: Optional[Any] = None, + human: Optional[bool] = None, + index_pattern: Optional[str] = None, + metrics: Optional[List[Any]] = None, + page_size: Optional[int] = None, + pretty: Optional[bool] = None, + rollup_index: Optional[Any] = None, + ) -> Any: """ Creates a rollup job. ``_ - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version + :param id: The ID of the job to create + :param cron: + :param groups: + :param index_pattern: + :param metrics: + :param page_size: + :param rollup_index: + """ + if id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/_rollup/job/{_quote(id)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if cron is not None: + __body["cron"] = cron + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if groups is not None: + __body["groups"] = groups + if human is not None: + __query["human"] = human + if index_pattern is not None: + __body["index_pattern"] = index_pattern + if metrics is not None: + __body["metrics"] = metrics + if page_size is not None: + __body["page_size"] = page_size + if pretty is not None: + __query["pretty"] = pretty + if rollup_index is not None: + __body["rollup_index"] = rollup_index + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "PUT", __target, headers=__headers, body=__body + ) - :arg id: The ID of the job to create - :arg body: The job configuration + @_rewrite_parameters( + body_name="config", + ) + async def rollup( + self, + *, + index: Any, + rollup_index: Any, + config: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - client, params = _deprecated_options(self, params) - for param in (id, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") + Rollup an index + + ``_ - return await client._perform_request( - "PUT", - _make_path("_rollup", "job", id), - params=params, - headers=headers, - body=body, + :param index: The index to roll up + :param rollup_index: The name of the rollup index to create + :param config: + """ + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + if rollup_index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'rollup_index'") + if config is None: + raise ValueError("Empty value passed for parameter 'config'") + __path = f"/{_quote(index)}/_rollup/{_quote(rollup_index)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + __body = config + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "POST", __target, headers=__headers, body=__body ) - @query_params("rest_total_hits_as_int", "typed_keys") + @_rewrite_parameters( + body_fields=True, + ) async def rollup_search( - self, index, body, doc_type=None, params=None, headers=None - ): + self, + *, + index: Any, + type: Optional[Any] = None, + aggregations: Optional[Dict[str, Any]] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + query: Optional[Any] = None, + rest_total_hits_as_int: Optional[bool] = None, + size: Optional[int] = None, + typed_keys: Optional[bool] = None, + ) -> Any: """ Enables searching rolled-up data using the standard query DSL. ``_ - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - - :arg index: The indices or index-pattern(s) (containing rollup - or regular data) that should be searched - :arg body: The search request body - :arg doc_type: The doc type inside the index - :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 typed_keys: Specify whether aggregation and suggester names - should be prefixed by their respective types in the response + :param index: The indices or index-pattern(s) (containing rollup or regular data) + that should be searched + :param type: The doc type inside the index + :param aggregations: + :param query: + :param rest_total_hits_as_int: Indicates whether hits.total should be rendered + as an integer or an object in the rest search response + :param size: Must be zero if set, as rollups work on pre-aggregated data + :param typed_keys: Specify whether aggregation and suggester names should be + prefixed by their respective types in the response """ - client, params = _deprecated_options(self, params) - for param in (index, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "POST", - _make_path(index, doc_type, "_rollup_search"), - params=params, - headers=headers, - body=body, + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + if index not in SKIP_IN_PATH and type not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/{_quote(type)}/_rollup_search" + elif index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_rollup_search" + else: + raise ValueError("Couldn't find a path for the given parameters") + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if aggregations is not None: + __body["aggregations"] = aggregations + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if query is not None: + __body["query"] = query + if rest_total_hits_as_int is not None: + __query["rest_total_hits_as_int"] = rest_total_hits_as_int + if size is not None: + __body["size"] = size + if typed_keys is not None: + __query["typed_keys"] = typed_keys + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "POST", __target, headers=__headers, body=__body ) - @query_params() - async def start_job(self, id, params=None, headers=None): + @_rewrite_parameters() + async def start_job( + self, + *, + id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Starts an existing, stopped rollup job. ``_ - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - - :arg id: The ID of the job to start + :param id: The ID of the job to start """ - client, params = _deprecated_options(self, params) if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'id'.") - - return await client._perform_request( - "POST", - _make_path("_rollup", "job", id, "_start"), - params=params, - headers=headers, - ) - - @query_params("timeout", "wait_for_completion") - async def stop_job(self, id, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/_rollup/job/{_quote(id)}/_start" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters() + async def stop_job( + self, + *, + id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + wait_for_completion: Optional[bool] = None, + ) -> Any: """ Stops an existing, started rollup job. ``_ - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - - :arg id: The ID of the job to stop - :arg timeout: Block for (at maximum) the specified duration - while waiting for the job to stop. Defaults to 30s. - :arg wait_for_completion: True if the API should block until the - job has fully stopped, false if should be executed async. Defaults to - false. + :param id: The ID of the job to stop + :param timeout: Block for (at maximum) the specified duration while waiting for + the job to stop. Defaults to 30s. + :param wait_for_completion: True if the API should block until the job has fully + stopped, false if should be executed async. Defaults to false. """ - client, params = _deprecated_options(self, params) if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'id'.") - - return await client._perform_request( - "POST", - _make_path("_rollup", "job", id, "_stop"), - params=params, - headers=headers, - ) - - @query_params() - async def rollup(self, index, rollup_index, body, params=None, headers=None): - """ - Rollup an index - - ``_ - - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - - :arg index: The index to roll up - :arg rollup_index: The name of the rollup index to create - :arg body: The rollup configuration - """ - client, params = _deprecated_options(self, params) - for param in (index, rollup_index, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "POST", - _make_path(index, "_rollup", rollup_index), - params=params, - headers=headers, - body=body, - ) + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/_rollup/job/{_quote(id)}/_stop" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if wait_for_completion is not None: + __query["wait_for_completion"] = wait_for_completion + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) diff --git a/elasticsearch/_async/client/rollup.pyi b/elasticsearch/_async/client/rollup.pyi deleted file mode 100644 index 6bedc6059..000000000 --- a/elasticsearch/_async/client/rollup.pyi +++ /dev/null @@ -1,186 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class RollupClient(NamespacedClient): - async def delete_job( - self, - id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_jobs( - self, - *, - id: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_rollup_caps( - self, - *, - id: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_rollup_index_caps( - self, - index: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def put_job( - self, - id: Any, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def rollup_search( - self, - index: Any, - *, - body: Any, - doc_type: Optional[Any] = ..., - rest_total_hits_as_int: Optional[Any] = ..., - typed_keys: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def start_job( - self, - id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def stop_job( - self, - id: Any, - *, - timeout: Optional[Any] = ..., - wait_for_completion: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def rollup( - self, - index: Any, - rollup_index: Any, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_async/client/searchable_snapshots.py b/elasticsearch/_async/client/searchable_snapshots.py index 50400e612..dae8802f3 100644 --- a/elasticsearch/_async/client/searchable_snapshots.py +++ b/elasticsearch/_async/client/searchable_snapshots.py @@ -15,114 +15,181 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params +from .utils import SKIP_IN_PATH, _quote, _quote_query, _rewrite_parameters class SearchableSnapshotsClient(NamespacedClient): - @query_params("allow_no_indices", "expand_wildcards", "ignore_unavailable") - async def clear_cache(self, index=None, params=None, headers=None): + @_rewrite_parameters() + async def clear_cache( + self, + *, + index: Optional[Any] = None, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Clear the cache of searchable snapshots. ``_ - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - - :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, none, all Default: open - :arg ignore_unavailable: Whether specified concrete indices - should be ignored when unavailable (missing or closed) + :param index: A comma-separated list of index names + :param 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) + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "POST", - _make_path(index, "_searchable_snapshots", "cache", "clear"), - params=params, - headers=headers, - ) - - @query_params("master_timeout", "storage", "wait_for_completion") - async def mount(self, repository, snapshot, body, params=None, headers=None): + if index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_searchable_snapshots/cache/clear" + else: + __path = "/_searchable_snapshots/cache/clear" + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + async def mount( + self, + *, + repository: Any, + snapshot: Any, + index: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_index_settings: Optional[List[str]] = None, + index_settings: Optional[Dict[str, Any]] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + renamed_index: Optional[Any] = None, + storage: Optional[str] = None, + wait_for_completion: Optional[bool] = None, + ) -> Any: """ Mount a snapshot as a searchable index. ``_ - :arg repository: The name of the repository containing the - snapshot of the index to mount - :arg snapshot: The name of the snapshot of the index to mount - :arg body: The restore configuration for mounting the snapshot - as searchable - :arg master_timeout: Explicit operation timeout for connection - to master node - :arg storage: Selects the kind of local storage used to - accelerate searches. Experimental, and defaults to `full_copy` - :arg wait_for_completion: Should this request wait until the - operation has completed before returning + :param repository: The name of the repository containing the snapshot of the + index to mount + :param snapshot: The name of the snapshot of the index to mount + :param index: + :param ignore_index_settings: + :param index_settings: + :param master_timeout: Explicit operation timeout for connection to master node + :param renamed_index: + :param storage: Selects the kind of local storage used to accelerate searches. + Experimental, and defaults to `full_copy` + :param wait_for_completion: Should this request wait until the operation has + completed before returning """ - client, params = _deprecated_options(self, params) - for param in (repository, snapshot, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "POST", - _make_path("_snapshot", repository, snapshot, "_mount"), - params=params, - headers=headers, - body=body, + if repository in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'repository'") + if snapshot in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'snapshot'") + if index is None: + raise ValueError("Empty value passed for parameter 'index'") + __path = f"/_snapshot/{_quote(repository)}/{_quote(snapshot)}/_mount" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if index is not None: + __body["index"] = index + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_index_settings is not None: + __body["ignore_index_settings"] = ignore_index_settings + if index_settings is not None: + __body["index_settings"] = index_settings + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if renamed_index is not None: + __body["renamed_index"] = renamed_index + if storage is not None: + __query["storage"] = storage + if wait_for_completion is not None: + __query["wait_for_completion"] = wait_for_completion + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "POST", __target, headers=__headers, body=__body ) - @query_params("level") - async def stats(self, index=None, params=None, headers=None): + @_rewrite_parameters() + async def stats( + self, + *, + index: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + level: Optional[Any] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Retrieve shard-level statistics about searchable snapshots. ``_ - :arg index: A comma-separated list of index names - :arg level: Return stats aggregated at cluster, index or shard - level Valid choices: cluster, indices, shards Default: indices - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", - _make_path(index, "_searchable_snapshots", "stats"), - params=params, - headers=headers, - ) - - @query_params() - async def cache_stats(self, node_id=None, params=None, headers=None): - """ - Retrieve node-level cache statistics about searchable snapshots. - - ``_ - - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - - :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 + :param index: A comma-separated list of index names + :param level: Return stats aggregated at cluster, index or shard level """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", - _make_path("_searchable_snapshots", node_id, "cache", "stats"), - params=params, - headers=headers, - ) + if index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_searchable_snapshots/stats" + else: + __path = "/_searchable_snapshots/stats" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if level is not None: + __query["level"] = level + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) diff --git a/elasticsearch/_async/client/searchable_snapshots.pyi b/elasticsearch/_async/client/searchable_snapshots.pyi deleted file mode 100644 index 4a3a49e8b..000000000 --- a/elasticsearch/_async/client/searchable_snapshots.pyi +++ /dev/null @@ -1,101 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class SearchableSnapshotsClient(NamespacedClient): - async def clear_cache( - self, - *, - index: Optional[Any] = ..., - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def mount( - self, - repository: Any, - snapshot: Any, - *, - body: Any, - master_timeout: Optional[Any] = ..., - storage: Optional[Any] = ..., - wait_for_completion: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def stats( - self, - *, - index: Optional[Any] = ..., - level: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def cache_stats( - self, - *, - node_id: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_async/client/security.py b/elasticsearch/_async/client/security.py index 9ebe02e2d..14f86d159 100644 --- a/elasticsearch/_async/client/security.py +++ b/elasticsearch/_async/client/security.py @@ -15,926 +15,1644 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params +from .utils import SKIP_IN_PATH, _quote, _quote_query, _rewrite_parameters class SecurityClient(NamespacedClient): - @query_params() - async def authenticate(self, params=None, headers=None): + @_rewrite_parameters() + async def authenticate( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: + """ + Enables authentication as a user and retrieve information about the authenticated + user. + + ``_ + """ + __path = "/_security/_authenticate" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + async def change_password( + self, + *, + username: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + password: Optional[Any] = None, + pretty: Optional[bool] = None, + refresh: Optional[Any] = None, + ) -> Any: """ - Enables authentication as a user and retrieve information about the - authenticated user. + Changes the passwords of users in the native realm and built-in users. - ``_ - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", "/_security/_authenticate", params=params, headers=headers + ``_ + + :param username: The username of the user to change the password for + :param password: + :param refresh: If `true` (the default) then refresh the affected shards to make + this operation visible to search, if `wait_for` then wait for a refresh to + make this operation visible to search, if `false` then do nothing with refreshes. + """ + if username not in SKIP_IN_PATH: + __path = f"/_security/user/{_quote(username)}/_password" + else: + __path = "/_security/user/_password" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if password is not None: + __body["password"] = password + if pretty is not None: + __query["pretty"] = pretty + if refresh is not None: + __query["refresh"] = refresh + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "PUT", __target, headers=__headers, body=__body ) - @query_params("refresh") - async def change_password(self, body, username=None, params=None, headers=None): + @_rewrite_parameters() + async def clear_api_key_cache( + self, + *, + ids: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Changes the passwords of users in the native realm and built-in users. + Clear a subset or all entries from the API key cache. - ``_ - - :arg body: the new password for the user - :arg username: The username of the user to change the password - for - :arg refresh: If `true` (the default) then refresh the affected - shards to make this operation visible to search, if `wait_for` then wait - for a refresh to make this operation visible to search, if `false` then - do nothing with refreshes. Valid choices: true, false, wait_for - """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return await client._perform_request( - "PUT", - _make_path("_security", "user", username, "_password"), - params=params, - headers=headers, - body=body, - ) + ``_ - @query_params("usernames") - async def clear_cached_realms(self, realms, params=None, headers=None): + :param ids: A comma-separated list of IDs of API keys to clear from the cache + """ + if ids in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'ids'") + __path = f"/_security/api_key/{_quote(ids)}/_clear_cache" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters() + async def clear_cached_privileges( + self, + *, + application: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Evicts users from the user cache. Can completely clear the cache or evict - specific users. + Evicts application privileges from the native application privileges cache. - ``_ + ``_ - :arg realms: Comma-separated list of realms to clear - :arg usernames: Comma-separated list of usernames to clear from - the cache + :param application: A comma-separated list of application names + """ + if application in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'application'") + __path = f"/_security/privilege/{_quote(application)}/_clear_cache" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters() + async def clear_cached_realms( + self, + *, + realms: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + usernames: Optional[List[str]] = None, + ) -> Any: + """ + Evicts users from the user cache. Can completely clear the cache or evict specific + users. + + ``_ + + :param realms: Comma-separated list of realms to clear + :param usernames: Comma-separated list of usernames to clear from the cache """ - client, params = _deprecated_options(self, params) if realms in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'realms'.") - - return await client._perform_request( - "POST", - _make_path("_security", "realm", realms, "_clear_cache"), - params=params, - headers=headers, - ) - - @query_params() - async def clear_cached_roles(self, name, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'realms'") + __path = f"/_security/realm/{_quote(realms)}/_clear_cache" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if usernames is not None: + __query["usernames"] = usernames + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters() + async def clear_cached_roles( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Evicts roles from the native role cache. - ``_ + ``_ - :arg name: Role name + :param name: Role name """ - client, params = _deprecated_options(self, params) if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'name'.") - - return await client._perform_request( - "POST", - _make_path("_security", "role", name, "_clear_cache"), - params=params, - headers=headers, - ) - - @query_params("refresh") - async def create_api_key(self, body, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_security/role/{_quote(name)}/_clear_cache" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters() + async def clear_cached_service_tokens( + self, + *, + namespace: Any, + service: Any, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Creates an API key for access without requiring basic authentication. + Evicts tokens from the service account token caches. - ``_ + ``_ - :arg body: The api key request to create an API key - :arg refresh: If `true` (the default) then refresh the affected - shards to make this operation visible to search, if `wait_for` then wait - for a refresh to make this operation visible to search, if `false` then - do nothing with refreshes. Valid choices: true, false, wait_for + :param namespace: An identifier for the namespace + :param service: An identifier for the service name + :param name: A comma-separated list of service token names """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") + if namespace in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'namespace'") + if service in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'service'") + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_security/service/{_quote(namespace)}/{_quote(service)}/credential/token/{_quote(name)}/_clear_cache" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + async def create_api_key( + self, + *, + error_trace: Optional[bool] = None, + expiration: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + metadata: Optional[Any] = None, + name: Optional[Any] = None, + pretty: Optional[bool] = None, + refresh: Optional[Any] = None, + role_descriptors: Optional[Dict[str, Any]] = None, + ) -> Any: + """ + Creates an API key for access without requiring basic authentication. - return await client._perform_request( - "PUT", "/_security/api_key", params=params, headers=headers, body=body + ``_ + + :param expiration: Expiration time for the API key. By default, API keys never + expire. + :param metadata: Arbitrary metadata that you want to associate with the API key. + It supports nested data structure. Within the metadata object, keys beginning + with _ are reserved for system usage. + :param name: Specifies the name for this API key. + :param refresh: If `true` (the default) then refresh the affected shards to make + this operation visible to search, if `wait_for` then wait for a refresh to + make this operation visible to search, if `false` then do nothing with refreshes. + :param role_descriptors: An array of role descriptors for this API key. This + parameter is optional. When it is not specified or is an empty array, then + the API key will have a point in time snapshot of permissions of the authenticated + user. If you supply role descriptors then the resultant permissions would + be an intersection of API keys permissions and authenticated user’s permissions + thereby limiting the access scope for API keys. The structure of role descriptor + is the same as the request for create role API. For more details, see create + or update roles API. + """ + __path = "/_security/api_key" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if expiration is not None: + __body["expiration"] = expiration + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if metadata is not None: + __body["metadata"] = metadata + if name is not None: + __body["name"] = name + if pretty is not None: + __query["pretty"] = pretty + if refresh is not None: + __query["refresh"] = refresh + if role_descriptors is not None: + __body["role_descriptors"] = role_descriptors + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "PUT", __target, headers=__headers, body=__body ) - @query_params("refresh") - async def delete_privileges(self, application, name, params=None, headers=None): + @_rewrite_parameters() + async def create_service_token( + self, + *, + namespace: Any, + service: Any, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: + """ + Creates a service account token for access without requiring basic authentication. + + ``_ + + :param namespace: An identifier for the namespace + :param service: An identifier for the service name + :param name: An identifier for the token name + """ + if namespace in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'namespace'") + if service in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'service'") + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + if ( + namespace not in SKIP_IN_PATH + and service not in SKIP_IN_PATH + and name not in SKIP_IN_PATH + ): + __path = f"/_security/service/{_quote(namespace)}/{_quote(service)}/credential/token/{_quote(name)}" + __method = "PUT" + elif namespace not in SKIP_IN_PATH and service not in SKIP_IN_PATH: + __path = f"/_security/service/{_quote(namespace)}/{_quote(service)}/credential/token" + __method = "POST" + else: + raise ValueError("Couldn't find a path for the given parameters") + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request(__method, __target, headers=__headers) + + @_rewrite_parameters() + async def delete_privileges( + self, + *, + application: Any, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + refresh: Optional[Any] = None, + ) -> Any: """ Removes application privileges. - ``_ - - :arg application: Application name - :arg name: Privilege name - :arg refresh: If `true` (the default) then refresh the affected - shards to make this operation visible to search, if `wait_for` then wait - for a refresh to make this operation visible to search, if `false` then - do nothing with refreshes. Valid choices: true, false, wait_for - """ - client, params = _deprecated_options(self, params) - for param in (application, name): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "DELETE", - _make_path("_security", "privilege", application, name), - params=params, - headers=headers, - ) + ``_ - @query_params("refresh") - async def delete_role(self, name, params=None, headers=None): + :param application: Application name + :param name: Privilege name + :param refresh: If `true` (the default) then refresh the affected shards to make + this operation visible to search, if `wait_for` then wait for a refresh to + make this operation visible to search, if `false` then do nothing with refreshes. + """ + if application in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'application'") + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_security/privilege/{_quote(application)}/{_quote(name)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if refresh is not None: + __query["refresh"] = refresh + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + async def delete_role( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + refresh: Optional[Any] = None, + ) -> Any: """ Removes roles in the native realm. - ``_ + ``_ - :arg name: Role name - :arg refresh: If `true` (the default) then refresh the affected - shards to make this operation visible to search, if `wait_for` then wait - for a refresh to make this operation visible to search, if `false` then - do nothing with refreshes. Valid choices: true, false, wait_for + :param name: Role name + :param refresh: If `true` (the default) then refresh the affected shards to make + this operation visible to search, if `wait_for` then wait for a refresh to + make this operation visible to search, if `false` then do nothing with refreshes. """ - client, params = _deprecated_options(self, params) if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'name'.") - - return await client._perform_request( - "DELETE", - _make_path("_security", "role", name), - params=params, - headers=headers, - ) - - @query_params("refresh") - async def delete_role_mapping(self, name, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_security/role/{_quote(name)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if refresh is not None: + __query["refresh"] = refresh + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + async def delete_role_mapping( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + refresh: Optional[Any] = None, + ) -> Any: """ Removes role mappings. - ``_ + ``_ - :arg name: Role-mapping name - :arg refresh: If `true` (the default) then refresh the affected - shards to make this operation visible to search, if `wait_for` then wait - for a refresh to make this operation visible to search, if `false` then - do nothing with refreshes. Valid choices: true, false, wait_for + :param name: Role-mapping name + :param refresh: If `true` (the default) then refresh the affected shards to make + this operation visible to search, if `wait_for` then wait for a refresh to + make this operation visible to search, if `false` then do nothing with refreshes. """ - client, params = _deprecated_options(self, params) if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'name'.") + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_security/role_mapping/{_quote(name)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if refresh is not None: + __query["refresh"] = refresh + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + async def delete_service_token( + self, + *, + namespace: Any, + service: Any, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + refresh: Optional[Any] = None, + ) -> Any: + """ + Deletes a service account token. - return await client._perform_request( - "DELETE", - _make_path("_security", "role_mapping", name), - params=params, - headers=headers, - ) + ``_ - @query_params("refresh") - async def delete_user(self, username, params=None, headers=None): + :param namespace: An identifier for the namespace + :param service: An identifier for the service name + :param name: An identifier for the token name + :param refresh: If `true` then refresh the affected shards to make this operation + visible to search, if `wait_for` (the default) then wait for a refresh to + make this operation visible to search, if `false` then do nothing with refreshes. + """ + if namespace in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'namespace'") + if service in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'service'") + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_security/service/{_quote(namespace)}/{_quote(service)}/credential/token/{_quote(name)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if refresh is not None: + __query["refresh"] = refresh + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + async def delete_user( + self, + *, + username: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + refresh: Optional[Any] = None, + ) -> Any: """ Deletes users from the native realm. - ``_ + ``_ - :arg username: username - :arg refresh: If `true` (the default) then refresh the affected - shards to make this operation visible to search, if `wait_for` then wait - for a refresh to make this operation visible to search, if `false` then - do nothing with refreshes. Valid choices: true, false, wait_for + :param username: username + :param refresh: If `true` (the default) then refresh the affected shards to make + this operation visible to search, if `wait_for` then wait for a refresh to + make this operation visible to search, if `false` then do nothing with refreshes. """ - client, params = _deprecated_options(self, params) if username in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'username'.") - - return await client._perform_request( - "DELETE", - _make_path("_security", "user", username), - params=params, - headers=headers, - ) - - @query_params("refresh") - async def disable_user(self, username, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'username'") + __path = f"/_security/user/{_quote(username)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if refresh is not None: + __query["refresh"] = refresh + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + async def disable_user( + self, + *, + username: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + refresh: Optional[Any] = None, + ) -> Any: """ 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 - shards to make this operation visible to search, if `wait_for` then wait - for a refresh to make this operation visible to search, if `false` then - do nothing with refreshes. Valid choices: true, false, wait_for + :param username: The username of the user to disable + :param refresh: If `true` (the default) then refresh the affected shards to make + this operation visible to search, if `wait_for` then wait for a refresh to + make this operation visible to search, if `false` then do nothing with refreshes. """ - client, params = _deprecated_options(self, params) if username in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'username'.") - - return await client._perform_request( - "PUT", - _make_path("_security", "user", username, "_disable"), - params=params, - headers=headers, - ) - - @query_params("refresh") - async def enable_user(self, username, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'username'") + __path = f"/_security/user/{_quote(username)}/_disable" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if refresh is not None: + __query["refresh"] = refresh + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("PUT", __target, headers=__headers) + + @_rewrite_parameters() + async def enable_user( + self, + *, + username: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + refresh: Optional[Any] = None, + ) -> Any: """ 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 - shards to make this operation visible to search, if `wait_for` then wait - for a refresh to make this operation visible to search, if `false` then - do nothing with refreshes. Valid choices: true, false, wait_for + :param username: The username of the user to enable + :param refresh: If `true` (the default) then refresh the affected shards to make + this operation visible to search, if `wait_for` then wait for a refresh to + make this operation visible to search, if `false` then do nothing with refreshes. """ - client, params = _deprecated_options(self, params) if username in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'username'.") - - return await client._perform_request( - "PUT", - _make_path("_security", "user", username, "_enable"), - params=params, - headers=headers, - ) - - @query_params("id", "name", "owner", "realm_name", "username") - async def get_api_key(self, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'username'") + __path = f"/_security/user/{_quote(username)}/_enable" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if refresh is not None: + __query["refresh"] = refresh + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("PUT", __target, headers=__headers) + + @_rewrite_parameters() + async def get_api_key( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + id: Optional[Any] = None, + name: Optional[Any] = None, + owner: Optional[bool] = None, + pretty: Optional[bool] = None, + realm_name: Optional[Any] = None, + username: Optional[Any] = None, + ) -> Any: """ 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 - :arg owner: flag to query API keys owned by the currently - authenticated user - :arg realm_name: realm name of the user who created this API key - to be retrieved - :arg username: user name of the user who created this API key to - be retrieved - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", "/_security/api_key", params=params, headers=headers - ) - - @query_params() + ``_ + + :param id: API key id of the API key to be retrieved + :param name: API key name of the API key to be retrieved + :param owner: flag to query API keys owned by the currently authenticated user + :param realm_name: realm name of the user who created this API key to be retrieved + :param username: user name of the user who created this API key to be retrieved + """ + __path = "/_security/api_key" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if id is not None: + __query["id"] = id + if name is not None: + __query["name"] = name + if owner is not None: + __query["owner"] = owner + if pretty is not None: + __query["pretty"] = pretty + if realm_name is not None: + __query["realm_name"] = realm_name + if username is not None: + __query["username"] = username + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def get_builtin_privileges( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: + """ + Retrieves the list of cluster privileges and index privileges that are available + in this version of Elasticsearch. + + ``_ + """ + __path = "/_security/privilege/_builtin" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() async def get_privileges( - self, application=None, name=None, params=None, headers=None - ): + self, + *, + application: Optional[Any] = None, + name: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Retrieves application privileges. - ``_ - - :arg application: Application name - :arg name: Privilege name - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", - _make_path("_security", "privilege", application, name), - params=params, - headers=headers, - ) - - @query_params() - async def get_role(self, name=None, params=None, headers=None): + ``_ + + :param application: Application name + :param name: Privilege name + """ + if application not in SKIP_IN_PATH and name not in SKIP_IN_PATH: + __path = f"/_security/privilege/{_quote(application)}/{_quote(name)}" + elif application not in SKIP_IN_PATH: + __path = f"/_security/privilege/{_quote(application)}" + else: + __path = "/_security/privilege" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def get_role( + self, + *, + name: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Retrieves roles in the native realm. - ``_ - - :arg name: A comma-separated list of role names - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", _make_path("_security", "role", name), params=params, headers=headers - ) - - @query_params() - async def get_role_mapping(self, name=None, params=None, headers=None): + ``_ + + :param name: A comma-separated list of role names + """ + if name not in SKIP_IN_PATH: + __path = f"/_security/role/{_quote(name)}" + else: + __path = "/_security/role" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def get_role_mapping( + self, + *, + name: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Retrieves role mappings. - ``_ - - :arg name: A comma-separated list of role-mapping names + ``_ + + :param name: A comma-separated list of role-mapping names + """ + if name not in SKIP_IN_PATH: + __path = f"/_security/role_mapping/{_quote(name)}" + else: + __path = "/_security/role_mapping" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def get_service_accounts( + self, + *, + namespace: Optional[Any] = None, + service: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", - _make_path("_security", "role_mapping", name), - params=params, - headers=headers, - ) + Retrieves information about service accounts. - @query_params() - async def get_token(self, body, params=None, headers=None): + ``_ + + :param namespace: An identifier for the namespace + :param service: An identifier for the service name + """ + if namespace not in SKIP_IN_PATH and service not in SKIP_IN_PATH: + __path = f"/_security/service/{_quote(namespace)}/{_quote(service)}" + elif namespace not in SKIP_IN_PATH: + __path = f"/_security/service/{_quote(namespace)}" + else: + __path = "/_security/service" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def get_service_credentials( + self, + *, + namespace: Any, + service: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Creates a bearer token for access without requiring basic authentication. - - ``_ + Retrieves information of all service credentials for a service account. - :arg body: The token request to get + ``_ + + :param namespace: Name of the namespace. + :param service: Name of the service name. + """ + if namespace in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'namespace'") + if service in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'service'") + __path = f"/_security/service/{_quote(namespace)}/{_quote(service)}/credential" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + async def get_token( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + grant_type: Optional[Any] = None, + human: Optional[bool] = None, + kerberos_ticket: Optional[str] = None, + password: Optional[Any] = None, + pretty: Optional[bool] = None, + refresh_token: Optional[str] = None, + scope: Optional[str] = None, + username: Optional[Any] = None, + ) -> Any: """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") + Creates a bearer token for access without requiring basic authentication. - return await client._perform_request( - "POST", "/_security/oauth2/token", params=params, headers=headers, body=body + ``_ + + :param grant_type: + :param kerberos_ticket: + :param password: + :param refresh_token: + :param scope: + :param username: + """ + __path = "/_security/oauth2/token" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if grant_type is not None: + __body["grant_type"] = grant_type + if human is not None: + __query["human"] = human + if kerberos_ticket is not None: + __body["kerberos_ticket"] = kerberos_ticket + if password is not None: + __body["password"] = password + if pretty is not None: + __query["pretty"] = pretty + if refresh_token is not None: + __body["refresh_token"] = refresh_token + if scope is not None: + __body["scope"] = scope + if username is not None: + __body["username"] = username + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "POST", __target, headers=__headers, body=__body ) - @query_params() - async def get_user(self, username=None, params=None, headers=None): + @_rewrite_parameters() + async def get_user( + self, + *, + username: Optional[Union[Any, List[Any]]] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Retrieves information about users in the native realm and built-in users. - ``_ - - :arg username: A comma-separated list of usernames - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", - _make_path("_security", "user", username), - params=params, - headers=headers, - ) - - @query_params() - async def get_user_privileges(self, params=None, headers=None): + ``_ + + :param username: An identifier for the user. You can specify multiple usernames + as a comma-separated list. If you omit this parameter, the API retrieves + information about all users. + """ + if username not in SKIP_IN_PATH: + __path = f"/_security/user/{_quote(username)}" + else: + __path = "/_security/user" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def get_user_privileges( + self, + *, + application: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + priviledge: Optional[Any] = None, + ) -> Any: """ Retrieves security privileges for the logged in user. - ``_ + ``_ + + :param application: The name of the application. Application privileges are always + associated with exactly one application. If you do not specify this parameter, + the API returns information about all privileges for all applications. + :param priviledge: The name of the privilege. If you do not specify this parameter, + the API returns information about all privileges for the requested application. + """ + __path = "/_security/user/_privileges" + __query: Dict[str, Any] = {} + if application is not None: + __query["application"] = application + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if priviledge is not None: + __query["priviledge"] = priviledge + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ignore_deprecated_options={"api_key"}, + ) + async def grant_api_key( + self, + *, + api_key: Any, + grant_type: Any, + access_token: Optional[str] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + password: Optional[Any] = None, + pretty: Optional[bool] = None, + username: Optional[Any] = None, + ) -> Any: """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", "/_security/user/_privileges", params=params, headers=headers + Creates an API key on behalf of another user. + + ``_ + + :param api_key: + :param grant_type: + :param access_token: + :param password: + :param username: + """ + if api_key is None: + raise ValueError("Empty value passed for parameter 'api_key'") + if grant_type is None: + raise ValueError("Empty value passed for parameter 'grant_type'") + __path = "/_security/api_key/grant" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if api_key is not None: + __body["api_key"] = api_key + if grant_type is not None: + __body["grant_type"] = grant_type + if access_token is not None: + __body["access_token"] = access_token + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if password is not None: + __body["password"] = password + if pretty is not None: + __query["pretty"] = pretty + if username is not None: + __body["username"] = username + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "POST", __target, headers=__headers, body=__body ) - @query_params() - async def has_privileges(self, body, user=None, params=None, headers=None): + @_rewrite_parameters( + body_fields=True, + ) + async def has_privileges( + self, + *, + user: Optional[Any] = None, + application: Optional[List[Any]] = None, + cluster: Optional[List[Any]] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + index: Optional[List[Any]] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Determines whether the specified user has a specified list of privileges. - ``_ - - :arg body: The privileges to test - :arg user: Username - """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return await client._perform_request( - "POST", - _make_path("_security", "user", user, "_has_privileges"), - params=params, - headers=headers, - body=body, + ``_ + + :param user: Username + :param application: + :param cluster: + :param index: + """ + if user not in SKIP_IN_PATH: + __path = f"/_security/user/{_quote(user)}/_has_privileges" + else: + __path = "/_security/user/_has_privileges" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if application is not None: + __body["application"] = application + if cluster is not None: + __body["cluster"] = cluster + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if index is not None: + __body["index"] = index + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "POST", __target, headers=__headers, body=__body ) - @query_params() - async def invalidate_api_key(self, body, params=None, headers=None): + @_rewrite_parameters( + body_fields=True, + ) + async def invalidate_api_key( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + id: Optional[Any] = None, + ids: Optional[List[Any]] = None, + name: Optional[Any] = None, + owner: Optional[bool] = None, + pretty: Optional[bool] = None, + realm_name: Optional[str] = None, + username: Optional[Any] = None, + ) -> Any: """ Invalidates one or more API keys. - ``_ - - :arg body: The api key request to invalidate API key(s) - """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return await client._perform_request( - "DELETE", "/_security/api_key", params=params, headers=headers, body=body + ``_ + + :param id: + :param ids: + :param name: + :param owner: + :param realm_name: + :param username: + """ + __path = "/_security/api_key" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if id is not None: + __body["id"] = id + if ids is not None: + __body["ids"] = ids + if name is not None: + __body["name"] = name + if owner is not None: + __body["owner"] = owner + if pretty is not None: + __query["pretty"] = pretty + if realm_name is not None: + __body["realm_name"] = realm_name + if username is not None: + __body["username"] = username + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "DELETE", __target, headers=__headers, body=__body ) - @query_params() - async def invalidate_token(self, body, params=None, headers=None): + @_rewrite_parameters( + body_fields=True, + ) + async def invalidate_token( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + realm_name: Optional[Any] = None, + refresh_token: Optional[str] = None, + token: Optional[str] = None, + username: Optional[Any] = None, + ) -> Any: """ Invalidates one or more access tokens or refresh tokens. - ``_ - - :arg body: The token to invalidate - """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return await client._perform_request( - "DELETE", - "/_security/oauth2/token", - params=params, - headers=headers, - body=body, + ``_ + + :param realm_name: + :param refresh_token: + :param token: + :param username: + """ + __path = "/_security/oauth2/token" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if realm_name is not None: + __body["realm_name"] = realm_name + if refresh_token is not None: + __body["refresh_token"] = refresh_token + if token is not None: + __body["token"] = token + if username is not None: + __body["username"] = username + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "DELETE", __target, headers=__headers, body=__body ) - @query_params("refresh") - async def put_privileges(self, body, params=None, headers=None): + @_rewrite_parameters( + body_name="privileges", + ) + async def put_privileges( + self, + *, + privileges: Dict[str, Dict[str, Any]], + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + refresh: Optional[Any] = None, + ) -> Any: """ Adds or updates application privileges. - ``_ - - :arg body: The privilege(s) to add - :arg refresh: If `true` (the default) then refresh the affected - shards to make this operation visible to search, if `wait_for` then wait - for a refresh to make this operation visible to search, if `false` then - do nothing with refreshes. Valid choices: true, false, wait_for - """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return await client._perform_request( - "PUT", "/_security/privilege/", params=params, headers=headers, body=body + ``_ + + :param privileges: + :param refresh: If `true` (the default) then refresh the affected shards to make + this operation visible to search, if `wait_for` then wait for a refresh to + make this operation visible to search, if `false` then do nothing with refreshes. + """ + if privileges is None: + raise ValueError("Empty value passed for parameter 'privileges'") + __path = "/_security/privilege" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if refresh is not None: + __query["refresh"] = refresh + __body = privileges + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "PUT", __target, headers=__headers, body=__body ) - @query_params("refresh") - async def put_role(self, name, body, params=None, headers=None): + @_rewrite_parameters( + body_fields=True, + parameter_aliases={"global": "global_"}, + ) + async def put_role( + self, + *, + name: Any, + applications: Optional[List[Any]] = None, + cluster: Optional[List[Any]] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + global_: Optional[Dict[str, Any]] = None, + human: Optional[bool] = None, + indices: Optional[List[Any]] = None, + metadata: Optional[Any] = None, + pretty: Optional[bool] = None, + refresh: Optional[Any] = None, + run_as: Optional[List[str]] = None, + transient_metadata: Optional[Any] = None, + ) -> Any: """ Adds and updates roles in the native realm. - ``_ - - :arg name: Role name - :arg body: The role to add - :arg refresh: If `true` (the default) then refresh the affected - shards to make this operation visible to search, if `wait_for` then wait - for a refresh to make this operation visible to search, if `false` then - do nothing with refreshes. Valid choices: true, false, wait_for - """ - client, params = _deprecated_options(self, params) - for param in (name, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "PUT", - _make_path("_security", "role", name), - params=params, - headers=headers, - body=body, - ) - - @query_params("refresh") - 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 - :arg refresh: If `true` (the default) then refresh the affected - shards to make this operation visible to search, if `wait_for` then wait - for a refresh to make this operation visible to search, if `false` then - do nothing with refreshes. Valid choices: true, false, wait_for - """ - client, params = _deprecated_options(self, params) - for param in (name, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "PUT", - _make_path("_security", "role_mapping", name), - params=params, - headers=headers, - body=body, - ) - - @query_params("refresh") - 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 - :arg refresh: If `true` (the default) then refresh the affected - shards to make this operation visible to search, if `wait_for` then wait - for a refresh to make this operation visible to search, if `false` then - do nothing with refreshes. Valid choices: true, false, wait_for - """ - client, params = _deprecated_options(self, params) - for param in (username, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "PUT", - _make_path("_security", "user", username), - params=params, - headers=headers, - body=body, - ) - - @query_params() - 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. - - ``_ - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", "/_security/privilege/_builtin", params=params, headers=headers - ) - - @query_params() - async def clear_cached_privileges(self, application, params=None, headers=None): - """ - Evicts application privileges from the native application privileges cache. - - ``_ - - :arg application: A comma-separated list of application names - """ - client, params = _deprecated_options(self, params) - if application in SKIP_IN_PATH: - raise ValueError( - "Empty value passed for a required argument 'application'." - ) - - return await client._perform_request( - "POST", - _make_path("_security", "privilege", application, "_clear_cache"), - params=params, - headers=headers, - ) - - @query_params() - async def clear_api_key_cache(self, ids, params=None, headers=None): + ``_ + + :param name: Role name + :param applications: A list of application privilege entries. + :param cluster: A list of cluster privileges. These privileges define the cluster-level + actions for users with this role. + :param global_: An object defining global privileges. A global privilege is a + form of cluster privilege that is request-aware. Support for global privileges + is currently limited to the management of application privileges. + :param indices: A list of indices permissions entries. + :param metadata: Optional metadata. Within the metadata object, keys that begin + with an underscore (`_`) are reserved for system use. + :param refresh: If `true` (the default) then refresh the affected shards to make + this operation visible to search, if `wait_for` then wait for a refresh to + make this operation visible to search, if `false` then do nothing with refreshes. + :param run_as: A list of users that the owners of this role can impersonate. + :param transient_metadata: Indicates roles that might be incompatible with the + current cluster license, specifically roles with document and field level + security. When the cluster license doesn’t allow certain features for a given + role, this parameter is updated dynamically to list the incompatible features. + If `enabled` is `false`, the role is ignored, but is still listed in the + response from the authenticate API. """ - Clear a subset or all entries from the API key cache. - - ``_ - - :arg ids: A comma-separated list of IDs of API keys to clear - from the cache - """ - client, params = _deprecated_options(self, params) - if ids in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'ids'.") - - return await client._perform_request( - "POST", - _make_path("_security", "api_key", ids, "_clear_cache"), - params=params, - headers=headers, - ) - - @query_params("refresh") - async def grant_api_key(self, body, params=None, headers=None): - """ - Creates an API key on behalf of another user. - - ``_ - - :arg body: The api key request to create an API key - :arg refresh: If `true` (the default) then refresh the affected - shards to make this operation visible to search, if `wait_for` then wait - for a refresh to make this operation visible to search, if `false` then - do nothing with refreshes. Valid choices: true, false, wait_for - """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return await client._perform_request( - "POST", - "/_security/api_key/grant", - params=params, - headers=headers, - body=body, - ) - - @query_params() - async def clear_cached_service_tokens( - self, namespace, service, name, params=None, headers=None - ): - """ - Evicts tokens from the service account token caches. - - ``_ - - :arg namespace: An identifier for the namespace - :arg service: An identifier for the service name - :arg name: A comma-separated list of service token names - """ - client, params = _deprecated_options(self, params) - for param in (namespace, service, name): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "POST", - _make_path( - "_security", - "service", - namespace, - service, - "credential", - "token", - name, - "_clear_cache", - ), - params=params, - headers=headers, - ) - - @query_params("refresh") - async def create_service_token( - self, namespace, service, name=None, params=None, headers=None - ): - """ - Creates a service account token for access without requiring basic - authentication. - - ``_ - - :arg namespace: An identifier for the namespace - :arg service: An identifier for the service name - :arg name: An identifier for the token name - :arg refresh: If `true` then refresh the affected shards to make - this operation visible to search, if `wait_for` (the default) then wait - for a refresh to make this operation visible to search, if `false` then - do nothing with refreshes. Valid choices: true, false, wait_for - """ - client, params = _deprecated_options(self, params) - for param in (namespace, service): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "PUT", - _make_path( - "_security", "service", namespace, service, "credential", "token", name - ), - params=params, - headers=headers, - ) - - @query_params("refresh") - async def delete_service_token( - self, namespace, service, name, params=None, headers=None - ): - """ - Deletes a service account token. - - ``_ - - :arg namespace: An identifier for the namespace - :arg service: An identifier for the service name - :arg name: An identifier for the token name - :arg refresh: If `true` then refresh the affected shards to make - this operation visible to search, if `wait_for` (the default) then wait - for a refresh to make this operation visible to search, if `false` then - do nothing with refreshes. Valid choices: true, false, wait_for - """ - client, params = _deprecated_options(self, params) - for param in (namespace, service, name): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "DELETE", - _make_path( - "_security", "service", namespace, service, "credential", "token", name - ), - params=params, - headers=headers, - ) - - @query_params() - async def get_service_accounts( - self, namespace=None, service=None, params=None, headers=None - ): - """ - Retrieves information about service accounts. - - ``_ - - :arg namespace: An identifier for the namespace - :arg service: An identifier for the service name - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", - _make_path("_security", "service", namespace, service), - params=params, - headers=headers, - ) - - @query_params() - async def get_service_credentials( - self, namespace, service, params=None, headers=None - ): - """ - Retrieves information of all service credentials for a service account. - - ``_ - - :arg namespace: An identifier for the namespace - :arg service: An identifier for the service name - """ - client, params = _deprecated_options(self, params) - for param in (namespace, service): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "GET", - _make_path("_security", "service", namespace, service, "credential"), - params=params, - headers=headers, - ) - - @query_params() - async def enroll_node(self, params=None, headers=None): - """ - Allows a new node to enroll to an existing cluster with security enabled. - - ``_ - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", "/_security/enroll/node", params=params, headers=headers - ) - - @query_params() - async def saml_complete_logout(self, body, params=None, headers=None): - """ - Verifies the logout response sent from the SAML IdP - - ``_ - - :arg body: The logout response to verify - """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return await client._perform_request( - "POST", - "/_security/saml/complete_logout", - params=params, - headers=headers, - body=body, - ) - - @query_params() - async def enroll_kibana(self, params=None, headers=None): - """ - Allows a kibana instance to configure itself to communicate with a secured - elasticsearch cluster. - - ``_ - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", "/_security/enroll/kibana", params=params, headers=headers - ) - - @query_params() - async def saml_authenticate(self, body, params=None, headers=None): - """ - Exchanges a SAML Response message for an Elasticsearch access token and refresh - token pair - - ``_ - - :arg body: The SAML response to authenticate - """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return await client._perform_request( - "POST", - "/_security/saml/authenticate", - params=params, - headers=headers, - body=body, - ) - - @query_params() - async def saml_invalidate(self, body, params=None, headers=None): - """ - Consumes a SAML LogoutRequest - - ``_ - - :arg body: The LogoutRequest message - """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return await client._perform_request( - "POST", - "/_security/saml/invalidate", - params=params, - headers=headers, - body=body, - ) - - @query_params() - async def saml_logout(self, body, params=None, headers=None): - """ - Invalidates an access token and a refresh token that were generated via the - SAML Authenticate API - - ``_ - - :arg body: The tokens to invalidate - """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return await client._perform_request( - "POST", "/_security/saml/logout", params=params, headers=headers, body=body - ) - - @query_params() - async def saml_prepare_authentication(self, body, params=None, headers=None): - """ - Creates a SAML authentication request - - ``_ - - :arg body: The realm for which to create the authentication - request, identified by either its name or the ACS URL - """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return await client._perform_request( - "POST", "/_security/saml/prepare", params=params, headers=headers, body=body + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_security/role/{_quote(name)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if applications is not None: + __body["applications"] = applications + if cluster is not None: + __body["cluster"] = cluster + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if global_ is not None: + __body["global"] = global_ + if human is not None: + __query["human"] = human + if indices is not None: + __body["indices"] = indices + if metadata is not None: + __body["metadata"] = metadata + if pretty is not None: + __query["pretty"] = pretty + if refresh is not None: + __query["refresh"] = refresh + if run_as is not None: + __body["run_as"] = run_as + if transient_metadata is not None: + __body["transient_metadata"] = transient_metadata + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "PUT", __target, headers=__headers, body=__body ) - @query_params() - async def saml_service_provider_metadata( - self, realm_name, params=None, headers=None - ): + @_rewrite_parameters( + body_fields=True, + ) + async def put_role_mapping( + self, + *, + name: Any, + enabled: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + metadata: Optional[Any] = None, + pretty: Optional[bool] = None, + refresh: Optional[Any] = None, + roles: Optional[List[str]] = None, + rules: Optional[Any] = None, + run_as: Optional[List[str]] = None, + ) -> Any: """ - Generates SAML metadata for the Elastic stack SAML 2.0 Service Provider + Creates and updates role mappings. - ``_ + ``_ - :arg realm_name: The name of the SAML realm to get the metadata - for + :param name: Role-mapping name + :param enabled: + :param metadata: + :param refresh: If `true` (the default) then refresh the affected shards to make + this operation visible to search, if `wait_for` then wait for a refresh to + make this operation visible to search, if `false` then do nothing with refreshes. + :param roles: + :param rules: + :param run_as: """ - client, params = _deprecated_options(self, params) - if realm_name in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'realm_name'.") - - return await client._perform_request( - "GET", - _make_path("_security", "saml", "metadata", realm_name), - params=params, - headers=headers, + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_security/role_mapping/{_quote(name)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if enabled is not None: + __body["enabled"] = enabled + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if metadata is not None: + __body["metadata"] = metadata + if pretty is not None: + __query["pretty"] = pretty + if refresh is not None: + __query["refresh"] = refresh + if roles is not None: + __body["roles"] = roles + if rules is not None: + __body["rules"] = rules + if run_as is not None: + __body["run_as"] = run_as + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "PUT", __target, headers=__headers, body=__body ) - @query_params() - async def query_api_keys(self, body=None, params=None, headers=None): + @_rewrite_parameters( + body_fields=True, + ) + async def put_user( + self, + *, + username: Any, + email: Optional[Union[None, str]] = None, + enabled: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + full_name: Optional[Union[None, str]] = None, + human: Optional[bool] = None, + metadata: Optional[Any] = None, + password: Optional[Any] = None, + password_hash: Optional[str] = None, + pretty: Optional[bool] = None, + refresh: Optional[Any] = None, + roles: Optional[List[str]] = None, + ) -> Any: """ - Retrieves information for API keys using a subset of query DSL + Adds and updates users in the native realm. These users are commonly referred + to as native users. - ``_ + ``_ - :arg body: From, size, query, sort and search_after + :param username: The username of the User + :param email: + :param enabled: + :param full_name: + :param metadata: + :param password: + :param password_hash: + :param refresh: If `true` (the default) then refresh the affected shards to make + this operation visible to search, if `wait_for` then wait for a refresh to + make this operation visible to search, if `false` then do nothing with refreshes. + :param roles: """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "POST", - "/_security/_query/api_key", - params=params, - headers=headers, - body=body, + if username in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'username'") + __path = f"/_security/user/{_quote(username)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if email is not None: + __body["email"] = email + if enabled is not None: + __body["enabled"] = enabled + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if full_name is not None: + __body["full_name"] = full_name + if human is not None: + __query["human"] = human + if metadata is not None: + __body["metadata"] = metadata + if password is not None: + __body["password"] = password + if password_hash is not None: + __body["password_hash"] = password_hash + if pretty is not None: + __query["pretty"] = pretty + if refresh is not None: + __query["refresh"] = refresh + if roles is not None: + __body["roles"] = roles + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "PUT", __target, headers=__headers, body=__body ) diff --git a/elasticsearch/_async/client/security.pyi b/elasticsearch/_async/client/security.pyi deleted file mode 100644 index 8e7ba94a9..000000000 --- a/elasticsearch/_async/client/security.pyi +++ /dev/null @@ -1,785 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class SecurityClient(NamespacedClient): - async def authenticate( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def change_password( - self, - *, - body: Any, - username: Optional[Any] = ..., - refresh: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def clear_cached_realms( - self, - realms: Any, - *, - usernames: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def clear_cached_roles( - self, - name: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def create_api_key( - self, - *, - body: Any, - refresh: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def delete_privileges( - self, - application: Any, - name: Any, - *, - refresh: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def delete_role( - self, - name: Any, - *, - refresh: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def delete_role_mapping( - self, - name: Any, - *, - refresh: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def delete_user( - self, - username: Any, - *, - refresh: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def disable_user( - self, - username: Any, - *, - refresh: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def enable_user( - self, - username: Any, - *, - refresh: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_api_key( - self, - *, - id: Optional[Any] = ..., - name: Optional[Any] = ..., - owner: Optional[Any] = ..., - realm_name: Optional[Any] = ..., - username: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_privileges( - self, - *, - application: Optional[Any] = ..., - name: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_role( - self, - *, - name: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_role_mapping( - self, - *, - name: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_token( - self, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_user( - self, - *, - username: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_user_privileges( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def has_privileges( - self, - *, - body: Any, - user: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def invalidate_api_key( - self, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def invalidate_token( - self, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def put_privileges( - self, - *, - body: Any, - refresh: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def put_role( - self, - name: Any, - *, - body: Any, - refresh: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def put_role_mapping( - self, - name: Any, - *, - body: Any, - refresh: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def put_user( - self, - username: Any, - *, - body: Any, - refresh: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_builtin_privileges( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def clear_cached_privileges( - self, - application: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def clear_api_key_cache( - self, - ids: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def grant_api_key( - self, - *, - body: Any, - refresh: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def clear_cached_service_tokens( - self, - namespace: Any, - service: Any, - name: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def create_service_token( - self, - namespace: Any, - service: Any, - *, - name: Optional[Any] = ..., - refresh: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def delete_service_token( - self, - namespace: Any, - service: Any, - name: Any, - *, - refresh: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_service_accounts( - self, - *, - namespace: Optional[Any] = ..., - service: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_service_credentials( - self, - namespace: Any, - service: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def enroll_node( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def saml_complete_logout( - self, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def enroll_kibana( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def saml_authenticate( - self, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def saml_invalidate( - self, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def saml_logout( - self, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def saml_prepare_authentication( - self, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def saml_service_provider_metadata( - self, - realm_name: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def query_api_keys( - self, - *, - body: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_async/client/shutdown.py b/elasticsearch/_async/client/shutdown.py index 15f8ddb1f..b62af7fee 100644 --- a/elasticsearch/_async/client/shutdown.py +++ b/elasticsearch/_async/client/shutdown.py @@ -15,72 +15,121 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params +from .utils import SKIP_IN_PATH, _quote, _quote_query, _rewrite_parameters class ShutdownClient(NamespacedClient): - @query_params() - async def delete_node(self, node_id, params=None, headers=None): + @_rewrite_parameters() + async def delete_node( + self, + *, + node_id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Removes a node from the shutdown list. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported. ``_ - :arg node_id: The node id of node to be removed from the - shutdown state + :param node_id: The node id of node to be removed from the shutdown state """ - client, params = _deprecated_options(self, params) if node_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'node_id'.") - - return await client._perform_request( - "DELETE", - _make_path("_nodes", node_id, "shutdown"), - params=params, - headers=headers, - ) + raise ValueError("Empty value passed for parameter 'node_id'") + __path = f"/_nodes/{_quote(node_id)}/shutdown" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("DELETE", __target, headers=__headers) - @query_params() - async def get_node(self, node_id=None, params=None, headers=None): + @_rewrite_parameters() + async def get_node( + self, + *, + node_id: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Retrieve status of a node or nodes that are currently marked as shutting down. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported. ``_ - :arg node_id: Which node for which to retrieve the shutdown - status + :param node_id: Which node for which to retrieve the shutdown status """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", - _make_path("_nodes", node_id, "shutdown"), - params=params, - headers=headers, - ) + if node_id not in SKIP_IN_PATH: + __path = f"/_nodes/{_quote(node_id)}/shutdown" + else: + __path = "/_nodes/shutdown" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) - @query_params() - async def put_node(self, node_id, body, params=None, headers=None): + @_rewrite_parameters() + async def put_node( + self, + *, + node_id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Adds a node to be shut down. Designed for indirect use by ECE/ESS and ECK. - Direct use is not supported. + Adds a node to be shut down. Designed for indirect use by ECE/ESS and ECK. Direct + use is not supported. ``_ - :arg node_id: The node id of node to be shut down - :arg body: The shutdown type definition to register + :param node_id: The node id of node to be shut down """ - client, params = _deprecated_options(self, params) - for param in (node_id, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "PUT", - _make_path("_nodes", node_id, "shutdown"), - params=params, - headers=headers, - body=body, - ) + if node_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'node_id'") + __path = f"/_nodes/{_quote(node_id)}/shutdown" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("PUT", __target, headers=__headers) diff --git a/elasticsearch/_async/client/shutdown.pyi b/elasticsearch/_async/client/shutdown.pyi deleted file mode 100644 index 84c6eb385..000000000 --- a/elasticsearch/_async/client/shutdown.pyi +++ /dev/null @@ -1,76 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class ShutdownClient(NamespacedClient): - async def delete_node( - self, - node_id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_node( - self, - *, - node_id: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def put_node( - self, - node_id: Any, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_async/client/slm.py b/elasticsearch/_async/client/slm.py index e9df99493..d71fb356e 100644 --- a/elasticsearch/_async/client/slm.py +++ b/elasticsearch/_async/client/slm.py @@ -15,153 +15,359 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params +from .utils import SKIP_IN_PATH, _quote, _quote_query, _rewrite_parameters class SlmClient(NamespacedClient): - @query_params() - async def delete_lifecycle(self, policy_id, params=None, headers=None): + @_rewrite_parameters() + async def delete_lifecycle( + self, + *, + policy_id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Deletes an existing snapshot lifecycle policy. - ``_ + ``_ - :arg policy_id: The id of the snapshot lifecycle policy to - remove + :param policy_id: The id of the snapshot lifecycle policy to remove """ - client, params = _deprecated_options(self, params) if policy_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'policy_id'.") - - return await client._perform_request( - "DELETE", - _make_path("_slm", "policy", policy_id), - params=params, - headers=headers, - ) + raise ValueError("Empty value passed for parameter 'policy_id'") + __path = f"/_slm/policy/{_quote(policy_id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("DELETE", __target, headers=__headers) - @query_params() - async def execute_lifecycle(self, policy_id, params=None, headers=None): + @_rewrite_parameters() + async def execute_lifecycle( + self, + *, + policy_id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Immediately creates a snapshot according to the lifecycle policy, without - waiting for the scheduled time. + 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 + :param policy_id: The id of the snapshot lifecycle policy to be executed """ - client, params = _deprecated_options(self, params) if policy_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'policy_id'.") - - return await client._perform_request( - "PUT", - _make_path("_slm", "policy", policy_id, "_execute"), - params=params, - headers=headers, - ) + raise ValueError("Empty value passed for parameter 'policy_id'") + __path = f"/_slm/policy/{_quote(policy_id)}/_execute" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("PUT", __target, headers=__headers) - @query_params() - async def execute_retention(self, params=None, headers=None): + @_rewrite_parameters() + async def execute_retention( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Deletes any snapshots that are expired according to the policy's retention - rules. + Deletes any snapshots that are expired according to the policy's retention rules. - ``_ + ``_ """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "POST", "/_slm/_execute_retention", params=params, headers=headers - ) + __path = "/_slm/_execute_retention" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) - @query_params() - async def get_lifecycle(self, policy_id=None, params=None, headers=None): + @_rewrite_parameters() + async def get_lifecycle( + self, + *, + policy_id: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Retrieves one or more snapshot lifecycle policy definitions and information - about the latest snapshot attempts. + 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 + :param policy_id: Comma-separated list of snapshot lifecycle policies to retrieve """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", - _make_path("_slm", "policy", policy_id), - params=params, - headers=headers, - ) + if policy_id not in SKIP_IN_PATH: + __path = f"/_slm/policy/{_quote(policy_id)}" + else: + __path = "/_slm/policy" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) - @query_params() - async def get_stats(self, params=None, headers=None): + @_rewrite_parameters() + async def get_stats( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Returns global and policy-level statistics about actions taken by snapshot - lifecycle management. + Returns global and policy-level statistics about actions taken by snapshot lifecycle + management. ``_ """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", "/_slm/stats", params=params, headers=headers - ) + __path = "/_slm/stats" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) - @query_params() - async def put_lifecycle(self, policy_id, body=None, params=None, headers=None): + @_rewrite_parameters() + async def get_status( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Creates or updates a snapshot lifecycle policy. - - ``_ + Retrieves the status of snapshot lifecycle management (SLM). - :arg policy_id: The id of the snapshot lifecycle policy - :arg body: The snapshot lifecycle policy definition to register + ``_ """ - client, params = _deprecated_options(self, params) - if policy_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'policy_id'.") - - return await client._perform_request( - "PUT", - _make_path("_slm", "policy", policy_id), - params=params, - headers=headers, - body=body, - ) + __path = "/_slm/status" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) - @query_params() - async def get_status(self, params=None, headers=None): + @_rewrite_parameters( + body_fields=True, + ) + async def put_lifecycle( + self, + *, + policy_id: Any, + config: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + name: Optional[Any] = None, + pretty: Optional[bool] = None, + repository: Optional[str] = None, + retention: Optional[Any] = None, + schedule: Optional[Any] = None, + timeout: Optional[Any] = None, + ) -> Any: """ - Retrieves the status of snapshot lifecycle management (SLM). + Creates or updates a snapshot lifecycle policy. - ``_ + ``_ + + :param policy_id: ID for the snapshot lifecycle policy you want to create or + update. + :param config: Configuration for each snapshot created by the policy. + :param master_timeout: Period to wait for a connection to the master node. If + no response is received before the timeout expires, the request fails and + returns an error. + :param name: Name automatically assigned to each snapshot created by the policy. + Date math is supported. To prevent conflicting snapshot names, a UUID is + automatically appended to each snapshot name. + :param repository: Repository used to store snapshots created by this policy. + This repository must exist prior to the policy’s creation. You can create + a repository using the snapshot repository API. + :param retention: Retention rules used to retain and delete snapshots created + by the policy. + :param schedule: Periodic or absolute schedule at which the policy creates snapshots. + SLM applies schedule changes immediately. + :param timeout: Period to wait for a response. If no response is received before + the timeout expires, the request fails and returns an error. """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", "/_slm/status", params=params, headers=headers + if policy_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'policy_id'") + __path = f"/_slm/policy/{_quote(policy_id)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if config is not None: + __body["config"] = config + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if name is not None: + __body["name"] = name + if pretty is not None: + __query["pretty"] = pretty + if repository is not None: + __body["repository"] = repository + if retention is not None: + __body["retention"] = retention + if schedule is not None: + __body["schedule"] = schedule + if timeout is not None: + __query["timeout"] = timeout + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "PUT", __target, headers=__headers, body=__body ) - @query_params() - async def start(self, params=None, headers=None): + @_rewrite_parameters() + async def start( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Turns on snapshot lifecycle management (SLM). - ``_ + ``_ """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "POST", "/_slm/start", params=params, headers=headers - ) + __path = "/_slm/start" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) - @query_params() - async def stop(self, params=None, headers=None): + @_rewrite_parameters() + async def stop( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Turns off snapshot lifecycle management (SLM). - ``_ + ``_ """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "POST", "/_slm/stop", params=params, headers=headers - ) + __path = "/_slm/stop" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) diff --git a/elasticsearch/_async/client/slm.pyi b/elasticsearch/_async/client/slm.pyi deleted file mode 100644 index 01dc447af..000000000 --- a/elasticsearch/_async/client/slm.pyi +++ /dev/null @@ -1,173 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class SlmClient(NamespacedClient): - async def delete_lifecycle( - self, - policy_id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def execute_lifecycle( - self, - policy_id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def execute_retention( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_lifecycle( - self, - *, - policy_id: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_stats( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def put_lifecycle( - self, - policy_id: Any, - *, - body: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_status( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def start( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def stop( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_async/client/snapshot.py b/elasticsearch/_async/client/snapshot.py index 39af4ac1e..1a3425edd 100644 --- a/elasticsearch/_async/client/snapshot.py +++ b/elasticsearch/_async/client/snapshot.py @@ -15,348 +15,682 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params +from .utils import SKIP_IN_PATH, _quote, _quote_query, _rewrite_parameters class SnapshotClient(NamespacedClient): - @query_params("master_timeout", "wait_for_completion") - 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 - :arg body: The snapshot definition - :arg master_timeout: Explicit operation timeout for connection - to master node - :arg wait_for_completion: Should this request wait until the - operation has completed before returning - """ - client, params = _deprecated_options(self, params) - for param in (repository, snapshot): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "PUT", - _make_path("_snapshot", repository, snapshot), - params=params, - headers=headers, - body=body, - ) - - @query_params("master_timeout") - async def delete(self, repository, snapshot, params=None, headers=None): + @_rewrite_parameters() + async def cleanup_repository( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ - Deletes one or more snapshots. + Removes stale data from repository. - ``_ + ``_ - :arg repository: A repository name - :arg snapshot: A comma-separated list of snapshot names - :arg master_timeout: Explicit operation timeout for connection - to master node + :param name: A repository name + :param master_timeout: Explicit operation timeout for connection to master node + :param timeout: Explicit operation timeout """ - client, params = _deprecated_options(self, params) - for param in (repository, snapshot): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "DELETE", - _make_path("_snapshot", repository, snapshot), - params=params, - headers=headers, - ) - - @query_params( - "ignore_unavailable", - "include_repository", - "index_details", - "master_timeout", - "verbose", + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_snapshot/{_quote(name)}/_cleanup" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, ) - async def get(self, repository, snapshot, params=None, headers=None): + async def clone( + self, + *, + repository: Any, + snapshot: Any, + target_snapshot: Any, + indices: str, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ - Returns information about a snapshot. + Clones indices from one snapshot into another snapshot in the same repository. ``_ - :arg repository: A repository name - :arg snapshot: A comma-separated list of snapshot names - :arg ignore_unavailable: Whether to ignore unavailable - snapshots, defaults to false which means a SnapshotMissingException is - thrown - :arg include_repository: Whether to include the repository name - in the snapshot info. Defaults to true. - :arg index_details: Whether to include details of each index in - the snapshot, if those details are available. Defaults to false. - :arg master_timeout: Explicit operation timeout for connection - to master node - :arg verbose: Whether to show verbose snapshot info or only show - the basic info found in the repository index blob + :param repository: A repository name + :param snapshot: The name of the snapshot to clone from + :param target_snapshot: The name of the cloned snapshot to create + :param indices: + :param master_timeout: Explicit operation timeout for connection to master node + :param timeout: """ - client, params = _deprecated_options(self, params) - for param in (repository, snapshot): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "GET", - _make_path("_snapshot", repository, snapshot), - params=params, - headers=headers, + if repository in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'repository'") + if snapshot in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'snapshot'") + if target_snapshot in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'target_snapshot'") + if indices is None: + raise ValueError("Empty value passed for parameter 'indices'") + __path = f"/_snapshot/{_quote(repository)}/{_quote(snapshot)}/_clone/{_quote(target_snapshot)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if indices is not None: + __body["indices"] = indices + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "PUT", __target, headers=__headers, body=__body ) - @query_params("master_timeout", "timeout") - async def delete_repository(self, repository, params=None, headers=None): + @_rewrite_parameters( + body_fields=True, + ) + async def create( + self, + *, + repository: Any, + snapshot: Any, + error_trace: Optional[bool] = None, + feature_states: Optional[List[str]] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + include_global_state: Optional[bool] = None, + indices: Optional[Any] = None, + master_timeout: Optional[Any] = None, + metadata: Optional[Any] = None, + partial: Optional[bool] = None, + pretty: Optional[bool] = None, + wait_for_completion: Optional[bool] = None, + ) -> Any: """ - Deletes a repository. + Creates a snapshot in a repository. ``_ - :arg repository: Name of the snapshot repository to unregister. - Wildcard (`*`) patterns are supported. - :arg master_timeout: Explicit operation timeout for connection - to master node - :arg timeout: Explicit operation timeout + :param repository: Repository for the snapshot. + :param snapshot: Name of the snapshot. Must be unique in the repository. + :param feature_states: Feature states to include in the snapshot. Each feature + state includes one or more system indices containing related data. You can + view a list of eligible features using the get features API. If `include_global_state` + is `true`, all current feature states are included by default. If `include_global_state` + is `false`, no feature states are included by default. + :param ignore_unavailable: If `true`, the request ignores data streams and indices + in `indices` that are missing or closed. If `false`, the request returns + an error for any data stream or index that is missing or closed. + :param include_global_state: If `true`, the current cluster state is included + in the snapshot. The cluster state includes persistent cluster settings, + composable index templates, legacy index templates, ingest pipelines, and + ILM policies. It also includes data stored in system indices, such as Watches + and task records (configurable via `feature_states`). + :param indices: Data streams and indices to include in the snapshot. Supports + multi-target syntax. Includes all data streams and indices by default. + :param master_timeout: Period to wait for a connection to the master node. If + no response is received before the timeout expires, the request fails and + returns an error. + :param metadata: Optional metadata for the snapshot. May have any contents. Must + be less than 1024 bytes. This map is not automatically generated by Elasticsearch. + :param partial: If `true`, allows restoring a partial snapshot of indices with + unavailable shards. Only shards that were successfully included in the snapshot + will be restored. All missing shards will be recreated as empty. If `false`, + the entire restore operation will fail if one or more indices included in + the snapshot do not have all primary shards available. + :param wait_for_completion: If `true`, the request returns a response when the + snapshot is complete. If `false`, the request returns a response when the + snapshot initializes. """ - client, params = _deprecated_options(self, params) if repository in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'repository'.") - - return await client._perform_request( - "DELETE", - _make_path("_snapshot", repository), - params=params, - headers=headers, + raise ValueError("Empty value passed for parameter 'repository'") + if snapshot in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'snapshot'") + __path = f"/_snapshot/{_quote(repository)}/{_quote(snapshot)}" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if feature_states is not None: + __body["feature_states"] = feature_states + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __body["ignore_unavailable"] = ignore_unavailable + if include_global_state is not None: + __body["include_global_state"] = include_global_state + if indices is not None: + __body["indices"] = indices + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if metadata is not None: + __body["metadata"] = metadata + if partial is not None: + __body["partial"] = partial + if pretty is not None: + __query["pretty"] = pretty + if wait_for_completion is not None: + __query["wait_for_completion"] = wait_for_completion + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "PUT", __target, headers=__headers, body=__body ) - @query_params("local", "master_timeout") - async def get_repository(self, repository=None, params=None, headers=None): + @_rewrite_parameters( + body_fields=True, + ) + async def create_repository( + self, + *, + name: Any, + settings: Any, + type: str, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + repository: Optional[Any] = None, + timeout: Optional[Any] = None, + verify: Optional[bool] = None, + ) -> Any: """ - Returns information about a repository. + Creates a repository. ``_ - :arg repository: A comma-separated list of repository names - :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 + :param name: A repository name + :param settings: + :param type: + :param master_timeout: Explicit operation timeout for connection to master node + :param repository: + :param timeout: Explicit operation timeout + :param verify: Whether to verify the repository after creation """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", _make_path("_snapshot", repository), params=params, headers=headers + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + if settings is None: + raise ValueError("Empty value passed for parameter 'settings'") + if type is None: + raise ValueError("Empty value passed for parameter 'type'") + __path = f"/_snapshot/{_quote(name)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if settings is not None: + __body["settings"] = settings + if type is not None: + __body["type"] = type + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if repository is not None: + __body["repository"] = repository + if timeout is not None: + __query["timeout"] = timeout + if verify is not None: + __query["verify"] = verify + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "PUT", __target, headers=__headers, body=__body ) - @query_params("master_timeout", "timeout", "verify") - async def create_repository(self, repository, body, params=None, headers=None): + @_rewrite_parameters() + async def delete( + self, + *, + repository: Any, + snapshot: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Creates a repository. + Deletes one or more snapshots. ``_ - :arg repository: A repository name - :arg body: The repository definition - :arg master_timeout: Explicit operation timeout for connection - to master node - :arg timeout: Explicit operation timeout - :arg verify: Whether to verify the repository after creation + :param repository: A repository name + :param snapshot: A comma-separated list of snapshot names + :param master_timeout: Explicit operation timeout for connection to master node """ - client, params = _deprecated_options(self, params) - for param in (repository, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "PUT", - _make_path("_snapshot", repository), - params=params, - headers=headers, - body=body, - ) - - @query_params("master_timeout", "wait_for_completion") - async def restore(self, repository, snapshot, body=None, params=None, headers=None): + if repository in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'repository'") + if snapshot in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'snapshot'") + __path = f"/_snapshot/{_quote(repository)}/{_quote(snapshot)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + async def delete_repository( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ - Restores a snapshot. + Deletes a repository. ``_ - :arg repository: A repository name - :arg snapshot: A snapshot name - :arg body: Details of what to restore - :arg master_timeout: Explicit operation timeout for connection - to master node - :arg wait_for_completion: Should this request wait until the - operation has completed before returning + :param name: Name of the snapshot repository to unregister. Wildcard (`*`) patterns + are supported. + :param master_timeout: Explicit operation timeout for connection to master node + :param timeout: Explicit operation timeout """ - client, params = _deprecated_options(self, params) - for param in (repository, snapshot): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "POST", - _make_path("_snapshot", repository, snapshot, "_restore"), - params=params, - headers=headers, - body=body, - ) - - @query_params("ignore_unavailable", "master_timeout") - async def status(self, repository=None, snapshot=None, params=None, headers=None): + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_snapshot/{_quote(name)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + async def get( + self, + *, + repository: Any, + snapshot: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + include_repository: Optional[bool] = None, + index_details: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + verbose: Optional[bool] = None, + ) -> Any: """ - Returns information about the status of a snapshot. + Returns information about a snapshot. ``_ - :arg repository: A repository name - :arg snapshot: A comma-separated list of snapshot names - :arg ignore_unavailable: Whether to ignore unavailable - snapshots, defaults to false which means a SnapshotMissingException is - thrown - :arg master_timeout: Explicit operation timeout for connection - to master node + :param repository: Comma-separated list of snapshot repository names used to + limit the request. Wildcard (*) expressions are supported. + :param snapshot: Comma-separated list of snapshot names to retrieve. Also accepts + wildcards (*). - To get information about all snapshots in a registered repository, + use a wildcard (*) or _all. - To get information about any snapshots that + are currently running, use _current. + :param ignore_unavailable: If false, the request returns an error for any snapshots + that are unavailable. + :param include_repository: Whether to include the repository name in the snapshot + info. Defaults to true. + :param index_details: If true, returns additional information about each index + in the snapshot comprising the number of shards in the index, the total size + of the index in bytes, and the maximum number of segments per shard in the + index. Defaults to false, meaning that this information is omitted. + :param master_timeout: Period to wait for a connection to the master node. If + no response is received before the timeout expires, the request fails and + returns an error. + :param verbose: If true, returns additional information about each snapshot such + as the version of Elasticsearch which took the snapshot, the start and end + times of the snapshot, and the number of shards snapshotted. """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", - _make_path("_snapshot", repository, snapshot, "_status"), - params=params, - headers=headers, - ) - - @query_params("master_timeout", "timeout") - async def verify_repository(self, repository, params=None, headers=None): + if repository in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'repository'") + if snapshot in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'snapshot'") + __path = f"/_snapshot/{_quote(repository)}/{_quote(snapshot)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if include_repository is not None: + __query["include_repository"] = include_repository + if index_details is not None: + __query["index_details"] = index_details + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if verbose is not None: + __query["verbose"] = verbose + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def get_repository( + self, + *, + name: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Verifies a repository. + Returns information about a repository. ``_ - :arg repository: A repository name - :arg master_timeout: Explicit operation timeout for connection - to master node - :arg timeout: Explicit operation timeout + :param name: A comma-separated list of repository names + :param local: Return local information, do not retrieve the state from master + node (default: false) + :param master_timeout: Explicit operation timeout for connection to master node """ - client, params = _deprecated_options(self, params) - if repository in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'repository'.") - - return await client._perform_request( - "POST", - _make_path("_snapshot", repository, "_verify"), - params=params, - headers=headers, - ) - - @query_params("master_timeout", "timeout") - async def cleanup_repository(self, repository, params=None, headers=None): + if name not in SKIP_IN_PATH: + __path = f"/_snapshot/{_quote(name)}" + else: + __path = "/_snapshot" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + async def restore( + self, + *, + repository: Any, + snapshot: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_index_settings: Optional[List[str]] = None, + ignore_unavailable: Optional[bool] = None, + include_aliases: Optional[bool] = None, + include_global_state: Optional[bool] = None, + index_settings: Optional[Any] = None, + indices: Optional[Any] = None, + master_timeout: Optional[Any] = None, + partial: Optional[bool] = None, + pretty: Optional[bool] = None, + rename_pattern: Optional[str] = None, + rename_replacement: Optional[str] = None, + wait_for_completion: Optional[bool] = None, + ) -> Any: """ - Removes stale data from repository. + Restores a snapshot. - ``_ + ``_ - :arg repository: A repository name - :arg master_timeout: Explicit operation timeout for connection - to master node - :arg timeout: Explicit operation timeout + :param repository: A repository name + :param snapshot: A snapshot name + :param ignore_index_settings: + :param ignore_unavailable: + :param include_aliases: + :param include_global_state: + :param index_settings: + :param indices: + :param master_timeout: Explicit operation timeout for connection to master node + :param partial: + :param rename_pattern: + :param rename_replacement: + :param wait_for_completion: Should this request wait until the operation has + completed before returning """ - client, params = _deprecated_options(self, params) if repository in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'repository'.") - - return await client._perform_request( - "POST", - _make_path("_snapshot", repository, "_cleanup"), - params=params, - headers=headers, + raise ValueError("Empty value passed for parameter 'repository'") + if snapshot in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'snapshot'") + __path = f"/_snapshot/{_quote(repository)}/{_quote(snapshot)}/_restore" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_index_settings is not None: + __body["ignore_index_settings"] = ignore_index_settings + if ignore_unavailable is not None: + __body["ignore_unavailable"] = ignore_unavailable + if include_aliases is not None: + __body["include_aliases"] = include_aliases + if include_global_state is not None: + __body["include_global_state"] = include_global_state + if index_settings is not None: + __body["index_settings"] = index_settings + if indices is not None: + __body["indices"] = indices + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if partial is not None: + __body["partial"] = partial + if pretty is not None: + __query["pretty"] = pretty + if rename_pattern is not None: + __body["rename_pattern"] = rename_pattern + if rename_replacement is not None: + __body["rename_replacement"] = rename_replacement + if wait_for_completion is not None: + __query["wait_for_completion"] = wait_for_completion + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "POST", __target, headers=__headers, body=__body ) - @query_params("master_timeout") - async def clone( - self, repository, snapshot, target_snapshot, body, params=None, headers=None - ): + @_rewrite_parameters() + async def status( + self, + *, + repository: Optional[Any] = None, + snapshot: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Clones indices from one snapshot into another snapshot in the same repository. + Returns information about the status of a snapshot. ``_ - :arg repository: A repository name - :arg snapshot: The name of the snapshot to clone from - :arg target_snapshot: The name of the cloned snapshot to create - :arg body: The snapshot clone definition - :arg master_timeout: Explicit operation timeout for connection - to master node + :param repository: A repository name + :param snapshot: A comma-separated list of snapshot names + :param ignore_unavailable: Whether to ignore unavailable snapshots, defaults + to false which means a SnapshotMissingException is thrown + :param master_timeout: Explicit operation timeout for connection to master node """ - client, params = _deprecated_options(self, params) - for param in (repository, snapshot, target_snapshot, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "PUT", - _make_path("_snapshot", repository, snapshot, "_clone", target_snapshot), - params=params, - headers=headers, - body=body, - ) - - @query_params( - "blob_count", - "concurrency", - "detailed", - "early_read_node_count", - "max_blob_size", - "max_total_data_size", - "rare_action_probability", - "rarely_abort_writes", - "read_node_count", - "seed", - "timeout", - ) - async def repository_analyze(self, repository, params=None, headers=None): + if repository not in SKIP_IN_PATH and snapshot not in SKIP_IN_PATH: + __path = f"/_snapshot/{_quote(repository)}/{_quote(snapshot)}/_status" + elif repository not in SKIP_IN_PATH: + __path = f"/_snapshot/{_quote(repository)}/_status" + else: + __path = "/_snapshot/_status" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def verify_repository( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ - Analyzes a repository for correctness and performance + Verifies a repository. ``_ - :arg repository: A repository name - :arg blob_count: Number of blobs to create during the test. - Defaults to 100. - :arg concurrency: Number of operations to run concurrently - during the test. Defaults to 10. - :arg detailed: Whether to return detailed results or a summary. - Defaults to 'false' so that only the summary is returned. - :arg early_read_node_count: Number of nodes on which to perform - an early read on a blob, i.e. before writing has completed. Early reads - are rare actions so the 'rare_action_probability' parameter is also - relevant. Defaults to 2. - :arg max_blob_size: Maximum size of a blob to create during the - test, e.g '1gb' or '100mb'. Defaults to '10mb'. - :arg max_total_data_size: Maximum total size of all blobs to - create during the test, e.g '1tb' or '100gb'. Defaults to '1gb'. - :arg rare_action_probability: Probability of taking a rare - action such as an early read or an overwrite. Defaults to 0.02. - :arg rarely_abort_writes: Whether to rarely abort writes before - they complete. Defaults to 'true'. - :arg read_node_count: Number of nodes on which to read a blob - after writing. Defaults to 10. - :arg seed: Seed for the random number generator used to create - the test workload. Defaults to a random value. - :arg timeout: Explicit operation timeout. Defaults to '30s'. + :param name: A repository name + :param master_timeout: Explicit operation timeout for connection to master node + :param timeout: Explicit operation timeout """ - client, params = _deprecated_options(self, params) - if repository in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'repository'.") - - return await client._perform_request( - "POST", - _make_path("_snapshot", repository, "_analyze"), - params=params, - headers=headers, - ) + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_snapshot/{_quote(name)}/_verify" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) diff --git a/elasticsearch/_async/client/snapshot.pyi b/elasticsearch/_async/client/snapshot.pyi deleted file mode 100644 index 435ddf94d..000000000 --- a/elasticsearch/_async/client/snapshot.pyi +++ /dev/null @@ -1,274 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class SnapshotClient(NamespacedClient): - async def create( - self, - repository: Any, - snapshot: Any, - *, - body: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - wait_for_completion: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def delete( - self, - repository: Any, - snapshot: Any, - *, - master_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get( - self, - repository: Any, - snapshot: Any, - *, - ignore_unavailable: Optional[Any] = ..., - include_repository: Optional[Any] = ..., - index_details: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - verbose: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def delete_repository( - self, - repository: Any, - *, - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_repository( - self, - *, - repository: Optional[Any] = ..., - local: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def create_repository( - self, - repository: Any, - *, - body: Any, - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - verify: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def restore( - self, - repository: Any, - snapshot: Any, - *, - body: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - wait_for_completion: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def status( - self, - *, - repository: Optional[Any] = ..., - snapshot: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def verify_repository( - self, - repository: Any, - *, - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def cleanup_repository( - self, - repository: Any, - *, - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def clone( - self, - repository: Any, - snapshot: Any, - target_snapshot: Any, - *, - body: Any, - master_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def repository_analyze( - self, - repository: Any, - *, - blob_count: Optional[Any] = ..., - concurrency: Optional[Any] = ..., - detailed: Optional[Any] = ..., - early_read_node_count: Optional[Any] = ..., - max_blob_size: Optional[Any] = ..., - max_total_data_size: Optional[Any] = ..., - rare_action_probability: Optional[Any] = ..., - rarely_abort_writes: Optional[Any] = ..., - read_node_count: Optional[Any] = ..., - seed: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_async/client/sql.py b/elasticsearch/_async/client/sql.py index 2e925679c..27c67ed0b 100644 --- a/elasticsearch/_async/client/sql.py +++ b/elasticsearch/_async/client/sql.py @@ -15,128 +15,189 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params +from .utils import _quote_query, _rewrite_parameters class SqlClient(NamespacedClient): - @query_params() - async def clear_cursor(self, body, params=None, headers=None): + @_rewrite_parameters( + body_fields=True, + ) + async def clear_cursor( + self, + *, + cursor: str, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Clears the SQL cursor - ``_ + ``_ - :arg body: Specify the cursor value in the `cursor` element to - clean the cursor. + :param cursor: """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return await client._perform_request( - "POST", "/_sql/close", params=params, headers=headers, body=body + if cursor is None: + raise ValueError("Empty value passed for parameter 'cursor'") + __path = "/_sql/close" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if cursor is not None: + __body["cursor"] = cursor + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "POST", __target, headers=__headers, body=__body ) - @query_params("format") - async def query(self, body, params=None, headers=None): + @_rewrite_parameters( + body_fields=True, + ignore_deprecated_options={"request_timeout"}, + ) + async def query( + self, + *, + columnar: Optional[bool] = None, + cursor: Optional[str] = None, + error_trace: Optional[bool] = None, + fetch_size: Optional[int] = None, + field_multi_value_leniency: Optional[bool] = None, + filter: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + human: Optional[bool] = None, + page_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + query: Optional[str] = None, + request_timeout: Optional[Any] = None, + time_zone: Optional[str] = None, + ) -> Any: """ Executes a SQL request - ``_ - - :arg body: Use the `query` element to start a query. Use the - `cursor` element to continue a query. - :arg format: a short version of the Accept header, e.g. json, - yaml + ``_ + + :param columnar: + :param cursor: + :param fetch_size: The maximum number of rows (or entries) to return in one response + :param field_multi_value_leniency: Throw an exception when encountering multiple + values for a field (default) or be lenient and return the first value from + the list (without any guarantees of what that will be - typically the first + in natural ascending order). + :param filter: Optional Elasticsearch query DSL for additional filtering. + :param format: a short version of the Accept header, e.g. json, yaml + :param page_timeout: The timeout before a pagination request fails. + :param query: SQL query to execute + :param request_timeout: The timeout before the request fails. + :param time_zone: Time-zone in ISO 8601 used for executing the query on the server. + More information available here. """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return await client._perform_request( - "POST", "/_sql", params=params, headers=headers, body=body + __path = "/_sql" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if columnar is not None: + __body["columnar"] = columnar + if cursor is not None: + __body["cursor"] = cursor + if error_trace is not None: + __query["error_trace"] = error_trace + if fetch_size is not None: + __body["fetch_size"] = fetch_size + if field_multi_value_leniency is not None: + __body["field_multi_value_leniency"] = field_multi_value_leniency + if filter is not None: + __body["filter"] = filter + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if human is not None: + __query["human"] = human + if page_timeout is not None: + __body["page_timeout"] = page_timeout + if pretty is not None: + __query["pretty"] = pretty + if query is not None: + __body["query"] = query + if request_timeout is not None: + __body["request_timeout"] = request_timeout + if time_zone is not None: + __body["time_zone"] = time_zone + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "POST", __target, headers=__headers, body=__body ) - @query_params() - async def translate(self, body, params=None, headers=None): + @_rewrite_parameters( + body_fields=True, + ) + async def translate( + self, + *, + query: str, + error_trace: Optional[bool] = None, + fetch_size: Optional[int] = None, + filter: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + time_zone: Optional[str] = None, + ) -> Any: """ Translates SQL into Elasticsearch queries - ``_ - - :arg body: Specify the query in the `query` element. - """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return await client._perform_request( - "POST", "/_sql/translate", params=params, headers=headers, body=body - ) - - @query_params() - async def delete_async(self, id, params=None, headers=None): - """ - Deletes an async SQL search or a stored synchronous SQL search. If the search - is still running, the API cancels it. - - ``_ - - :arg id: The async search ID - """ - client, params = _deprecated_options(self, params) - if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'id'.") - - return await client._perform_request( - "DELETE", - _make_path("_sql", "async", "delete", id), - params=params, - headers=headers, - ) + ``_ - @query_params("delimiter", "format", "keep_alive", "wait_for_completion_timeout") - async def get_async(self, id, params=None, headers=None): + :param query: + :param fetch_size: + :param filter: + :param time_zone: """ - Returns the current status and available results for an async SQL search or - stored synchronous SQL search - - ``_ - - :arg id: The async search ID - :arg delimiter: Separator for CSV results Default: , - :arg format: Short version of the Accept header, e.g. json, yaml - :arg keep_alive: Retention period for the search and its results - Default: 5d - :arg wait_for_completion_timeout: Duration to wait for complete - results - """ - client, params = _deprecated_options(self, params) - if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'id'.") - - return await client._perform_request( - "GET", _make_path("_sql", "async", id), params=params, headers=headers - ) - - @query_params() - async def get_async_status(self, id, params=None, headers=None): - """ - Returns the current status of an async SQL search or a stored synchronous SQL - search - - ``_ - - :arg id: The async search ID - """ - client, params = _deprecated_options(self, params) - if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'id'.") - - return await client._perform_request( - "GET", - _make_path("_sql", "async", "status", id), - params=params, - headers=headers, + if query is None: + raise ValueError("Empty value passed for parameter 'query'") + __path = "/_sql/translate" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if query is not None: + __body["query"] = query + if error_trace is not None: + __query["error_trace"] = error_trace + if fetch_size is not None: + __body["fetch_size"] = fetch_size + if filter is not None: + __body["filter"] = filter + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if time_zone is not None: + __body["time_zone"] = time_zone + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "POST", __target, headers=__headers, body=__body ) diff --git a/elasticsearch/_async/client/sql.pyi b/elasticsearch/_async/client/sql.pyi deleted file mode 100644 index d9f0dc5dd..000000000 --- a/elasticsearch/_async/client/sql.pyi +++ /dev/null @@ -1,129 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class SqlClient(NamespacedClient): - async def clear_cursor( - self, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def query( - self, - *, - body: Any, - format: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def translate( - self, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def delete_async( - self, - id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_async( - self, - id: Any, - *, - delimiter: Optional[Any] = ..., - format: Optional[Any] = ..., - keep_alive: Optional[Any] = ..., - wait_for_completion_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_async_status( - self, - id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_async/client/ssl.py b/elasticsearch/_async/client/ssl.py index 9a07bb24f..68eedfa0a 100644 --- a/elasticsearch/_async/client/ssl.py +++ b/elasticsearch/_async/client/ssl.py @@ -15,20 +15,41 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import _deprecated_options, query_params +from .utils import _quote_query, _rewrite_parameters class SslClient(NamespacedClient): - @query_params() - async def certificates(self, params=None, headers=None): + @_rewrite_parameters() + async def certificates( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Retrieves information about the X.509 certificates used to encrypt - communications in the cluster. + Retrieves information about the X.509 certificates used to encrypt communications + in the cluster. - ``_ + ``_ """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", "/_ssl/certificates", params=params, headers=headers - ) + __path = "/_ssl/certificates" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) diff --git a/elasticsearch/_async/client/ssl.pyi b/elasticsearch/_async/client/ssl.pyi deleted file mode 100644 index b3a8007f1..000000000 --- a/elasticsearch/_async/client/ssl.pyi +++ /dev/null @@ -1,40 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class SslClient(NamespacedClient): - async def certificates( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_async/client/tasks.py b/elasticsearch/_async/client/tasks.py index de823875d..ee650df58 100644 --- a/elasticsearch/_async/client/tasks.py +++ b/elasticsearch/_async/client/tasks.py @@ -15,105 +15,177 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params +from .utils import SKIP_IN_PATH, _quote, _quote_query, _rewrite_parameters class TasksClient(NamespacedClient): - @query_params( - "actions", - "detailed", - "group_by", - "nodes", - "parent_task_id", - "timeout", - "wait_for_completion", - ) - async def list(self, params=None, headers=None): + @_rewrite_parameters() + async def cancel( + self, + *, + task_id: Optional[Any] = None, + actions: Optional[Union[List[str], str]] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + nodes: Optional[List[str]] = None, + parent_task_id: Optional[str] = None, + pretty: Optional[bool] = None, + wait_for_completion: Optional[bool] = None, + ) -> Any: """ - Returns a list of tasks. + Cancels a task, if it can be cancelled through an API. ``_ - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - - :arg actions: A comma-separated list of actions that should be - returned. Leave empty to return all. - :arg detailed: Return detailed task information (default: false) - :arg group_by: Group tasks by nodes or parent/child - relationships Valid choices: nodes, parents, none Default: nodes - :arg nodes: 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 parent_task_id: Return tasks with specified parent task id - (node_id:task_number). Set to -1 to return all. - :arg timeout: Explicit operation timeout - :arg wait_for_completion: Wait for the matching tasks to - complete (default: false) + :param task_id: Cancel the task with specified task id (node_id:task_number) + :param actions: A comma-separated list of actions that should be cancelled. Leave + empty to cancel all. + :param nodes: 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 + :param parent_task_id: Cancel tasks with specified parent task id (node_id:task_number). + Set to -1 to cancel all. + :param wait_for_completion: Should the request block until the cancellation of + the task and its descendant tasks is completed. Defaults to false """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", "/_tasks", params=params, headers=headers - ) - - @query_params("actions", "nodes", "parent_task_id", "wait_for_completion") - async def cancel(self, task_id=None, params=None, headers=None): + if task_id not in SKIP_IN_PATH: + __path = f"/_tasks/{_quote(task_id)}/_cancel" + else: + __path = "/_tasks/_cancel" + __query: Dict[str, Any] = {} + if actions is not None: + __query["actions"] = actions + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if nodes is not None: + __query["nodes"] = nodes + if parent_task_id is not None: + __query["parent_task_id"] = parent_task_id + if pretty is not None: + __query["pretty"] = pretty + if wait_for_completion is not None: + __query["wait_for_completion"] = wait_for_completion + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters() + async def get( + self, + *, + task_id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + wait_for_completion: Optional[bool] = None, + ) -> Any: """ - Cancels a task, if it can be cancelled through an API. + Returns information about a task. ``_ - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - - :arg task_id: Cancel the task with specified task id - (node_id:task_number) - :arg actions: A comma-separated list of actions that should be - cancelled. Leave empty to cancel all. - :arg nodes: 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 parent_task_id: Cancel tasks with specified parent task id - (node_id:task_number). Set to -1 to cancel all. - :arg wait_for_completion: Should the request block until the - cancellation of the task and its descendant tasks is completed. Defaults - to false + :param task_id: Return the task with specified id (node_id:task_number) + :param timeout: Explicit operation timeout + :param wait_for_completion: Wait for the matching tasks to complete (default: + false) """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "POST", - _make_path("_tasks", task_id, "_cancel"), - params=params, - headers=headers, - ) - - @query_params("timeout", "wait_for_completion") - async def get(self, task_id, params=None, headers=None): + if task_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'task_id'") + __path = f"/_tasks/{_quote(task_id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if wait_for_completion is not None: + __query["wait_for_completion"] = wait_for_completion + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def list( + self, + *, + actions: Optional[Union[List[str], str]] = None, + detailed: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + group_by: Optional[Any] = None, + human: Optional[bool] = None, + nodes: Optional[List[str]] = None, + parent_task_id: Optional[Any] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + wait_for_completion: Optional[bool] = None, + ) -> Any: """ - Returns information about a task. + Returns a list of tasks. ``_ - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - - :arg task_id: Return the task with specified id - (node_id:task_number) - :arg timeout: Explicit operation timeout - :arg wait_for_completion: Wait for the matching tasks to - complete (default: false) + :param actions: A comma-separated list of actions that should be returned. Leave + empty to return all. + :param detailed: Return detailed task information (default: false) + :param group_by: Group tasks by nodes or parent/child relationships + :param nodes: 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 + :param parent_task_id: Return tasks with specified parent task id (node_id:task_number). + Set to -1 to return all. + :param timeout: Explicit operation timeout + :param wait_for_completion: Wait for the matching tasks to complete (default: + false) """ - client, params = _deprecated_options(self, params) - if task_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'task_id'.") - - return await client._perform_request( - "GET", _make_path("_tasks", task_id), params=params, headers=headers - ) + __path = "/_tasks" + __query: Dict[str, Any] = {} + if actions is not None: + __query["actions"] = actions + if detailed is not None: + __query["detailed"] = detailed + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if group_by is not None: + __query["group_by"] = group_by + if human is not None: + __query["human"] = human + if nodes is not None: + __query["nodes"] = nodes + if parent_task_id is not None: + __query["parent_task_id"] = parent_task_id + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if wait_for_completion is not None: + __query["wait_for_completion"] = wait_for_completion + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) diff --git a/elasticsearch/_async/client/tasks.pyi b/elasticsearch/_async/client/tasks.pyi deleted file mode 100644 index 5873aa585..000000000 --- a/elasticsearch/_async/client/tasks.pyi +++ /dev/null @@ -1,87 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class TasksClient(NamespacedClient): - async def list( - self, - *, - actions: Optional[Any] = ..., - detailed: Optional[Any] = ..., - group_by: Optional[Any] = ..., - nodes: Optional[Any] = ..., - parent_task_id: Optional[Any] = ..., - timeout: Optional[Any] = ..., - wait_for_completion: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def cancel( - self, - *, - task_id: Optional[Any] = ..., - actions: Optional[Any] = ..., - nodes: Optional[Any] = ..., - parent_task_id: Optional[Any] = ..., - wait_for_completion: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get( - self, - task_id: Any, - *, - timeout: Optional[Any] = ..., - wait_for_completion: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_async/client/text_structure.py b/elasticsearch/_async/client/text_structure.py index bbe3dcb37..1c6150c40 100644 --- a/elasticsearch/_async/client/text_structure.py +++ b/elasticsearch/_async/client/text_structure.py @@ -15,76 +15,146 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, query_params +from .utils import _quote_query, _rewrite_parameters class TextStructureClient(NamespacedClient): - @query_params( - "charset", - "column_names", - "delimiter", - "explain", - "format", - "grok_pattern", - "has_header_row", - "line_merge_size_limit", - "lines_to_sample", - "quote", - "should_trim_fields", - "timeout", - "timestamp_field", - "timestamp_format", + @_rewrite_parameters( + body_name="text_files", ) - async def find_structure(self, body, params=None, headers=None): + async def find_structure( + self, + *, + text_files: List[Any], + charset: Optional[str] = None, + column_names: Optional[str] = None, + delimiter: Optional[str] = None, + explain: Optional[bool] = None, + format: Optional[str] = None, + grok_pattern: Optional[str] = None, + has_header_row: Optional[bool] = None, + line_merge_size_limit: Optional[int] = None, + lines_to_sample: Optional[int] = None, + quote: Optional[str] = None, + should_trim_fields: Optional[bool] = None, + timeout: Optional[Any] = None, + timestamp_field: Optional[Any] = None, + timestamp_format: Optional[str] = None, + ) -> Any: """ - Finds the structure of a text file. The text file must contain data that is - suitable to be ingested into Elasticsearch. + 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 + :param text_files: + :param charset: The text’s character set. It must be a character set that is + supported by the JVM that Elasticsearch uses. For example, UTF-8, UTF-16LE, + windows-1252, or EUC-JP. If this parameter is not specified, the structure + finder chooses an appropriate character set. + :param column_names: If you have set format to delimited, you can specify the + column names in a comma-separated list. If this parameter is not specified, + the structure finder uses the column names from the header row of the text. + If the text does not have a header role, columns are named "column1", "column2", + "column3", etc. + :param delimiter: If you have set format to delimited, you can specify the character + used to delimit the values in each row. Only a single character is supported; + the delimiter cannot have multiple characters. By default, the API considers + the following possibilities: comma, tab, semi-colon, and pipe (|). In this + default scenario, all rows must have the same number of fields for the delimited + format to be detected. If you specify a delimiter, up to 10% of the rows + can have a different number of columns than the first row. + :param explain: If this parameter is set to true, the response includes a field + named explanation, which is an array of strings that indicate how the structure + finder produced its result. + :param format: The high level structure of the text. Valid values are ndjson, + xml, delimited, and semi_structured_text. By default, the API chooses the + format. In this default scenario, all rows must have the same number of fields + for a delimited format to be detected. If the format is set to delimited + and the delimiter is not set, however, the API tolerates up to 5% of rows + that have a different number of columns than the first row. + :param grok_pattern: If you have set format to semi_structured_text, you can + specify a Grok pattern that is used to extract fields from every message + in the text. The name of the timestamp field in the Grok pattern must match + what is specified in the timestamp_field parameter. If that parameter is + not specified, the name of the timestamp field in the Grok pattern must match + "timestamp". If grok_pattern is not specified, the structure finder creates + a Grok pattern. + :param has_header_row: If you have set format to delimited, you can use this + parameter to indicate whether the column names are in the first row of the + text. If this parameter is not specified, the structure finder guesses based + on the similarity of the first row of the text to other rows. + :param line_merge_size_limit: The maximum number of characters in a message when + lines are merged to form messages while analyzing semi-structured text. If + you have extremely long messages you may need to increase this, but be aware + that this may lead to very long processing times if the way to group lines + into messages is misdetected. + :param lines_to_sample: The number of lines to include in the structural analysis, + starting from the beginning of the text. The minimum is 2; If the value of + this parameter is greater than the number of lines in the text, the analysis + proceeds (as long as there are at least two lines in the text) for all of + the lines. + :param quote: If you have set format to delimited, you can specify the character + used to quote the values in each row if they contain newlines or the delimiter + character. Only a single character is supported. If this parameter is not + specified, the default value is a double quote ("). If your delimited text + format does not use quoting, a workaround is to set this argument to a character + that does not appear anywhere in the sample. + :param should_trim_fields: If you have set format to delimited, you can specify + whether values between delimiters should have whitespace trimmed from them. + If this parameter is not specified and the delimiter is pipe (|), the default + value is true. Otherwise, the default value is false. + :param timeout: Sets the maximum amount of time that the structure analysis make + take. If the analysis is still running when the timeout expires then it will + be aborted. + :param timestamp_field: Optional parameter to specify the timestamp field in the file - :arg column_names: Optional parameter containing a comma - separated list of the column names for a delimited file - :arg delimiter: Optional parameter to specify the delimiter - character for a delimited file - must be a single character - :arg explain: Whether to include a commentary on how the - structure was derived - :arg format: Optional parameter to specify the high level file - format Valid choices: ndjson, xml, delimited, semi_structured_text - :arg grok_pattern: Optional parameter to specify the Grok - pattern that should be used to extract fields from messages in a semi- - structured text file - :arg has_header_row: Optional parameter to specify whether a - delimited file includes the column names in its first row - :arg line_merge_size_limit: Maximum number of characters - permitted in a single message when lines are merged to create messages. - Default: 10000 - :arg lines_to_sample: How many lines of the file should be - included in the analysis Default: 1000 - :arg quote: Optional parameter to specify the quote character - for a delimited file - must be a single character - :arg should_trim_fields: Optional parameter to specify whether - the values between delimiters in a delimited file should have whitespace - trimmed from them - :arg timeout: Timeout after which the analysis will be aborted - Default: 25s - :arg timestamp_field: Optional parameter to specify the - timestamp field in the file - :arg timestamp_format: Optional parameter to specify the - timestamp format in the file - may be either a Joda or Java time format + :param timestamp_format: The Java time format of the timestamp field in the text. """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - headers["content-type"] = "application/x-ndjson" - return await client._perform_request( - "POST", - "/_text_structure/find_structure", - params=params, - headers=headers, - body=body, + if text_files is None: + raise ValueError("Empty value passed for parameter 'text_files'") + __path = "/_text_structure/find_structure" + __query: Dict[str, Any] = {} + if charset is not None: + __query["charset"] = charset + if column_names is not None: + __query["column_names"] = column_names + if delimiter is not None: + __query["delimiter"] = delimiter + if explain is not None: + __query["explain"] = explain + if format is not None: + __query["format"] = format + if grok_pattern is not None: + __query["grok_pattern"] = grok_pattern + if has_header_row is not None: + __query["has_header_row"] = has_header_row + if line_merge_size_limit is not None: + __query["line_merge_size_limit"] = line_merge_size_limit + if lines_to_sample is not None: + __query["lines_to_sample"] = lines_to_sample + if quote is not None: + __query["quote"] = quote + if should_trim_fields is not None: + __query["should_trim_fields"] = should_trim_fields + if timeout is not None: + __query["timeout"] = timeout + if timestamp_field is not None: + __query["timestamp_field"] = timestamp_field + if timestamp_format is not None: + __query["timestamp_format"] = timestamp_format + __body = text_files + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = { + "accept": "application/json", + "content-type": "application/x-ndjson", + } + return await self._perform_request( + "POST", __target, headers=__headers, body=__body ) diff --git a/elasticsearch/_async/client/text_structure.pyi b/elasticsearch/_async/client/text_structure.pyi deleted file mode 100644 index dff334ae3..000000000 --- a/elasticsearch/_async/client/text_structure.pyi +++ /dev/null @@ -1,54 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class TextStructureClient(NamespacedClient): - async def find_structure( - self, - *, - body: Any, - charset: Optional[Any] = ..., - column_names: Optional[Any] = ..., - delimiter: Optional[Any] = ..., - explain: Optional[Any] = ..., - format: Optional[Any] = ..., - grok_pattern: Optional[Any] = ..., - has_header_row: Optional[Any] = ..., - line_merge_size_limit: Optional[Any] = ..., - lines_to_sample: Optional[Any] = ..., - quote: Optional[Any] = ..., - should_trim_fields: Optional[Any] = ..., - timeout: Optional[Any] = ..., - timestamp_field: Optional[Any] = ..., - timestamp_format: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_async/client/transform.py b/elasticsearch/_async/client/transform.py index ee1023d00..f99a6022e 100644 --- a/elasticsearch/_async/client/transform.py +++ b/elasticsearch/_async/client/transform.py @@ -15,243 +15,529 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params +from .utils import SKIP_IN_PATH, _quote, _quote_query, _rewrite_parameters class TransformClient(NamespacedClient): - @query_params("force") - async def delete_transform(self, transform_id, params=None, headers=None): + @_rewrite_parameters() + async def delete_transform( + self, + *, + transform_id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + force: Optional[bool] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Deletes an existing transform. - ``_ + ``_ - :arg transform_id: The id of the transform to delete - :arg force: When `true`, the transform is deleted regardless of - its current state. The default value is `false`, meaning that the - transform must be `stopped` before it can be deleted. + :param transform_id: The id of the transform to delete + :param force: When `true`, the transform is deleted regardless of its current + state. The default value is `false`, meaning that the transform must be `stopped` + before it can be deleted. """ - client, params = _deprecated_options(self, params) if transform_id in SKIP_IN_PATH: - raise ValueError( - "Empty value passed for a required argument 'transform_id'." - ) - - return await client._perform_request( - "DELETE", - _make_path("_transform", transform_id), - params=params, - headers=headers, - ) - - @query_params("allow_no_match", "exclude_generated", "from_", "size") - async def get_transform(self, transform_id=None, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'transform_id'") + __path = f"/_transform/{_quote(transform_id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if force is not None: + __query["force"] = force + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters( + parameter_aliases={"from": "from_"}, + ) + async def get_transform( + self, + *, + transform_id: Optional[Any] = None, + allow_no_match: Optional[bool] = None, + error_trace: Optional[bool] = None, + exclude_generated: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + from_: Optional[int] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + size: Optional[int] = None, + ) -> Any: """ 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 - 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 exclude_generated: Omits fields that are illegal to set on - transform PUT - :arg from\\_: skips a number of transform configs, defaults to 0 - :arg size: specifies a max number of transforms to get, defaults - to 100 + :param transform_id: The id or comma delimited list of id expressions of the + transforms to get, '_all' or '*' implies get all transforms + :param allow_no_match: Whether to ignore if a wildcard expression matches no + transforms. (This includes `_all` string or when no transforms have been + specified) + :param exclude_generated: Omits fields that are illegal to set on transform PUT + :param from_: skips a number of transform configs, defaults to 0 + :param size: specifies a max number of transforms to get, defaults to 100 """ - client, params = _deprecated_options(self, params) - if params and "from_" in params: - params["from"] = params.pop("from_") - - return await client._perform_request( - "GET", - _make_path("_transform", transform_id), - params=params, - headers=headers, - ) - - @query_params("allow_no_match", "from_", "size") - async def get_transform_stats(self, transform_id, params=None, headers=None): + if transform_id not in SKIP_IN_PATH: + __path = f"/_transform/{_quote(transform_id)}" + else: + __path = "/_transform" + __query: Dict[str, Any] = {} + if allow_no_match is not None: + __query["allow_no_match"] = allow_no_match + if error_trace is not None: + __query["error_trace"] = error_trace + if exclude_generated is not None: + __query["exclude_generated"] = exclude_generated + if filter_path is not None: + __query["filter_path"] = filter_path + if from_ is not None: + __query["from"] = from_ + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if size is not None: + __query["size"] = size + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + parameter_aliases={"from": "from_"}, + ) + async def get_transform_stats( + self, + *, + transform_id: Any, + allow_no_match: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + from_: Optional[int] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + size: Optional[int] = None, + ) -> Any: """ 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 size: specifies a max number of transform stats to get, - defaults to 100 + :param transform_id: The id of the transform for which to get stats. '_all' or + '*' implies all transforms + :param allow_no_match: Whether to ignore if a wildcard expression matches no + transforms. (This includes `_all` string or when no transforms have been + specified) + :param from_: skips a number of transform stats, defaults to 0 + :param size: specifies a max number of transform stats to get, defaults to 100 """ - client, params = _deprecated_options(self, params) - if params and "from_" in params: - params["from"] = params.pop("from_") - if transform_id in SKIP_IN_PATH: - raise ValueError( - "Empty value passed for a required argument 'transform_id'." - ) - - return await client._perform_request( - "GET", - _make_path("_transform", transform_id, "_stats"), - params=params, - headers=headers, - ) - - @query_params() + raise ValueError("Empty value passed for parameter 'transform_id'") + __path = f"/_transform/{_quote(transform_id)}/_stats" + __query: Dict[str, Any] = {} + if allow_no_match is not None: + __query["allow_no_match"] = allow_no_match + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if from_ is not None: + __query["from"] = from_ + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if size is not None: + __query["size"] = size + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) async def preview_transform( - self, body=None, transform_id=None, params=None, headers=None - ): + self, + *, + transform_id: Optional[Any] = None, + description: Optional[str] = None, + dest: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + frequency: Optional[Any] = None, + human: Optional[bool] = None, + latest: Optional[Any] = None, + pivot: Optional[Any] = None, + pretty: Optional[bool] = None, + retention_policy: Optional[Any] = None, + settings: Optional[Any] = None, + source: Optional[Any] = None, + sync: Optional[Any] = None, + ) -> Any: """ Previews a transform. - ``_ - - :arg body: The definition for the transform to preview - :arg transform_id: The id of the transform to preview. + ``_ + + :param transform_id: The id of the transform to preview. + :param description: Free text description of the transform. + :param dest: The destination for the transform. + :param frequency: The interval between checks for changes in the source indices + when the transform is running continuously. Also determines the retry interval + in the event of transient failures while the transform is searching or indexing. + The minimum value is 1s and the maximum is 1h. + :param latest: The latest method transforms the data by finding the latest document + for each unique key. + :param pivot: The pivot method transforms the data by aggregating and grouping + it. These objects define the group by fields and the aggregation to reduce + the data. + :param retention_policy: Defines a retention policy for the transform. Data that + meets the defined criteria is deleted from the destination index. + :param settings: Defines optional transform settings. + :param source: The source of the data for the transform. + :param sync: Defines the properties transforms require to run continuously. """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "POST", - _make_path("_transform", transform_id, "_preview"), - params=params, - headers=headers, - body=body, + if transform_id not in SKIP_IN_PATH: + __path = f"/_transform/{_quote(transform_id)}/_preview" + else: + __path = "/_transform/_preview" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if description is not None: + __body["description"] = description + if dest is not None: + __body["dest"] = dest + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if frequency is not None: + __body["frequency"] = frequency + if human is not None: + __query["human"] = human + if latest is not None: + __body["latest"] = latest + if pivot is not None: + __body["pivot"] = pivot + if pretty is not None: + __query["pretty"] = pretty + if retention_policy is not None: + __body["retention_policy"] = retention_policy + if settings is not None: + __body["settings"] = settings + if source is not None: + __body["source"] = source + if sync is not None: + __body["sync"] = sync + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "POST", __target, headers=__headers, body=__body ) - @query_params("defer_validation") - async def put_transform(self, transform_id, body, params=None, headers=None): + @_rewrite_parameters( + body_fields=True, + ) + async def put_transform( + self, + *, + transform_id: Any, + dest: Any, + source: Any, + defer_validation: Optional[bool] = None, + description: Optional[str] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + frequency: Optional[Any] = None, + human: Optional[bool] = None, + latest: Optional[Any] = None, + pivot: Optional[Any] = None, + pretty: Optional[bool] = None, + retention_policy: Optional[Any] = None, + settings: Optional[Any] = None, + sync: Optional[Any] = None, + ) -> Any: """ Instantiates a transform. - ``_ - - :arg transform_id: The id of the new transform. - :arg body: The transform definition - :arg defer_validation: If validations should be deferred until - transform starts, defaults to false. + ``_ + + :param transform_id: Identifier for the transform. This identifier can contain + lowercase alphanumeric characters (a-z and 0-9), hyphens, and underscores. + It must start and end with alphanumeric characters. + :param dest: The destination for the transform. + :param source: The source of the data for the transform. + :param defer_validation: When true, deferrable validations are not run. This + behavior may be desired if the source index does not exist until after the + transform is created. + :param description: Free text description of the transform. + :param frequency: The interval between checks for changes in the source indices + when the transform is running continuously. Also determines the retry interval + in the event of transient failures while the transform is searching or indexing. + The minimum value is 1s and the maximum is 1h. + :param latest: The latest method transforms the data by finding the latest document + for each unique key. + :param pivot: The pivot method transforms the data by aggregating and grouping + it. These objects define the group by fields and the aggregation to reduce + the data. + :param retention_policy: Defines a retention policy for the transform. Data that + meets the defined criteria is deleted from the destination index. + :param settings: Defines optional transform settings. + :param sync: Defines the properties transforms require to run continuously. """ - client, params = _deprecated_options(self, params) - for param in (transform_id, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "PUT", - _make_path("_transform", transform_id), - params=params, - headers=headers, - body=body, + if transform_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'transform_id'") + if dest is None: + raise ValueError("Empty value passed for parameter 'dest'") + if source is None: + raise ValueError("Empty value passed for parameter 'source'") + __path = f"/_transform/{_quote(transform_id)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if dest is not None: + __body["dest"] = dest + if source is not None: + __body["source"] = source + if defer_validation is not None: + __query["defer_validation"] = defer_validation + if description is not None: + __body["description"] = description + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if frequency is not None: + __body["frequency"] = frequency + if human is not None: + __query["human"] = human + if latest is not None: + __body["latest"] = latest + if pivot is not None: + __body["pivot"] = pivot + if pretty is not None: + __query["pretty"] = pretty + if retention_policy is not None: + __body["retention_policy"] = retention_policy + if settings is not None: + __body["settings"] = settings + if sync is not None: + __body["sync"] = sync + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "PUT", __target, headers=__headers, body=__body ) - @query_params("timeout") - async def start_transform(self, transform_id, params=None, headers=None): + @_rewrite_parameters() + async def start_transform( + self, + *, + transform_id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ 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 - start + :param transform_id: The id of the transform to start + :param timeout: Controls the time to wait for the transform to start """ - client, params = _deprecated_options(self, params) if transform_id in SKIP_IN_PATH: - raise ValueError( - "Empty value passed for a required argument 'transform_id'." - ) - - return await client._perform_request( - "POST", - _make_path("_transform", transform_id, "_start"), - params=params, - headers=headers, - ) - - @query_params( - "allow_no_match", - "force", - "timeout", - "wait_for_checkpoint", - "wait_for_completion", - ) - async def stop_transform(self, transform_id, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'transform_id'") + __path = f"/_transform/{_quote(transform_id)}/_start" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters() + async def stop_transform( + self, + *, + transform_id: Any, + allow_no_match: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + force: Optional[bool] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + wait_for_checkpoint: Optional[bool] = None, + wait_for_completion: Optional[bool] = None, + ) -> Any: """ 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 - matches no transforms. (This includes `_all` string or when no - transforms have been specified) - :arg force: Whether to force stop a failed transform or not. - Default to false - :arg timeout: Controls the time to wait until the transform has - stopped. Default to 30 seconds - :arg wait_for_checkpoint: Whether to wait for the transform to - reach a checkpoint before stopping. Default to false - :arg wait_for_completion: Whether to wait for the transform to - fully stop before returning or not. Default to false + ``_ + + :param transform_id: The id of the transform to stop + :param allow_no_match: Whether to ignore if a wildcard expression matches no + transforms. (This includes `_all` string or when no transforms have been + specified) + :param force: Whether to force stop a failed transform or not. Default to false + :param timeout: Controls the time to wait until the transform has stopped. Default + to 30 seconds + :param wait_for_checkpoint: Whether to wait for the transform to reach a checkpoint + before stopping. Default to false + :param wait_for_completion: Whether to wait for the transform to fully stop before + returning or not. Default to false """ - client, params = _deprecated_options(self, params) if transform_id in SKIP_IN_PATH: - raise ValueError( - "Empty value passed for a required argument 'transform_id'." - ) - - return await client._perform_request( - "POST", - _make_path("_transform", transform_id, "_stop"), - params=params, - headers=headers, - ) - - @query_params("defer_validation") - async def update_transform(self, transform_id, body, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'transform_id'") + __path = f"/_transform/{_quote(transform_id)}/_stop" + __query: Dict[str, Any] = {} + if allow_no_match is not None: + __query["allow_no_match"] = allow_no_match + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if force is not None: + __query["force"] = force + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if wait_for_checkpoint is not None: + __query["wait_for_checkpoint"] = wait_for_checkpoint + if wait_for_completion is not None: + __query["wait_for_completion"] = wait_for_completion + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + async def update_transform( + self, + *, + transform_id: Any, + defer_validation: Optional[bool] = None, + description: Optional[str] = None, + dest: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + frequency: Optional[Any] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + retention_policy: Optional[Any] = None, + settings: Optional[Any] = None, + source: Optional[Any] = None, + sync: Optional[Any] = None, + ) -> Any: """ Updates certain properties of a transform. - ``_ - - :arg transform_id: The id of the transform. - :arg body: The update transform definition - :arg defer_validation: If validations should be deferred until - transform starts, defaults to false. - """ - client, params = _deprecated_options(self, params) - for param in (transform_id, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return await client._perform_request( - "POST", - _make_path("_transform", transform_id, "_update"), - params=params, - headers=headers, - body=body, - ) - - @query_params("dry_run") - async def upgrade_transforms(self, params=None, headers=None): + ``_ + + :param transform_id: Identifier for the transform. This identifier can contain + lowercase alphanumeric characters (a-z and 0-9), hyphens, and underscores. + It must start and end with alphanumeric characters. + :param defer_validation: When true, deferrable validations are not run. This + behavior may be desired if the source index does not exist until after the + transform is created. + :param description: Free text description of the transform. + :param dest: The destination for the transform. + :param frequency: The interval between checks for changes in the source indices + when the transform is running continuously. Also determines the retry interval + in the event of transient failures while the transform is searching or indexing. + The minimum value is 1s and the maximum is 1h. + :param retention_policy: Defines a retention policy for the transform. Data that + meets the defined criteria is deleted from the destination index. + :param settings: Defines optional transform settings. + :param source: The source of the data for the transform. + :param sync: Defines the properties transforms require to run continuously. """ - Upgrades all transforms. - - ``_ - - :arg dry_run: Whether to only check for updates but don't - execute - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "POST", "/_transform/_upgrade", params=params, headers=headers + if transform_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'transform_id'") + __path = f"/_transform/{_quote(transform_id)}/_update" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if defer_validation is not None: + __query["defer_validation"] = defer_validation + if description is not None: + __body["description"] = description + if dest is not None: + __body["dest"] = dest + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if frequency is not None: + __body["frequency"] = frequency + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if retention_policy is not None: + __body["retention_policy"] = retention_policy + if settings is not None: + __body["settings"] = settings + if source is not None: + __body["source"] = source + if sync is not None: + __body["sync"] = sync + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "POST", __target, headers=__headers, body=__body ) diff --git a/elasticsearch/_async/client/transform.pyi b/elasticsearch/_async/client/transform.pyi deleted file mode 100644 index 9cd3f2c9a..000000000 --- a/elasticsearch/_async/client/transform.pyi +++ /dev/null @@ -1,196 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class TransformClient(NamespacedClient): - async def delete_transform( - self, - transform_id: Any, - *, - force: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_transform( - self, - *, - transform_id: Optional[Any] = ..., - allow_no_match: Optional[Any] = ..., - exclude_generated: Optional[Any] = ..., - from_: Optional[Any] = ..., - size: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_transform_stats( - self, - transform_id: Any, - *, - allow_no_match: Optional[Any] = ..., - from_: Optional[Any] = ..., - size: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def preview_transform( - self, - *, - body: Optional[Any] = ..., - transform_id: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def put_transform( - self, - transform_id: Any, - *, - body: Any, - defer_validation: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def start_transform( - self, - transform_id: Any, - *, - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def stop_transform( - self, - transform_id: Any, - *, - allow_no_match: Optional[Any] = ..., - force: Optional[Any] = ..., - timeout: Optional[Any] = ..., - wait_for_checkpoint: Optional[Any] = ..., - wait_for_completion: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def update_transform( - self, - transform_id: Any, - *, - body: Any, - defer_validation: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def upgrade_transforms( - self, - *, - dry_run: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_async/client/utils.py b/elasticsearch/_async/client/utils.py index d62f1f8ef..f14b81fbd 100644 --- a/elasticsearch/_async/client/utils.py +++ b/elasticsearch/_async/client/utils.py @@ -21,24 +21,20 @@ CLIENT_META_SERVICE, SKIP_IN_PATH, _base64_auth_header, - _bulk_body, - _deprecated_options, - _escape, - _make_path, + _quote, + _quote_query, + _rewrite_parameters, client_node_configs, - query_params, ) __all__ = [ "CLIENT_META_SERVICE", "_TYPE_ASYNC_SNIFF_CALLBACK", - "_deprecated_options", + "_base64_auth_header", + "_quote", + "_quote_query", "_TYPE_HOSTS", "SKIP_IN_PATH", - "_bulk_body", - "_escape", - "_make_path", - "query_params", "client_node_configs", - "_base64_auth_header", + "_rewrite_parameters", ] diff --git a/elasticsearch/_async/client/watcher.py b/elasticsearch/_async/client/watcher.py index 129fe03b7..25bcb2ecc 100644 --- a/elasticsearch/_async/client/watcher.py +++ b/elasticsearch/_async/client/watcher.py @@ -15,218 +15,531 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params +from .utils import SKIP_IN_PATH, _quote, _quote_query, _rewrite_parameters class WatcherClient(NamespacedClient): - @query_params() - async def ack_watch(self, watch_id, action_id=None, params=None, headers=None): + @_rewrite_parameters() + async def ack_watch( + self, + *, + watch_id: Any, + action_id: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ 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 - acked + :param watch_id: Watch ID + :param action_id: A comma-separated list of the action ids to be acked """ - client, params = _deprecated_options(self, params) if watch_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'watch_id'.") - - return await client._perform_request( - "PUT", - _make_path("_watcher", "watch", watch_id, "_ack", action_id), - params=params, - headers=headers, - ) - - @query_params() - async def activate_watch(self, watch_id, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'watch_id'") + if watch_id not in SKIP_IN_PATH and action_id not in SKIP_IN_PATH: + __path = f"/_watcher/watch/{_quote(watch_id)}/_ack/{_quote(action_id)}" + elif watch_id not in SKIP_IN_PATH: + __path = f"/_watcher/watch/{_quote(watch_id)}/_ack" + else: + raise ValueError("Couldn't find a path for the given parameters") + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("PUT", __target, headers=__headers) + + @_rewrite_parameters() + async def activate_watch( + self, + *, + watch_id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Activates a currently inactive watch. - ``_ + ``_ - :arg watch_id: Watch ID + :param watch_id: Watch ID """ - client, params = _deprecated_options(self, params) if watch_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'watch_id'.") - - return await client._perform_request( - "PUT", - _make_path("_watcher", "watch", watch_id, "_activate"), - params=params, - headers=headers, - ) - - @query_params() - async def deactivate_watch(self, watch_id, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'watch_id'") + __path = f"/_watcher/watch/{_quote(watch_id)}/_activate" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("PUT", __target, headers=__headers) + + @_rewrite_parameters() + async def deactivate_watch( + self, + *, + watch_id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Deactivates a currently active watch. - ``_ + ``_ - :arg watch_id: Watch ID + :param watch_id: Watch ID """ - client, params = _deprecated_options(self, params) if watch_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'watch_id'.") - - return await client._perform_request( - "PUT", - _make_path("_watcher", "watch", watch_id, "_deactivate"), - params=params, - headers=headers, - ) - - @query_params() - async def delete_watch(self, id, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'watch_id'") + __path = f"/_watcher/watch/{_quote(watch_id)}/_deactivate" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("PUT", __target, headers=__headers) + + @_rewrite_parameters() + async def delete_watch( + self, + *, + id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Removes a watch from Watcher. - ``_ + ``_ - :arg id: Watch ID + :param id: Watch ID """ - client, params = _deprecated_options(self, params) if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'id'.") - - return await client._perform_request( - "DELETE", - _make_path("_watcher", "watch", id), - params=params, - headers=headers, - ) - - @query_params("debug") - async def execute_watch(self, body=None, id=None, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/_watcher/watch/{_quote(id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + async def execute_watch( + self, + *, + id: Optional[Any] = None, + action_modes: Optional[Dict[str, Any]] = None, + alternative_input: Optional[Dict[str, Any]] = None, + debug: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_condition: Optional[bool] = None, + pretty: Optional[bool] = None, + record_execution: Optional[bool] = None, + simulated_actions: Optional[Any] = None, + trigger_data: Optional[Any] = None, + watch: Optional[Any] = None, + ) -> Any: """ 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 + ``_ + + :param id: Watch ID + :param action_modes: + :param alternative_input: + :param debug: indicates whether the watch should execute in debug mode + :param ignore_condition: + :param record_execution: + :param simulated_actions: + :param trigger_data: + :param watch: """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "PUT", - _make_path("_watcher", "watch", id, "_execute"), - params=params, - headers=headers, - body=body, + if id not in SKIP_IN_PATH: + __path = f"/_watcher/watch/{_quote(id)}/_execute" + else: + __path = "/_watcher/watch/_execute" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if action_modes is not None: + __body["action_modes"] = action_modes + if alternative_input is not None: + __body["alternative_input"] = alternative_input + if debug is not None: + __query["debug"] = debug + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_condition is not None: + __body["ignore_condition"] = ignore_condition + if pretty is not None: + __query["pretty"] = pretty + if record_execution is not None: + __body["record_execution"] = record_execution + if simulated_actions is not None: + __body["simulated_actions"] = simulated_actions + if trigger_data is not None: + __body["trigger_data"] = trigger_data + if watch is not None: + __body["watch"] = watch + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "PUT", __target, headers=__headers, body=__body ) - @query_params() - async def get_watch(self, id, params=None, headers=None): + @_rewrite_parameters() + async def get_watch( + self, + *, + id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Retrieves a watch by its ID. - ``_ + ``_ - :arg id: Watch ID + :param id: Watch ID """ - client, params = _deprecated_options(self, params) if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'id'.") + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/_watcher/watch/{_quote(id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + async def put_watch( + self, + *, + id: Any, + actions: Optional[Dict[str, Any]] = None, + active: Optional[bool] = None, + condition: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + if_primary_term: Optional[int] = None, + if_sequence_number: Optional[int] = None, + input: Optional[Any] = None, + metadata: Optional[Any] = None, + pretty: Optional[bool] = None, + throttle_period: Optional[str] = None, + transform: Optional[Any] = None, + trigger: Optional[Any] = None, + version: Optional[Any] = None, + ) -> Any: + """ + Creates a new watch, or updates an existing one. - return await client._perform_request( - "GET", _make_path("_watcher", "watch", id), params=params, headers=headers + ``_ + + :param id: Watch ID + :param actions: + :param active: Specify whether the watch is in/active by default + :param condition: + :param if_primary_term: only update the watch if the last operation that has + changed the watch has the specified primary term + :param if_sequence_number: + :param input: + :param metadata: + :param throttle_period: + :param transform: + :param trigger: + :param version: Explicit version number for concurrency control + """ + if id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/_watcher/watch/{_quote(id)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if actions is not None: + __body["actions"] = actions + if active is not None: + __query["active"] = active + if condition is not None: + __body["condition"] = condition + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if if_primary_term is not None: + __query["if_primary_term"] = if_primary_term + if if_sequence_number is not None: + __query["if_sequence_number"] = if_sequence_number + if input is not None: + __body["input"] = input + if metadata is not None: + __body["metadata"] = metadata + if pretty is not None: + __query["pretty"] = pretty + if throttle_period is not None: + __body["throttle_period"] = throttle_period + if transform is not None: + __body["transform"] = transform + if trigger is not None: + __body["trigger"] = trigger + if version is not None: + __query["version"] = version + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "PUT", __target, headers=__headers, body=__body ) - @query_params("active", "if_primary_term", "if_seq_no", "version") - async def put_watch(self, id, body=None, params=None, headers=None): + @_rewrite_parameters( + body_fields=True, + parameter_aliases={"from": "from_"}, + ) + async def query_watches( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + from_: Optional[int] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + query: Optional[Any] = None, + search_after: Optional[Any] = None, + size: Optional[int] = None, + sort: Optional[Any] = None, + ) -> Any: """ - Creates a new watch, or updates an existing one. + Retrieves stored watches. - ``_ + ``_ - :arg id: Watch ID - :arg body: The watch - :arg active: Specify whether the watch is in/active by default - :arg if_primary_term: only update the watch if the last - operation that has changed the watch has the specified primary term - :arg if_seq_no: only update the watch if the last operation that - has changed the watch has the specified sequence number - :arg version: Explicit version number for concurrency control + :param from_: The offset from the first result to fetch. Needs to be non-negative. + :param query: Optional, query filter watches to be returned. + :param search_after: Optional search After to do pagination using last hit’s + sort values. + :param size: The number of hits to return. Needs to be non-negative. + :param sort: Optional sort definition. """ - client, params = _deprecated_options(self, params) - if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'id'.") - - return await client._perform_request( - "PUT", - _make_path("_watcher", "watch", id), - params=params, - headers=headers, - body=body, + __path = "/_watcher/_query/watches" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if from_ is not None: + __body["from"] = from_ + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if query is not None: + __body["query"] = query + if search_after is not None: + __body["search_after"] = search_after + if size is not None: + __body["size"] = size + if sort is not None: + __body["sort"] = sort + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return await self._perform_request( + "POST", __target, headers=__headers, body=__body ) - @query_params() - async def start(self, params=None, headers=None): + @_rewrite_parameters() + async def start( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Starts Watcher if it is not already running. - ``_ + ``_ """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "POST", "/_watcher/_start", params=params, headers=headers - ) - - @query_params("emit_stacktraces") - async def stats(self, metric=None, params=None, headers=None): + __path = "/_watcher/_start" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters() + async def stats( + self, + *, + metric: Optional[Union[Any, List[Any]]] = None, + emit_stacktraces: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Retrieves the current Watcher metrics. - ``_ + ``_ - :arg metric: Controls what additional stat metrics should be - include in the response Valid choices: _all, queued_watches, - current_watches, pending_watches - :arg emit_stacktraces: Emits stack traces of currently running - watches + :param metric: Defines which additional metrics are included in the response. + :param emit_stacktraces: Defines whether stack traces are generated for each + watch that is running. """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", - _make_path("_watcher", "stats", metric), - params=params, - headers=headers, - ) - - @query_params() - async def stop(self, params=None, headers=None): + if metric not in SKIP_IN_PATH: + __path = f"/_watcher/stats/{_quote(metric)}" + else: + __path = "/_watcher/stats" + __query: Dict[str, Any] = {} + if emit_stacktraces is not None: + __query["emit_stacktraces"] = emit_stacktraces + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + async def stop( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Stops Watcher if it is running. - ``_ + ``_ """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "POST", "/_watcher/_stop", params=params, headers=headers - ) - - @query_params() - async def query_watches(self, body=None, params=None, headers=None): - """ - Retrieves stored watches. - - ``_ - - :arg body: From, size, query, sort and search_after - """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "POST", - "/_watcher/_query/watches", - params=params, - headers=headers, - body=body, - ) + __path = "/_watcher/_stop" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("POST", __target, headers=__headers) diff --git a/elasticsearch/_async/client/watcher.pyi b/elasticsearch/_async/client/watcher.pyi deleted file mode 100644 index 88ba22279..000000000 --- a/elasticsearch/_async/client/watcher.pyi +++ /dev/null @@ -1,218 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class WatcherClient(NamespacedClient): - async def ack_watch( - self, - watch_id: Any, - *, - action_id: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def activate_watch( - self, - watch_id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def deactivate_watch( - self, - watch_id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def delete_watch( - self, - id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def execute_watch( - self, - *, - body: Optional[Any] = ..., - id: Optional[Any] = ..., - debug: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def get_watch( - self, - id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def put_watch( - self, - id: Any, - *, - body: Optional[Any] = ..., - active: Optional[Any] = ..., - if_primary_term: Optional[Any] = ..., - if_seq_no: Optional[Any] = ..., - version: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def start( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def stats( - self, - *, - metric: Optional[Any] = ..., - emit_stacktraces: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def stop( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def query_watches( - self, - *, - body: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_async/client/xpack.py b/elasticsearch/_async/client/xpack.py index 0cef1c5c6..f46fe4503 100644 --- a/elasticsearch/_async/client/xpack.py +++ b/elasticsearch/_async/client/xpack.py @@ -15,42 +15,87 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import _deprecated_options, query_params +from .utils import _quote_query, _rewrite_parameters class XPackClient(NamespacedClient): - def __getattr__(self, attr_name): + def __getattr__(self, attr_name: str) -> Any: return getattr(self.client, attr_name) # AUTO-GENERATED-API-DEFINITIONS # - @query_params("accept_enterprise", "categories") - async def info(self, params=None, headers=None): + + @_rewrite_parameters() + async def info( + self, + *, + categories: Optional[List[str]] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Retrieves information about the installed X-Pack features. - ``_ + ``_ - :arg accept_enterprise: If this param is used it must be set to - true - :arg categories: Comma-separated list of info categories. Can be - any of: build, license, features + :param categories: Comma-separated list of info categories. Can be any of: build, + license, features """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", "/_xpack", params=params, headers=headers - ) + __path = "/_xpack" + __query: Dict[str, Any] = {} + if categories is not None: + __query["categories"] = categories + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) - @query_params("master_timeout") - async def usage(self, params=None, headers=None): + @_rewrite_parameters() + async def usage( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Retrieves usage information about the installed X-Pack features. - ``_ + ``_ - :arg master_timeout: Specify timeout for watch write operation + :param master_timeout: Specify timeout for watch write operation """ - client, params = _deprecated_options(self, params) - return await client._perform_request( - "GET", "/_xpack/usage", params=params, headers=headers - ) + __path = "/_xpack/usage" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return await self._perform_request("GET", __target, headers=__headers) diff --git a/elasticsearch/_async/client/xpack.pyi b/elasticsearch/_async/client/xpack.pyi deleted file mode 100644 index ea1e7ae87..000000000 --- a/elasticsearch/_async/client/xpack.pyi +++ /dev/null @@ -1,62 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class XPackClient(NamespacedClient): - def __getattr__(self, attr_name: str) -> Any: - return getattr(self.client, attr_name) - # AUTO-GENERATED-API-DEFINITIONS # - async def info( - self, - *, - accept_enterprise: Optional[Any] = ..., - categories: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - async def usage( - self, - *, - master_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_async/compat.py b/elasticsearch/_async/compat.py deleted file mode 100644 index 6c8aa8565..000000000 --- a/elasticsearch/_async/compat.py +++ /dev/null @@ -1,38 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -import asyncio - -from ..compat import * # noqa - -# Hack supporting Python 3.6 asyncio which didn't have 'get_running_loop()'. -# Essentially we want to get away from having users pass in a loop to us. -# Instead we should call 'get_running_loop()' whenever we need -# the currently running loop. -# See: https://aiopg.readthedocs.io/en/stable/run_loop.html#implementation -try: - from asyncio import get_running_loop -except ImportError: - - def get_running_loop() -> asyncio.AbstractEventLoop: - loop = asyncio.get_event_loop() - if not loop.is_running(): - raise RuntimeError("no running event loop") - return loop - - -__all__ = ["get_running_loop"] diff --git a/elasticsearch/_async/helpers.py b/elasticsearch/_async/helpers.py index 512494510..489c9b8aa 100644 --- a/elasticsearch/_async/helpers.py +++ b/elasticsearch/_async/helpers.py @@ -482,7 +482,7 @@ async def _change_doc_index(hits, index, op_type): try: # Verify if the target_index is data stream or index data_streams = await target_client.indices.get_data_stream( - target_index, expand_wildcards="all" + name=target_index, expand_wildcards="all" ) is_data_stream = any( data_stream["name"] == target_index diff --git a/elasticsearch/_sync/client/__init__.py b/elasticsearch/_sync/client/__init__.py index 4a649afcf..9a654c10c 100644 --- a/elasticsearch/_sync/client/__init__.py +++ b/elasticsearch/_sync/client/__init__.py @@ -18,10 +18,29 @@ import logging import warnings -from typing import Any, Callable, Dict, Optional, Union +from typing import ( + Any, + Callable, + Collection, + Dict, + List, + Mapping, + Optional, + Tuple, + Type, + Union, +) -from elastic_transport import NodeConfig, Transport, TransportError -from elastic_transport.client_utils import DEFAULT +from elastic_transport import ( + BaseNode, + NodeConfig, + NodePool, + NodeSelector, + Serializer, + Transport, + TransportError, +) +from elastic_transport.client_utils import DEFAULT, DefaultType from ...serializer import DEFAULT_SERIALIZERS from ._base import ( @@ -39,7 +58,6 @@ from .enrich import EnrichClient from .eql import EqlClient from .features import FeaturesClient -from .fleet import FleetClient from .graph import GraphClient from .ilm import IlmClient from .indices import IndicesClient @@ -65,10 +83,10 @@ _TYPE_HOSTS, CLIENT_META_SERVICE, SKIP_IN_PATH, - _deprecated_options, - _make_path, + _quote, + _quote_query, + _rewrite_parameters, client_node_configs, - query_params, ) from .watcher import WatcherClient from .xpack import XPackClient @@ -116,59 +134,59 @@ def __init__( *, # API cloud_id: Optional[str] = None, - api_key=None, - basic_auth=None, - bearer_auth=None, - opaque_id=None, + api_key: Optional[Union[str, Tuple[str, str]]] = None, + basic_auth: Optional[Union[str, Tuple[str, str]]] = None, + bearer_auth: Optional[str] = None, + opaque_id: Optional[str] = None, # Node - headers=DEFAULT, - connections_per_node=DEFAULT, - http_compress=DEFAULT, - verify_certs=DEFAULT, - ca_certs=DEFAULT, - client_cert=DEFAULT, - client_key=DEFAULT, - ssl_assert_hostname=DEFAULT, - ssl_assert_fingerprint=DEFAULT, - ssl_version=DEFAULT, - ssl_context=DEFAULT, - ssl_show_warn=DEFAULT, + headers: Union[DefaultType, Mapping[str, str]] = DEFAULT, + connections_per_node: Union[DefaultType, int] = DEFAULT, + http_compress: Union[DefaultType, bool] = DEFAULT, + verify_certs: Union[DefaultType, bool] = DEFAULT, + ca_certs: Union[DefaultType, str] = DEFAULT, + client_cert: Union[DefaultType, str] = DEFAULT, + client_key: Union[DefaultType, str] = DEFAULT, + ssl_assert_hostname: Union[DefaultType, str] = DEFAULT, + ssl_assert_fingerprint: Union[DefaultType, str] = DEFAULT, + ssl_version: Union[DefaultType, int] = DEFAULT, + ssl_context: Union[DefaultType, Any] = DEFAULT, + ssl_show_warn: Union[DefaultType, bool] = DEFAULT, # Transport - transport_class=Transport, - request_timeout=DEFAULT, - node_class=DEFAULT, - node_pool_class=DEFAULT, - randomize_nodes_in_pool=DEFAULT, - node_selector_class=DEFAULT, - dead_node_backoff_factor=DEFAULT, - max_dead_node_backoff=DEFAULT, - serializers=DEFAULT, - default_mimetype="application/json", - max_retries=DEFAULT, - retry_on_status=DEFAULT, - retry_on_timeout=DEFAULT, - sniff_on_start=DEFAULT, - sniff_before_requests=DEFAULT, - sniff_on_node_failure=DEFAULT, - sniff_timeout=DEFAULT, - min_delay_between_sniffing=DEFAULT, + transport_class: Type[Transport] = Transport, + request_timeout: Union[DefaultType, None, float] = DEFAULT, + node_class: Union[DefaultType, Type[BaseNode]] = DEFAULT, + node_pool_class: Union[DefaultType, Type[NodePool]] = DEFAULT, + randomize_nodes_in_pool: Union[DefaultType, bool] = DEFAULT, + node_selector_class: Union[DefaultType, Type[NodeSelector]] = DEFAULT, + dead_node_backoff_factor: Union[DefaultType, float] = DEFAULT, + max_dead_node_backoff: Union[DefaultType, float] = DEFAULT, + serializers: Union[DefaultType, Mapping[str, Serializer]] = DEFAULT, + default_mimetype: str = "application/json", + max_retries: Union[DefaultType, int] = DEFAULT, + retry_on_status: Union[DefaultType, int, Collection[int]] = DEFAULT, + retry_on_timeout: Union[DefaultType, bool] = DEFAULT, + sniff_on_start: Union[DefaultType, bool] = DEFAULT, + sniff_before_requests: Union[DefaultType, bool] = DEFAULT, + sniff_on_node_failure: Union[DefaultType, bool] = DEFAULT, + sniff_timeout: Union[DefaultType, None, float] = DEFAULT, + min_delay_between_sniffing: Union[DefaultType, None, float] = DEFAULT, sniffed_node_callback: Optional[ Callable[[Dict[str, Any], NodeConfig], Optional[NodeConfig]] ] = None, - meta_header=DEFAULT, + meta_header: Union[DefaultType, bool] = DEFAULT, # Deprecated - timeout=DEFAULT, - randomize_hosts=DEFAULT, + timeout: Union[DefaultType, None, float] = DEFAULT, + randomize_hosts: Union[DefaultType, bool] = DEFAULT, host_info_callback: Optional[ Callable[ [Dict[str, Any], Dict[str, Union[str, int]]], Optional[Dict[str, Union[str, int]]], ] ] = None, - sniffer_timeout=DEFAULT, - sniff_on_connection_fail=DEFAULT, - http_auth=DEFAULT, - maxsize=DEFAULT, + sniffer_timeout: Union[DefaultType, None, float] = DEFAULT, + sniff_on_connection_fail: Union[DefaultType, bool] = DEFAULT, + http_auth: Union[DefaultType, Any] = DEFAULT, + maxsize: Union[DefaultType, int] = DEFAULT, # Internal use only _transport: Optional[Transport] = None, ) -> None: @@ -303,7 +321,7 @@ def __init__( ssl_context=ssl_context, ssl_show_warn=ssl_show_warn, ) - transport_kwargs = {} + transport_kwargs: Dict[str, Any] = {} if node_class is not DEFAULT: transport_kwargs["node_class"] = node_class if node_pool_class is not DEFAULT: @@ -348,15 +366,17 @@ def __init__( # These are set per-request so are stored separately. self._request_timeout = request_timeout self._max_retries = max_retries - self._retry_on_status = retry_on_status self._retry_on_timeout = retry_on_timeout + if isinstance(retry_on_status, int): + retry_on_status = (retry_on_status,) + self._retry_on_status = retry_on_status else: super().__init__(_transport) if headers is not DEFAULT and headers is not None: self._headers.update(headers) - if opaque_id is not DEFAULT and opaque_id is not None: + if opaque_id is not DEFAULT and opaque_id is not None: # type: ignore[comparison-overlap] self._headers["x-opaque-id"] = opaque_id self._headers = resolve_auth_headers( self._headers, @@ -383,7 +403,6 @@ def __init__( self.dangling_indices = DanglingIndicesClient(self) self.enrich = EnrichClient(self) self.eql = EqlClient(self) - self.fleet = FleetClient(self) self.graph = GraphClient(self) self.ilm = IlmClient(self) self.license = LicenseClient(self) @@ -402,1972 +421,3853 @@ def __init__( self.transform = TransformClient(self) self.watcher = WatcherClient(self) - def __repr__(self): + def __repr__(self) -> str: try: # get a list of all connections - cons = self.transport.hosts + nodes = [node.base_url for node in self.transport.node_pool.all()] # truncate to 5 if there are too many - if len(cons) > 5: - cons = cons[:5] + ["..."] - return f"<{self.__class__.__name__}({cons})>" + if len(nodes) > 5: + nodes = nodes[:5] + ["..."] + return f"<{self.__class__.__name__}({nodes})>" except Exception: # probably operating on custom transport and connection_pool, ignore return super().__repr__() - def __enter__(self): - if hasattr(self.transport, "_async_call"): - self.transport._async_call() + def __enter__(self) -> "Elasticsearch": + try: + # All this to avoid a Mypy error when using unasync. + getattr(self.transport, "_async_call")() + except AttributeError: + pass return self - def __exit__(self, *_): + def __exit__(self, *_: Any) -> None: self.close() - def close(self): + def close(self) -> None: """Closes the Transport and all internal connections""" self.transport.close() - # AUTO-GENERATED-API-DEFINITIONS # - @query_params() - def ping(self, params=None, headers=None): + @_rewrite_parameters() + def ping( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> bool: """ - Returns whether the cluster is running. + Returns basic information about the cluster. - ``_ + ``_ """ - client, params = _deprecated_options(self, params) + __path = "/" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} try: - client._perform_request("HEAD", "/", params=params, headers=headers) - return True + resp = self._perform_request("HEAD", __target, headers=__headers) + return bool(resp) except TransportError: return False - @query_params() - def info(self, params=None, headers=None): - """ - Returns basic information about the cluster. - - ``_ - """ - client, params = _deprecated_options(self, params) - return client._perform_request("GET", "/", params=params, headers=headers) + # AUTO-GENERATED-API-DEFINITIONS # - @query_params( - "pipeline", - "refresh", - "routing", - "timeout", - "version", - "version_type", - "wait_for_active_shards", + @_rewrite_parameters( + body_name="operations", + parameter_aliases={ + "_source": "source", + "_source_excludes": "source_excludes", + "_source_includes": "source_includes", + }, ) - def create(self, index, id, body, doc_type=None, params=None, headers=None): + def bulk( + self, + *, + operations: List[Any], + index: Optional[Any] = None, + type: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pipeline: Optional[str] = None, + pretty: Optional[bool] = None, + refresh: Optional[Any] = None, + require_alias: Optional[bool] = None, + routing: Optional[Any] = None, + source: Optional[Union[Any, bool]] = None, + source_excludes: Optional[Any] = None, + source_includes: Optional[Any] = None, + timeout: Optional[Any] = None, + wait_for_active_shards: Optional[Any] = None, + ) -> Any: """ - Creates a new document in the index. Returns a 409 response when a document - with a same ID already exists in the index. + Allows to perform multiple index/update/delete operations in a single request. - ``_ + ``_ - :arg index: The name of the index - :arg id: Document ID - :arg body: The document - :arg doc_type: The type of the document - :arg pipeline: The pipeline id to preprocess incoming documents - with - :arg refresh: If `true` then refresh the affected shards to make - this operation visible to search, if `wait_for` then wait for a refresh - to make this operation visible to search, if `false` (the default) then - do nothing with refreshes. Valid choices: true, false, wait_for - :arg routing: Specific routing value - :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 - :arg wait_for_active_shards: Sets the number of shard copies - that must be active before proceeding with the index operation. Defaults - to 1, meaning the primary shard only. Set to `all` for all shard copies, - otherwise set to any non-negative value less than or equal to the total - number of copies for the shard (number of replicas + 1) - """ - client, params = _deprecated_options(self, params) - for param in (index, id, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - if doc_type in SKIP_IN_PATH: - path = _make_path(index, "_create", id) + :param operations: + :param index: Default index for items which don't provide one + :param type: Default document type for items which don't provide one + :param pipeline: The pipeline id to preprocess incoming documents with + :param refresh: If `true` then refresh the affected shards to make this operation + visible to search, if `wait_for` then wait for a refresh to make this operation + visible to search, if `false` (the default) then do nothing with refreshes. + :param require_alias: Sets require_alias for all incoming documents. Defaults + to unset (false) + :param routing: Specific routing value + :param source: True or false to return the _source field or not, or default list + of fields to return, can be overridden on each sub-request + :param source_excludes: Default list of fields to exclude from the returned _source + field, can be overridden on each sub-request + :param source_includes: Default list of fields to extract and return from the + _source field, can be overridden on each sub-request + :param timeout: Explicit operation timeout + :param wait_for_active_shards: Sets the number of shard copies that must be active + before proceeding with the bulk operation. Defaults to 1, meaning the primary + shard only. Set to `all` for all shard copies, otherwise set to any non-negative + value less than or equal to the total number of copies for the shard (number + of replicas + 1) + """ + if operations is None: + raise ValueError("Empty value passed for parameter 'operations'") + if index not in SKIP_IN_PATH and type not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/{_quote(type)}/_bulk" + elif index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_bulk" else: - path = _make_path(index, doc_type, id, "_create") - - return client._perform_request( - "POST" if id in SKIP_IN_PATH else "PUT", - path, - params=params, - headers=headers, - body=body, - ) - - @query_params( - "if_primary_term", - "if_seq_no", - "op_type", - "pipeline", - "refresh", - "require_alias", - "routing", - "timeout", - "version", - "version_type", - "wait_for_active_shards", + __path = "/_bulk" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pipeline is not None: + __query["pipeline"] = pipeline + if pretty is not None: + __query["pretty"] = pretty + if refresh is not None: + __query["refresh"] = refresh + if require_alias is not None: + __query["require_alias"] = require_alias + if routing is not None: + __query["routing"] = routing + if source is not None: + __query["_source"] = source + if source_excludes is not None: + __query["_source_excludes"] = source_excludes + if source_includes is not None: + __query["_source_includes"] = source_includes + if timeout is not None: + __query["timeout"] = timeout + if wait_for_active_shards is not None: + __query["wait_for_active_shards"] = wait_for_active_shards + __body = operations + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = { + "accept": "application/json", + "content-type": "application/x-ndjson", + } + return self._perform_request("PUT", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, ) - def index(self, index, body, id=None, params=None, headers=None): + def clear_scroll( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + scroll_id: Optional[Any] = None, + ) -> Any: """ - Creates or updates a document in an index. - - ``_ + Explicitly clears the search context for a scroll. - :arg index: The name of the index - :arg body: 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 - term - :arg if_seq_no: only perform the index operation if the last - operation that has changed the document has the specified sequence - number - :arg op_type: Explicit operation type. Defaults to `index` for - requests with an explicit document ID, and to `create`for requests - without an explicit document ID Valid choices: index, create - :arg pipeline: The pipeline id to preprocess incoming documents - with - :arg refresh: If `true` then refresh the affected shards to make - this operation visible to search, if `wait_for` then wait for a refresh - to make this operation visible to search, if `false` (the default) then - do nothing with refreshes. Valid choices: true, false, wait_for - :arg require_alias: When true, requires destination to be an - alias. Default is false - :arg routing: Specific routing value - :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 - :arg wait_for_active_shards: Sets the number of shard copies - that must be active before proceeding with the index operation. Defaults - to 1, meaning the primary shard only. Set to `all` for all shard copies, - otherwise set to any non-negative value less than or equal to the total - number of copies for the shard (number of replicas + 1) - """ - client, params = _deprecated_options(self, params) - for param in (index, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "POST" if id in SKIP_IN_PATH else "PUT", - _make_path(index, "_doc", id), - params=params, - headers=headers, - body=body, - ) + ``_ - @query_params( - "_source", - "_source_excludes", - "_source_includes", - "pipeline", - "refresh", - "require_alias", - "routing", - "timeout", - "wait_for_active_shards", + :param scroll_id: + """ + __path = "/_search/scroll" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if scroll_id is not None: + __body["scroll_id"] = scroll_id + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("DELETE", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, ) - def bulk(self, body, index=None, doc_type=None, params=None, headers=None): + def close_point_in_time( + self, + *, + id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Allows to perform multiple index/update/delete operations in a single request. - - ``_ + Close a point in time - :arg body: The operation definition and data (action-data - pairs), separated by newlines - :arg index: Default index for items which don't provide one - :arg doc_type: Default document type for items which don't - provide one - :arg _source: True or false to return the _source field or not, - or default list of fields to return, can be overridden on each sub- - request - :arg _source_excludes: Default list of fields to exclude from - the returned _source field, can be overridden on each sub-request - :arg _source_includes: Default list of fields to extract and - return from the _source field, can be overridden on each sub-request - :arg pipeline: The pipeline id to preprocess incoming documents - with - :arg refresh: If `true` then refresh the affected shards to make - this operation visible to search, if `wait_for` then wait for a refresh - to make this operation visible to search, if `false` (the default) then - do nothing with refreshes. Valid choices: true, false, wait_for - :arg require_alias: Sets require_alias for all incoming - documents. Defaults to unset (false) - :arg routing: Specific routing value - :arg timeout: Explicit operation timeout - :arg wait_for_active_shards: Sets the number of shard copies - that must be active before proceeding with the bulk operation. Defaults - to 1, meaning the primary shard only. Set to `all` for all shard copies, - otherwise set to any non-negative value less than or equal to the total - number of copies for the shard (number of replicas + 1) - """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - headers["content-type"] = "application/x-ndjson" - return client._perform_request( - "POST", - _make_path(index, doc_type, "_bulk"), - params=params, - headers=headers, - body=body, - ) + ``_ - @query_params() - def clear_scroll(self, body=None, scroll_id=None, params=None, headers=None): + :param id: """ - 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 - :arg scroll_id: A comma-separated list of scroll IDs to clear + if id is None: + raise ValueError("Empty value passed for parameter 'id'") + __path = "/_pit" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if id is not None: + __body["id"] = id + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("DELETE", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, + ) + def count( + self, + *, + index: Optional[Any] = None, + allow_no_indices: Optional[bool] = None, + analyze_wildcard: Optional[bool] = None, + analyzer: Optional[str] = None, + default_operator: Optional[Any] = None, + df: Optional[str] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_throttled: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + lenient: Optional[bool] = None, + min_score: Optional[float] = None, + preference: Optional[str] = None, + pretty: Optional[bool] = None, + q: Optional[str] = None, + query: Optional[Any] = None, + routing: Optional[Any] = None, + terminate_after: Optional[int] = None, + ) -> Any: """ - client, params = _deprecated_options(self, params) - if scroll_id in SKIP_IN_PATH and body in SKIP_IN_PATH: - raise ValueError("You need to supply scroll_id or body.") - elif scroll_id and not body: - body = {"scroll_id": [scroll_id]} - elif scroll_id: - params["scroll_id"] = scroll_id + Returns number of documents matching a query. - return client._perform_request( - "DELETE", "/_search/scroll", params=params, headers=headers, body=body - ) + ``_ - @query_params( - "allow_no_indices", - "analyze_wildcard", - "analyzer", - "default_operator", - "df", - "expand_wildcards", - "ignore_throttled", - "ignore_unavailable", - "lenient", - "min_score", - "preference", - "q", - "routing", - "terminate_after", + :param index: A comma-separated list of indices to restrict the results + :param 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) + :param analyze_wildcard: Specify whether wildcard and prefix queries should be + analyzed (default: false) + :param analyzer: The analyzer to use for the query string + :param default_operator: The default operator for query string query (AND or + OR) + :param df: The field to use as default where no field prefix is given in the + query string + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param ignore_throttled: Whether specified concrete, expanded or aliased indices + should be ignored when throttled + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param lenient: Specify whether format-based query failures (such as providing + text to a numeric field) should be ignored + :param min_score: Include only documents with a specific `_score` value in the + result + :param preference: Specify the node or shard the operation should be performed + on (default: random) + :param q: Query in the Lucene query string syntax + :param query: + :param routing: A comma-separated list of specific routing values + :param terminate_after: The maximum count for each shard, upon reaching which + the query execution will terminate early + """ + if index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_count" + else: + __path = "/_count" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if analyze_wildcard is not None: + __query["analyze_wildcard"] = analyze_wildcard + if analyzer is not None: + __query["analyzer"] = analyzer + if default_operator is not None: + __query["default_operator"] = default_operator + if df is not None: + __query["df"] = df + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_throttled is not None: + __query["ignore_throttled"] = ignore_throttled + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if lenient is not None: + __query["lenient"] = lenient + if min_score is not None: + __query["min_score"] = min_score + if preference is not None: + __query["preference"] = preference + if pretty is not None: + __query["pretty"] = pretty + if q is not None: + __query["q"] = q + if query is not None: + __body["query"] = query + if routing is not None: + __query["routing"] = routing + if terminate_after is not None: + __query["terminate_after"] = terminate_after + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_name="document", ) - def count(self, body=None, index=None, params=None, headers=None): + def create( + self, + *, + index: Any, + id: Any, + document: Any, + type: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pipeline: Optional[str] = None, + pretty: Optional[bool] = None, + refresh: Optional[Any] = None, + routing: Optional[Any] = None, + timeout: Optional[Any] = None, + version: Optional[Any] = None, + version_type: Optional[Any] = None, + wait_for_active_shards: Optional[Any] = None, + ) -> Any: """ - Returns number of documents matching a query. + Creates a new document in the index. Returns a 409 response when a document with + a same ID already exists in the index. - ``_ + ``_ - :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 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 analyze_wildcard: Specify whether wildcard and prefix - queries should be analyzed (default: false) - :arg analyzer: The analyzer to use for the query string - :arg default_operator: The default operator for query string - query (AND or OR) Valid choices: AND, OR Default: OR - :arg df: The field to use as default where no field prefix is - given in the query string - :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_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 lenient: Specify whether format-based query failures (such - as providing text to a numeric field) should be ignored - :arg min_score: Include only documents with a specific `_score` - value in the result - :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 routing: A comma-separated list of specific routing values - :arg terminate_after: The maximum count for each shard, upon - reaching which the query execution will terminate early - """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "POST", - _make_path(index, "_count"), - params=params, - headers=headers, - body=body, - ) + :param index: The name of the index + :param id: Document ID + :param document: + :param type: The type of the document + :param pipeline: The pipeline id to preprocess incoming documents with + :param refresh: If `true` then refresh the affected shards to make this operation + visible to search, if `wait_for` then wait for a refresh to make this operation + visible to search, if `false` (the default) then do nothing with refreshes. + :param routing: Specific routing value + :param timeout: Explicit operation timeout + :param version: Explicit version number for concurrency control + :param version_type: Specific version type + :param wait_for_active_shards: Sets the number of shard copies that must be active + before proceeding with the index operation. Defaults to 1, meaning the primary + shard only. Set to `all` for all shard copies, otherwise set to any non-negative + value less than or equal to the total number of copies for the shard (number + of replicas + 1) + """ + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + if id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'id'") + if document is None: + raise ValueError("Empty value passed for parameter 'document'") + if ( + index not in SKIP_IN_PATH + and type not in SKIP_IN_PATH + and id not in SKIP_IN_PATH + ): + __path = f"/{_quote(index)}/{_quote(type)}/{_quote(id)}/_create" + elif index not in SKIP_IN_PATH and id not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_create/{_quote(id)}" + else: + raise ValueError("Couldn't find a path for the given parameters") + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pipeline is not None: + __query["pipeline"] = pipeline + if pretty is not None: + __query["pretty"] = pretty + if refresh is not None: + __query["refresh"] = refresh + if routing is not None: + __query["routing"] = routing + if timeout is not None: + __query["timeout"] = timeout + if version is not None: + __query["version"] = version + if version_type is not None: + __query["version_type"] = version_type + if wait_for_active_shards is not None: + __query["wait_for_active_shards"] = wait_for_active_shards + __body = document + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("PUT", __target, headers=__headers, body=__body) - @query_params( - "if_primary_term", - "if_seq_no", - "refresh", - "routing", - "timeout", - "version", - "version_type", - "wait_for_active_shards", - ) - def delete(self, index, id, doc_type=None, params=None, headers=None): + @_rewrite_parameters() + def delete( + self, + *, + index: Any, + id: Any, + type: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + if_primary_term: Optional[int] = None, + if_seq_no: Optional[Any] = None, + pretty: Optional[bool] = None, + refresh: Optional[Any] = None, + routing: Optional[Any] = None, + timeout: Optional[Any] = None, + version: Optional[Any] = None, + version_type: Optional[Any] = None, + wait_for_active_shards: Optional[Any] = None, + ) -> Any: """ Removes a document from the index. ``_ - :arg index: The name of the index - :arg id: The document ID - :arg doc_type: The type of the document - :arg if_primary_term: only perform the delete operation if the - last operation that has changed the document has the specified primary - term - :arg if_seq_no: only perform the delete operation if the last - operation that has changed the document has the specified sequence - number - :arg refresh: If `true` then refresh the affected shards to make - this operation visible to search, if `wait_for` then wait for a refresh - to make this operation visible to search, if `false` (the default) then - do nothing with refreshes. Valid choices: true, false, wait_for - :arg routing: Specific routing value - :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 - :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 - shard copies, otherwise set to any non-negative value less than or equal - to the total number of copies for the shard (number of replicas + 1) - """ - client, params = _deprecated_options(self, params) - for param in (index, id): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - if doc_type in SKIP_IN_PATH: - doc_type = "_doc" - - return client._perform_request( - "DELETE", _make_path(index, doc_type, id), params=params, headers=headers - ) - - @query_params( - "_source", - "_source_excludes", - "_source_includes", - "allow_no_indices", - "analyze_wildcard", - "analyzer", - "conflicts", - "default_operator", - "df", - "expand_wildcards", - "from_", - "ignore_unavailable", - "lenient", - "max_docs", - "preference", - "q", - "refresh", - "request_cache", - "requests_per_second", - "routing", - "scroll", - "scroll_size", - "search_timeout", - "search_type", - "slices", - "sort", - "stats", - "terminate_after", - "timeout", - "version", - "wait_for_active_shards", - "wait_for_completion", + :param index: The name of the index + :param id: The document ID + :param type: The type of the document + :param if_primary_term: only perform the delete operation if the last operation + that has changed the document has the specified primary term + :param if_seq_no: only perform the delete operation if the last operation that + has changed the document has the specified sequence number + :param refresh: If `true` then refresh the affected shards to make this operation + visible to search, if `wait_for` then wait for a refresh to make this operation + visible to search, if `false` (the default) then do nothing with refreshes. + :param routing: Specific routing value + :param timeout: Explicit operation timeout + :param version: Explicit version number for concurrency control + :param version_type: Specific version type + :param 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 shard copies, otherwise set to any non-negative + value less than or equal to the total number of copies for the shard (number + of replicas + 1) + """ + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + if id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'id'") + if ( + index not in SKIP_IN_PATH + and type not in SKIP_IN_PATH + and id not in SKIP_IN_PATH + ): + __path = f"/{_quote(index)}/{_quote(type)}/{_quote(id)}" + elif index not in SKIP_IN_PATH and id not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_doc/{_quote(id)}" + else: + raise ValueError("Couldn't find a path for the given parameters") + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if if_primary_term is not None: + __query["if_primary_term"] = if_primary_term + if if_seq_no is not None: + __query["if_seq_no"] = if_seq_no + if pretty is not None: + __query["pretty"] = pretty + if refresh is not None: + __query["refresh"] = refresh + if routing is not None: + __query["routing"] = routing + if timeout is not None: + __query["timeout"] = timeout + if version is not None: + __query["version"] = version + if version_type is not None: + __query["version_type"] = version_type + if wait_for_active_shards is not None: + __query["wait_for_active_shards"] = wait_for_active_shards + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + parameter_aliases={ + "_source": "source", + "_source_excludes": "source_excludes", + "_source_includes": "source_includes", + "from": "from_", + }, ) - def delete_by_query(self, index, body, params=None, headers=None): + def delete_by_query( + self, + *, + index: Any, + allow_no_indices: Optional[bool] = None, + analyze_wildcard: Optional[bool] = None, + analyzer: Optional[str] = None, + conflicts: Optional[Any] = None, + default_operator: Optional[Any] = None, + df: Optional[str] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + from_: Optional[int] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + lenient: Optional[bool] = None, + max_docs: Optional[int] = None, + preference: Optional[str] = None, + pretty: Optional[bool] = None, + q: Optional[str] = None, + query: Optional[Any] = None, + refresh: Optional[bool] = None, + request_cache: Optional[bool] = None, + requests_per_second: Optional[int] = None, + routing: Optional[Any] = None, + scroll: Optional[Any] = None, + scroll_size: Optional[int] = None, + search_timeout: Optional[Any] = None, + search_type: Optional[Any] = None, + size: Optional[int] = None, + slice: Optional[Any] = None, + slices: Optional[int] = None, + sort: Optional[List[str]] = None, + source: Optional[Union[Any, bool]] = None, + source_excludes: Optional[Any] = None, + source_includes: Optional[Any] = None, + stats: Optional[List[str]] = None, + terminate_after: Optional[int] = None, + timeout: Optional[Any] = None, + version: Optional[bool] = None, + wait_for_active_shards: Optional[Any] = None, + wait_for_completion: Optional[bool] = None, + ) -> Any: """ 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 _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 - returned _source field - :arg _source_includes: A list of fields to extract and return - from the _source field - :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 analyze_wildcard: Specify whether wildcard and prefix - queries should be analyzed (default: false) - :arg analyzer: The analyzer to use for the query string - :arg conflicts: What to do when the delete by query hits version - conflicts? Valid choices: abort, proceed Default: abort - :arg default_operator: The default operator for query string - query (AND or OR) Valid choices: AND, OR Default: OR - :arg df: The field to use as default where no field prefix is - given in the query string - :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 ignore_unavailable: Whether specified concrete indices - should be ignored when unavailable (missing or closed) - :arg lenient: Specify whether format-based query failures (such - as providing text to a numeric field) should be ignored - :arg max_docs: Maximum number of documents to process (default: - all documents) - :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 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- - requests per second. -1 means no throttle. - :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 scroll_size: Size on the scroll request powering the delete - by query Default: 100 - :arg search_timeout: Explicit timeout for each search request. - Defaults to no timeout. - :arg search_type: Search operation type Valid choices: - query_then_fetch, dfs_query_then_fetch - :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 - :arg sort: A comma-separated list of : pairs - :arg stats: Specific 'tag' of the request for logging and - statistical purposes - :arg terminate_after: The maximum number of documents to collect - for each shard, upon reaching which the query execution will terminate - early. - :arg timeout: Time each individual bulk request should wait for - shards that are unavailable. Default: 1m - :arg version: Specify whether to return document version as part - of a hit - :arg wait_for_active_shards: Sets the number of shard copies - that must be active before proceeding with the delete by query - operation. Defaults to 1, meaning the primary shard only. Set to `all` - for all shard copies, otherwise set to any non-negative value less than - or equal to the total number of copies for the shard (number of replicas - + 1) - :arg wait_for_completion: Should the request should block until - the delete by query is complete. Default: True - """ - client, params = _deprecated_options(self, params) - if params and "from_" in params: - params["from"] = params.pop("from_") - - for param in (index, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "POST", - _make_path(index, "_delete_by_query"), - params=params, - headers=headers, - body=body, - ) + :param index: A comma-separated list of index names to search; use `_all` or + empty string to perform the operation on all indices + :param 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) + :param analyze_wildcard: Specify whether wildcard and prefix queries should be + analyzed (default: false) + :param analyzer: The analyzer to use for the query string + :param conflicts: What to do when the delete by query hits version conflicts? + :param default_operator: The default operator for query string query (AND or + OR) + :param df: The field to use as default where no field prefix is given in the + query string + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param from_: Starting offset (default: 0) + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param lenient: Specify whether format-based query failures (such as providing + text to a numeric field) should be ignored + :param max_docs: + :param preference: Specify the node or shard the operation should be performed + on (default: random) + :param q: Query in the Lucene query string syntax + :param query: + :param refresh: Should the affected indexes be refreshed? + :param request_cache: Specify if request cache should be used for this request + or not, defaults to index level setting + :param requests_per_second: The throttle for this request in sub-requests per + second. -1 means no throttle. + :param routing: A comma-separated list of specific routing values + :param scroll: Specify how long a consistent view of the index should be maintained + for scrolled search + :param scroll_size: Size on the scroll request powering the delete by query + :param search_timeout: Explicit timeout for each search request. Defaults to + no timeout. + :param search_type: Search operation type + :param size: + :param slice: + :param 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`. + :param sort: A comma-separated list of : pairs + :param source: True or false to return the _source field or not, or a list of + fields to return + :param source_excludes: A list of fields to exclude from the returned _source + field + :param source_includes: A list of fields to extract and return from the _source + field + :param stats: Specific 'tag' of the request for logging and statistical purposes + :param terminate_after: The maximum number of documents to collect for each shard, + upon reaching which the query execution will terminate early. + :param timeout: Time each individual bulk request should wait for shards that + are unavailable. + :param version: Specify whether to return document version as part of a hit + :param wait_for_active_shards: Sets the number of shard copies that must be active + before proceeding with the delete by query operation. Defaults to 1, meaning + the primary shard only. Set to `all` for all shard copies, otherwise set + to any non-negative value less than or equal to the total number of copies + for the shard (number of replicas + 1) + :param wait_for_completion: Should the request should block until the delete + by query is complete. + """ + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + __path = f"/{_quote(index)}/_delete_by_query" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if analyze_wildcard is not None: + __query["analyze_wildcard"] = analyze_wildcard + if analyzer is not None: + __query["analyzer"] = analyzer + if conflicts is not None: + __query["conflicts"] = conflicts + if default_operator is not None: + __query["default_operator"] = default_operator + if df is not None: + __query["df"] = df + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if from_ is not None: + __query["from"] = from_ + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if lenient is not None: + __query["lenient"] = lenient + if max_docs is not None: + __body["max_docs"] = max_docs + if preference is not None: + __query["preference"] = preference + if pretty is not None: + __query["pretty"] = pretty + if q is not None: + __query["q"] = q + if query is not None: + __body["query"] = query + if refresh is not None: + __query["refresh"] = refresh + if request_cache is not None: + __query["request_cache"] = request_cache + if requests_per_second is not None: + __query["requests_per_second"] = requests_per_second + if routing is not None: + __query["routing"] = routing + if scroll is not None: + __query["scroll"] = scroll + if scroll_size is not None: + __query["scroll_size"] = scroll_size + if search_timeout is not None: + __query["search_timeout"] = search_timeout + if search_type is not None: + __query["search_type"] = search_type + if size is not None: + __query["size"] = size + if slice is not None: + __body["slice"] = slice + if slices is not None: + __query["slices"] = slices + if sort is not None: + __query["sort"] = sort + if source is not None: + __query["_source"] = source + if source_excludes is not None: + __query["_source_excludes"] = source_excludes + if source_includes is not None: + __query["_source_includes"] = source_includes + if stats is not None: + __query["stats"] = stats + if terminate_after is not None: + __query["terminate_after"] = terminate_after + if timeout is not None: + __query["timeout"] = timeout + if version is not None: + __query["version"] = version + if wait_for_active_shards is not None: + __query["wait_for_active_shards"] = wait_for_active_shards + if wait_for_completion is not None: + __query["wait_for_completion"] = wait_for_completion + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("POST", __target, headers=__headers, body=__body) - @query_params("requests_per_second") - def delete_by_query_rethrottle(self, task_id, params=None, headers=None): + @_rewrite_parameters() + def delete_by_query_rethrottle( + self, + *, + task_id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + requests_per_second: Optional[int] = None, + ) -> Any: """ - Changes the number of requests per second for a particular Delete By Query - operation. + 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 - floating sub-requests per second. -1 means set no throttle. + :param task_id: The task id to rethrottle + :param requests_per_second: The throttle to set on this request in floating sub-requests + per second. -1 means set no throttle. """ - client, params = _deprecated_options(self, params) if task_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'task_id'.") - - return client._perform_request( - "POST", - _make_path("_delete_by_query", task_id, "_rethrottle"), - params=params, - headers=headers, - ) + raise ValueError("Empty value passed for parameter 'task_id'") + __path = f"/_delete_by_query/{_quote(task_id)}/_rethrottle" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if requests_per_second is not None: + __query["requests_per_second"] = requests_per_second + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) - @query_params("master_timeout", "timeout") - def delete_script(self, id, params=None, headers=None): + @_rewrite_parameters() + def delete_script( + self, + *, + id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ Deletes a script. ``_ - :arg id: Script ID - :arg master_timeout: Specify timeout for connection to master - :arg timeout: Explicit operation timeout + :param id: Script ID + :param master_timeout: Specify timeout for connection to master + :param timeout: Explicit operation timeout """ - client, params = _deprecated_options(self, params) if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'id'.") - - return client._perform_request( - "DELETE", _make_path("_scripts", id), params=params, headers=headers - ) - - @query_params( - "_source", - "_source_excludes", - "_source_includes", - "preference", - "realtime", - "refresh", - "routing", - "stored_fields", - "version", - "version_type", + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/_scripts/{_quote(id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters( + parameter_aliases={ + "_source": "source", + "_source_excludes": "source_excludes", + "_source_includes": "source_includes", + }, ) - def exists(self, index, id, params=None, headers=None): + def exists( + self, + *, + index: Any, + id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + preference: Optional[str] = None, + pretty: Optional[bool] = None, + realtime: Optional[bool] = None, + refresh: Optional[bool] = None, + routing: Optional[Any] = None, + source: Optional[Union[Any, bool]] = None, + source_excludes: Optional[Any] = None, + source_includes: Optional[Any] = None, + stored_fields: Optional[Any] = None, + version: Optional[Any] = None, + version_type: Optional[Any] = None, + ) -> Any: """ Returns information about whether a document exists in an index. ``_ - :arg index: The name of the index - :arg id: The document ID - :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 - returned _source field - :arg _source_includes: A list of fields to extract and return - from the _source field - :arg preference: Specify the node or shard the operation should - be performed on (default: random) - :arg realtime: Specify whether to perform the operation in - realtime or search mode - :arg refresh: Refresh the shard containing the document before - performing the operation - :arg routing: Specific routing value - :arg stored_fields: A comma-separated list of stored fields to - return in the response - :arg version: Explicit version number for concurrency control - :arg version_type: Specific version type Valid choices: - internal, external, external_gte - """ - client, params = _deprecated_options(self, params) - for param in (index, id): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "HEAD", _make_path(index, "_doc", id), params=params, headers=headers - ) - - @query_params( - "_source", - "_source_excludes", - "_source_includes", - "preference", - "realtime", - "refresh", - "routing", - "version", - "version_type", + :param index: The name of the index + :param id: The document ID + :param preference: Specify the node or shard the operation should be performed + on (default: random) + :param realtime: Specify whether to perform the operation in realtime or search + mode + :param refresh: Refresh the shard containing the document before performing the + operation + :param routing: Specific routing value + :param source: True or false to return the _source field or not, or a list of + fields to return + :param source_excludes: A list of fields to exclude from the returned _source + field + :param source_includes: A list of fields to extract and return from the _source + field + :param stored_fields: A comma-separated list of stored fields to return in the + response + :param version: Explicit version number for concurrency control + :param version_type: Specific version type + """ + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + if id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/{_quote(index)}/_doc/{_quote(id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if preference is not None: + __query["preference"] = preference + if pretty is not None: + __query["pretty"] = pretty + if realtime is not None: + __query["realtime"] = realtime + if refresh is not None: + __query["refresh"] = refresh + if routing is not None: + __query["routing"] = routing + if source is not None: + __query["_source"] = source + if source_excludes is not None: + __query["_source_excludes"] = source_excludes + if source_includes is not None: + __query["_source_includes"] = source_includes + if stored_fields is not None: + __query["stored_fields"] = stored_fields + if version is not None: + __query["version"] = version + if version_type is not None: + __query["version_type"] = version_type + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("HEAD", __target, headers=__headers) + + @_rewrite_parameters( + parameter_aliases={ + "_source": "source", + "_source_excludes": "source_excludes", + "_source_includes": "source_includes", + }, ) - def exists_source(self, index, id, doc_type=None, params=None, headers=None): + def exists_source( + self, + *, + index: Any, + id: Any, + type: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + preference: Optional[str] = None, + pretty: Optional[bool] = None, + realtime: Optional[bool] = None, + refresh: Optional[bool] = None, + routing: Optional[Any] = None, + source: Optional[Union[Any, bool]] = None, + source_excludes: Optional[Any] = None, + source_includes: Optional[Any] = None, + version: Optional[Any] = None, + version_type: Optional[Any] = None, + ) -> Any: """ Returns information about whether a document source exists in an index. ``_ - :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 - returned _source field - :arg _source_includes: A list of fields to extract and return - from the _source field - :arg preference: Specify the node or shard the operation should - be performed on (default: random) - :arg realtime: Specify whether to perform the operation in - realtime or search mode - :arg refresh: Refresh the shard containing the document before - performing the operation - :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 - """ - client, params = _deprecated_options(self, params) - for param in (index, id): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "HEAD", - _make_path(index, doc_type, id, "_source"), - params=params, - headers=headers, - ) - - @query_params( - "_source", - "_source_excludes", - "_source_includes", - "analyze_wildcard", - "analyzer", - "default_operator", - "df", - "lenient", - "preference", - "q", - "routing", - "stored_fields", + :param index: The name of the index + :param id: The document ID + :param type: The type of the document; deprecated and optional starting with + 7.0 + :param preference: Specify the node or shard the operation should be performed + on (default: random) + :param realtime: Specify whether to perform the operation in realtime or search + mode + :param refresh: Refresh the shard containing the document before performing the + operation + :param routing: Specific routing value + :param source: True or false to return the _source field or not, or a list of + fields to return + :param source_excludes: A list of fields to exclude from the returned _source + field + :param source_includes: A list of fields to extract and return from the _source + field + :param version: Explicit version number for concurrency control + :param version_type: Specific version type + """ + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + if id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'id'") + if ( + index not in SKIP_IN_PATH + and type not in SKIP_IN_PATH + and id not in SKIP_IN_PATH + ): + __path = f"/{_quote(index)}/{_quote(type)}/{_quote(id)}/_source" + elif index not in SKIP_IN_PATH and id not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_source/{_quote(id)}" + else: + raise ValueError("Couldn't find a path for the given parameters") + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if preference is not None: + __query["preference"] = preference + if pretty is not None: + __query["pretty"] = pretty + if realtime is not None: + __query["realtime"] = realtime + if refresh is not None: + __query["refresh"] = refresh + if routing is not None: + __query["routing"] = routing + if source is not None: + __query["_source"] = source + if source_excludes is not None: + __query["_source_excludes"] = source_excludes + if source_includes is not None: + __query["_source_includes"] = source_includes + if version is not None: + __query["version"] = version + if version_type is not None: + __query["version_type"] = version_type + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("HEAD", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + parameter_aliases={ + "_source": "source", + "_source_excludes": "source_excludes", + "_source_includes": "source_includes", + }, ) - def explain(self, index, id, body=None, params=None, headers=None): + def explain( + self, + *, + index: Any, + id: Any, + analyze_wildcard: Optional[bool] = None, + analyzer: Optional[str] = None, + default_operator: Optional[Any] = None, + df: Optional[str] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + lenient: Optional[bool] = None, + preference: Optional[str] = None, + pretty: Optional[bool] = None, + q: Optional[str] = None, + query: Optional[Any] = None, + routing: Optional[Any] = None, + source: Optional[Union[Any, bool]] = None, + source_excludes: Optional[Any] = None, + source_includes: Optional[Any] = None, + stored_fields: Optional[Any] = None, + ) -> Any: """ 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 _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 - returned _source field - :arg _source_includes: A list of fields to extract and return - from the _source field - :arg analyze_wildcard: Specify whether wildcards and prefix - queries in the query string query should be analyzed (default: false) - :arg analyzer: The analyzer for the query string query - :arg default_operator: The default operator for query string - query (AND or OR) Valid choices: AND, OR Default: OR - :arg df: The default field for query string query (default: - _all) - :arg lenient: Specify whether format-based query failures (such - as providing text to a numeric field) should be ignored - :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 routing: Specific routing value - :arg stored_fields: A comma-separated list of stored fields to - return in the response - """ - client, params = _deprecated_options(self, params) - for param in (index, id): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "POST", - _make_path(index, "_explain", id), - params=params, - headers=headers, - body=body, - ) - - @query_params( - "allow_no_indices", - "expand_wildcards", - "fields", - "ignore_unavailable", - "include_unmapped", + :param index: The name of the index + :param id: The document ID + :param analyze_wildcard: Specify whether wildcards and prefix queries in the + query string query should be analyzed (default: false) + :param analyzer: The analyzer for the query string query + :param default_operator: The default operator for query string query (AND or + OR) + :param df: The default field for query string query (default: _all) + :param lenient: Specify whether format-based query failures (such as providing + text to a numeric field) should be ignored + :param preference: Specify the node or shard the operation should be performed + on (default: random) + :param q: Query in the Lucene query string syntax + :param query: + :param routing: Specific routing value + :param source: True or false to return the _source field or not, or a list of + fields to return + :param source_excludes: A list of fields to exclude from the returned _source + field + :param source_includes: A list of fields to extract and return from the _source + field + :param stored_fields: A comma-separated list of stored fields to return in the + response + """ + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + if id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/{_quote(index)}/_explain/{_quote(id)}" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if analyze_wildcard is not None: + __query["analyze_wildcard"] = analyze_wildcard + if analyzer is not None: + __query["analyzer"] = analyzer + if default_operator is not None: + __query["default_operator"] = default_operator + if df is not None: + __query["df"] = df + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if lenient is not None: + __query["lenient"] = lenient + if preference is not None: + __query["preference"] = preference + if pretty is not None: + __query["pretty"] = pretty + if q is not None: + __query["q"] = q + if query is not None: + __body["query"] = query + if routing is not None: + __query["routing"] = routing + if source is not None: + __query["_source"] = source + if source_excludes is not None: + __query["_source_excludes"] = source_excludes + if source_includes is not None: + __query["_source_includes"] = source_includes + if stored_fields is not None: + __query["stored_fields"] = stored_fields + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, ) - def field_caps(self, body=None, index=None, params=None, headers=None): + def field_caps( + self, + *, + index: Optional[Any] = None, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + fields: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + include_unmapped: Optional[bool] = None, + index_filter: Optional[Any] = None, + pretty: Optional[bool] = None, + runtime_mappings: Optional[Any] = None, + ) -> Any: """ - Returns the information about the capabilities of fields among multiple - indices. + Returns the information about the capabilities of fields among multiple indices. ``_ - :arg body: An index filter specified with the Query DSL - :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 fields: A comma-separated list of field names - :arg ignore_unavailable: Whether specified concrete indices - should be ignored when unavailable (missing or closed) - :arg include_unmapped: Indicates whether unmapped fields should - be included in the response. - """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "POST", - _make_path(index, "_field_caps"), - params=params, - headers=headers, - body=body, - ) - - @query_params( - "_source", - "_source_excludes", - "_source_includes", - "preference", - "realtime", - "refresh", - "routing", - "stored_fields", - "version", - "version_type", + :param index: A comma-separated list of index names; use `_all` or empty string + to perform the operation on all indices + :param 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) + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param fields: A comma-separated list of field names + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param include_unmapped: Indicates whether unmapped fields should be included + in the response. + :param index_filter: + :param runtime_mappings: + """ + if index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_field_caps" + else: + __path = "/_field_caps" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if fields is not None: + __query["fields"] = fields + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if include_unmapped is not None: + __query["include_unmapped"] = include_unmapped + if index_filter is not None: + __body["index_filter"] = index_filter + if pretty is not None: + __query["pretty"] = pretty + if runtime_mappings is not None: + __body["runtime_mappings"] = runtime_mappings + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + parameter_aliases={ + "_source": "source", + "_source_excludes": "source_excludes", + "_source_includes": "source_includes", + }, ) - def get(self, index, id, params=None, headers=None): + def get( + self, + *, + index: Any, + id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + preference: Optional[str] = None, + pretty: Optional[bool] = None, + realtime: Optional[bool] = None, + refresh: Optional[bool] = None, + routing: Optional[Any] = None, + source: Optional[Union[Any, bool]] = None, + source_excludes: Optional[Any] = None, + source_includes: Optional[Any] = None, + stored_fields: Optional[Any] = None, + version: Optional[Any] = None, + version_type: Optional[Any] = None, + ) -> Any: """ Returns a document. ``_ - :arg index: The name of the index - :arg id: The document ID - :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 - returned _source field - :arg _source_includes: A list of fields to extract and return - from the _source field - :arg preference: Specify the node or shard the operation should - be performed on (default: random) - :arg realtime: Specify whether to perform the operation in - realtime or search mode - :arg refresh: Refresh the shard containing the document before - performing the operation - :arg routing: Specific routing value - :arg stored_fields: A comma-separated list of stored fields to - return in the response - :arg version: Explicit version number for concurrency control - :arg version_type: Specific version type Valid choices: - internal, external, external_gte - """ - client, params = _deprecated_options(self, params) - for param in (index, id): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "GET", _make_path(index, "_doc", id), params=params, headers=headers - ) + :param index: Name of the index that contains the document. + :param id: Unique identifier of the document. + :param preference: Specifies the node or shard the operation should be performed + on. Random by default. + :param realtime: Boolean) If true, the request is real-time as opposed to near-real-time. + :param refresh: If true, Elasticsearch refreshes the affected shards to make + this operation visible to search. If false, do nothing with refreshes. + :param routing: Target the specified primary shard. + :param source: True or false to return the _source field or not, or a list of + fields to return. + :param source_excludes: A comma-separated list of source fields to exclude in + the response. + :param source_includes: A comma-separated list of source fields to include in + the response. + :param stored_fields: A comma-separated list of stored fields to return in the + response + :param version: Explicit version number for concurrency control. The specified + version must match the current version of the document for the request to + succeed. + :param version_type: Specific version type: internal, external, external_gte. + """ + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + if id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/{_quote(index)}/_doc/{_quote(id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if preference is not None: + __query["preference"] = preference + if pretty is not None: + __query["pretty"] = pretty + if realtime is not None: + __query["realtime"] = realtime + if refresh is not None: + __query["refresh"] = refresh + if routing is not None: + __query["routing"] = routing + if source is not None: + __query["_source"] = source + if source_excludes is not None: + __query["_source_excludes"] = source_excludes + if source_includes is not None: + __query["_source_includes"] = source_includes + if stored_fields is not None: + __query["stored_fields"] = stored_fields + if version is not None: + __query["version"] = version + if version_type is not None: + __query["version_type"] = version_type + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) - @query_params("master_timeout") - def get_script(self, id, params=None, headers=None): + @_rewrite_parameters() + def get_script( + self, + *, + id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Returns a script. ``_ - :arg id: Script ID - :arg master_timeout: Specify timeout for connection to master + :param id: Script ID + :param master_timeout: Specify timeout for connection to master """ - client, params = _deprecated_options(self, params) if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'id'.") + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/_scripts/{_quote(id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) - return client._perform_request( - "GET", _make_path("_scripts", id), params=params, headers=headers - ) + @_rewrite_parameters() + def get_script_context( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: + """ + Returns all script contexts. - @query_params( - "_source", - "_source_excludes", - "_source_includes", - "preference", - "realtime", - "refresh", - "routing", - "version", - "version_type", + ``_ + """ + __path = "/_script_context" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def get_script_languages( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: + """ + Returns available script types, languages and contexts + + ``_ + """ + __path = "/_script_language" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + parameter_aliases={ + "_source": "source", + "_source_excludes": "source_excludes", + "_source_includes": "source_includes", + }, ) - def get_source(self, index, id, params=None, headers=None): + def get_source( + self, + *, + index: Any, + id: Any, + preference: Optional[str] = None, + realtime: Optional[bool] = None, + refresh: Optional[bool] = None, + routing: Optional[Any] = None, + source: Optional[Union[Any, bool]] = None, + source_excludes: Optional[Any] = None, + source_includes: Optional[Any] = None, + stored_fields: Optional[Any] = None, + version: Optional[Any] = None, + version_type: Optional[Any] = None, + ) -> Any: """ Returns the source of a document. ``_ - :arg index: The name of the index - :arg id: The document ID - :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 - returned _source field - :arg _source_includes: A list of fields to extract and return - from the _source field - :arg preference: Specify the node or shard the operation should - be performed on (default: random) - :arg realtime: Specify whether to perform the operation in - realtime or search mode - :arg refresh: Refresh the shard containing the document before - performing the operation - :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 - """ - client, params = _deprecated_options(self, params) - for param in (index, id): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "GET", _make_path(index, "_source", id), params=params, headers=headers - ) + :param index: Name of the index that contains the document. + :param id: Unique identifier of the document. + :param preference: Specifies the node or shard the operation should be performed + on. Random by default. + :param realtime: Boolean) If true, the request is real-time as opposed to near-real-time. + :param refresh: If true, Elasticsearch refreshes the affected shards to make + this operation visible to search. If false, do nothing with refreshes. + :param routing: Target the specified primary shard. + :param source: True or false to return the _source field or not, or a list of + fields to return. + :param source_excludes: A comma-separated list of source fields to exclude in + the response. + :param source_includes: A comma-separated list of source fields to include in + the response. + :param stored_fields: + :param version: Explicit version number for concurrency control. The specified + version must match the current version of the document for the request to + succeed. + :param version_type: Specific version type: internal, external, external_gte. + """ + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + if id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/{_quote(index)}/_source/{_quote(id)}" + __query: Dict[str, Any] = {} + if preference is not None: + __query["preference"] = preference + if realtime is not None: + __query["realtime"] = realtime + if refresh is not None: + __query["refresh"] = refresh + if routing is not None: + __query["routing"] = routing + if source is not None: + __query["_source"] = source + if source_excludes is not None: + __query["_source_excludes"] = source_excludes + if source_includes is not None: + __query["_source_includes"] = source_includes + if stored_fields is not None: + __query["stored_fields"] = stored_fields + if version is not None: + __query["version"] = version + if version_type is not None: + __query["version_type"] = version_type + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + body_name="document", + ) + def index( + self, + *, + index: Any, + document: Any, + id: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + if_primary_term: Optional[int] = None, + if_seq_no: Optional[Any] = None, + op_type: Optional[Any] = None, + pipeline: Optional[str] = None, + pretty: Optional[bool] = None, + refresh: Optional[Any] = None, + require_alias: Optional[bool] = None, + routing: Optional[Any] = None, + timeout: Optional[Any] = None, + version: Optional[Any] = None, + version_type: Optional[Any] = None, + wait_for_active_shards: Optional[Any] = None, + ) -> Any: + """ + Creates or updates a document in an index. + + ``_ + + :param index: The name of the index + :param document: + :param id: Document ID + :param if_primary_term: only perform the index operation if the last operation + that has changed the document has the specified primary term + :param if_seq_no: only perform the index operation if the last operation that + has changed the document has the specified sequence number + :param op_type: Explicit operation type. Defaults to `index` for requests with + an explicit document ID, and to `create`for requests without an explicit + document ID + :param pipeline: The pipeline id to preprocess incoming documents with + :param refresh: If `true` then refresh the affected shards to make this operation + visible to search, if `wait_for` then wait for a refresh to make this operation + visible to search, if `false` (the default) then do nothing with refreshes. + :param require_alias: When true, requires destination to be an alias. Default + is false + :param routing: Specific routing value + :param timeout: Explicit operation timeout + :param version: Explicit version number for concurrency control + :param version_type: Specific version type + :param wait_for_active_shards: Sets the number of shard copies that must be active + before proceeding with the index operation. Defaults to 1, meaning the primary + shard only. Set to `all` for all shard copies, otherwise set to any non-negative + value less than or equal to the total number of copies for the shard (number + of replicas + 1) + """ + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + if document is None: + raise ValueError("Empty value passed for parameter 'document'") + if index not in SKIP_IN_PATH and id not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_doc/{_quote(id)}" + __method = "PUT" + elif index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_doc" + __method = "POST" + else: + raise ValueError("Couldn't find a path for the given parameters") + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if if_primary_term is not None: + __query["if_primary_term"] = if_primary_term + if if_seq_no is not None: + __query["if_seq_no"] = if_seq_no + if op_type is not None: + __query["op_type"] = op_type + if pipeline is not None: + __query["pipeline"] = pipeline + if pretty is not None: + __query["pretty"] = pretty + if refresh is not None: + __query["refresh"] = refresh + if require_alias is not None: + __query["require_alias"] = require_alias + if routing is not None: + __query["routing"] = routing + if timeout is not None: + __query["timeout"] = timeout + if version is not None: + __query["version"] = version + if version_type is not None: + __query["version_type"] = version_type + if wait_for_active_shards is not None: + __query["wait_for_active_shards"] = wait_for_active_shards + __body = document + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request(__method, __target, headers=__headers, body=__body) + + @_rewrite_parameters() + def info( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: + """ + Returns basic information about the cluster. + + ``_ + """ + __path = "/" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + parameter_aliases={"_source": "source"}, + ignore_deprecated_options=True, + ) + def knn_search( + self, + *, + index: Any, + knn: Any, + docvalue_fields: Optional[Union[Any, List[Any]]] = None, + error_trace: Optional[bool] = None, + fields: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + routing: Optional[Any] = None, + source: Optional[Union[Any, bool]] = None, + stored_fields: Optional[Any] = None, + ) -> Any: + """ + Performs a kNN search. - @query_params( - "_source", - "_source_excludes", - "_source_includes", - "preference", - "realtime", - "refresh", - "routing", - "stored_fields", + ``_ + + :param index: A comma-separated list of index names to search; use `_all` or + to perform the operation on all indices + :param knn: kNN query to execute + :param docvalue_fields: The request returns doc values for field names matching + these patterns in the hits.fields property of the response. Accepts wildcard + (*) patterns. + :param fields: The request returns values for field names matching these patterns + in the hits.fields property of the response. Accepts wildcard (*) patterns. + :param routing: A comma-separated list of specific routing values + :param source: Indicates which source fields are returned for matching documents. + These fields are returned in the hits._source property of the search response. + :param stored_fields: List of stored fields to return as part of a hit. If no + fields are specified, no stored fields are included in the response. If this + field is specified, the _source parameter defaults to false. You can pass + _source: true to return both source fields and stored fields in the search + response. + """ + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + if knn is None: + raise ValueError("Empty value passed for parameter 'knn'") + __path = f"/{_quote(index)}/_knn_search" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if knn is not None: + __body["knn"] = knn + if docvalue_fields is not None: + __body["docvalue_fields"] = docvalue_fields + if error_trace is not None: + __query["error_trace"] = error_trace + if fields is not None: + __body["fields"] = fields + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if routing is not None: + __query["routing"] = routing + if source is not None: + __body["_source"] = source + if stored_fields is not None: + __body["stored_fields"] = stored_fields + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, + parameter_aliases={ + "_source": "source", + "_source_excludes": "source_excludes", + "_source_includes": "source_includes", + }, ) - def mget(self, body, index=None, params=None, headers=None): + def mget( + self, + *, + index: Optional[Any] = None, + docs: Optional[List[Any]] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ids: Optional[List[Any]] = None, + preference: Optional[str] = None, + pretty: Optional[bool] = None, + realtime: Optional[bool] = None, + refresh: Optional[bool] = None, + routing: Optional[Any] = None, + source: Optional[Union[Any, bool]] = None, + source_excludes: Optional[Any] = None, + source_includes: Optional[Any] = None, + stored_fields: Optional[Any] = None, + ) -> Any: """ 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. - :arg index: The name of the index - :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 - returned _source field - :arg _source_includes: A list of fields to extract and return - from the _source field - :arg preference: Specify the node or shard the operation should - be performed on (default: random) - :arg realtime: Specify whether to perform the operation in - realtime or search mode - :arg refresh: Refresh the shard containing the document before - performing the operation - :arg routing: Specific routing value - :arg stored_fields: A comma-separated list of stored fields to - return in the response - """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return client._perform_request( - "POST", - _make_path(index, "_mget"), - params=params, - headers=headers, - body=body, - ) + :param index: The name of the index + :param docs: + :param ids: + :param preference: Specify the node or shard the operation should be performed + on (default: random) + :param realtime: Specify whether to perform the operation in realtime or search + mode + :param refresh: Refresh the shard containing the document before performing the + operation + :param routing: Specific routing value + :param source: True or false to return the _source field or not, or a list of + fields to return + :param source_excludes: A list of fields to exclude from the returned _source + field + :param source_includes: A list of fields to extract and return from the _source + field + :param stored_fields: A comma-separated list of stored fields to return in the + response + """ + if index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_mget" + else: + __path = "/_mget" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if docs is not None: + __body["docs"] = docs + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ids is not None: + __body["ids"] = ids + if preference is not None: + __query["preference"] = preference + if pretty is not None: + __query["pretty"] = pretty + if realtime is not None: + __query["realtime"] = realtime + if refresh is not None: + __query["refresh"] = refresh + if routing is not None: + __query["routing"] = routing + if source is not None: + __query["_source"] = source + if source_excludes is not None: + __query["_source_excludes"] = source_excludes + if source_includes is not None: + __query["_source_includes"] = source_includes + if stored_fields is not None: + __query["stored_fields"] = stored_fields + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("POST", __target, headers=__headers, body=__body) - @query_params( - "ccs_minimize_roundtrips", - "max_concurrent_searches", - "max_concurrent_shard_requests", - "pre_filter_shard_size", - "rest_total_hits_as_int", - "search_type", - "typed_keys", + @_rewrite_parameters( + body_name="searches", ) - def msearch(self, body, index=None, params=None, headers=None): + def msearch( + self, + *, + searches: List[Any], + index: Optional[Any] = None, + allow_no_indices: Optional[bool] = None, + ccs_minimize_roundtrips: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_throttled: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + max_concurrent_searches: Optional[int] = None, + max_concurrent_shard_requests: Optional[int] = None, + pre_filter_shard_size: Optional[int] = None, + pretty: Optional[bool] = None, + rest_total_hits_as_int: Optional[bool] = None, + search_type: Optional[Any] = None, + typed_keys: Optional[bool] = None, + ) -> Any: """ 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 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 max_concurrent_shard_requests: The number of concurrent - shard requests each sub search executes concurrently per node. This - value should be used to limit the impact of the search on the cluster in - order to limit the number of concurrent shard requests Default: 5 - :arg pre_filter_shard_size: A threshold that enforces a pre- - filter roundtrip to prefilter search shards based on query rewriting if - the number of shards the search request expands to exceeds the - threshold. This filter roundtrip can limit the number of shards - significantly if for instance a shard can not match any documents based - on its rewrite method ie. if date filters are mandatory to match but the - shard bounds and the query are disjoint. - :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, dfs_query_then_fetch - :arg typed_keys: Specify whether aggregation and suggester names - should be prefixed by their respective types in the response - """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - headers["content-type"] = "application/x-ndjson" - return client._perform_request( - "POST", - _make_path(index, "_msearch"), - params=params, - headers=headers, - body=body, - ) + :param searches: + :param index: Comma-separated list of data streams, indices, and index aliases + to search. + :param allow_no_indices: If false, the request returns an error if any wildcard + expression, index alias, or _all value targets only missing or closed indices. + This behavior applies even if the request targets other open indices. For + example, a request targeting foo*,bar* returns an error if an index starts + with foo but no index starts with bar. + :param ccs_minimize_roundtrips: If true, network roundtrips between the coordinating + node and remote clusters are minimized for cross-cluster search requests. + :param expand_wildcards: Type of index that wildcard expressions can match. If + the request can target data streams, this argument determines whether wildcard + expressions match hidden data streams. + :param ignore_throttled: If true, concrete, expanded or aliased indices are ignored + when frozen. + :param ignore_unavailable: If true, missing or closed indices are not included + in the response. + :param max_concurrent_searches: Maximum number of concurrent searches the multi + search API can execute. + :param max_concurrent_shard_requests: Maximum number of concurrent shard requests + that each sub-search request executes per node. + :param pre_filter_shard_size: Defines a threshold that enforces a pre-filter + roundtrip to prefilter search shards based on query rewriting if the number + of shards the search request expands to exceeds the threshold. This filter + roundtrip can limit the number of shards significantly if for instance a + shard can not match any documents based on its rewrite method i.e., if date + filters are mandatory to match but the shard bounds and the query are disjoint. + :param rest_total_hits_as_int: If true, hits.total are returned as an integer + in the response. Defaults to false, which returns an object. + :param search_type: Indicates whether global term and document frequencies should + be used when scoring returned documents. + :param typed_keys: Specifies whether aggregation and suggester names should be + prefixed by their respective types in the response. + """ + if searches is None: + raise ValueError("Empty value passed for parameter 'searches'") + if index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_msearch" + else: + __path = "/_msearch" + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if ccs_minimize_roundtrips is not None: + __query["ccs_minimize_roundtrips"] = ccs_minimize_roundtrips + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_throttled is not None: + __query["ignore_throttled"] = ignore_throttled + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if max_concurrent_searches is not None: + __query["max_concurrent_searches"] = max_concurrent_searches + if max_concurrent_shard_requests is not None: + __query["max_concurrent_shard_requests"] = max_concurrent_shard_requests + if pre_filter_shard_size is not None: + __query["pre_filter_shard_size"] = pre_filter_shard_size + if pretty is not None: + __query["pretty"] = pretty + if rest_total_hits_as_int is not None: + __query["rest_total_hits_as_int"] = rest_total_hits_as_int + if search_type is not None: + __query["search_type"] = search_type + if typed_keys is not None: + __query["typed_keys"] = typed_keys + __body = searches + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = { + "accept": "application/json", + "content-type": "application/x-ndjson", + } + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_name="search_templates", + ) + def msearch_template( + self, + *, + search_templates: List[Any], + index: Optional[Any] = None, + ccs_minimize_roundtrips: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + max_concurrent_searches: Optional[int] = None, + pretty: Optional[bool] = None, + rest_total_hits_as_int: Optional[bool] = None, + search_type: Optional[Any] = None, + typed_keys: Optional[bool] = None, + ) -> Any: + """ + Allows to execute several search template operations in one request. + + ``_ + + :param search_templates: + :param index: A comma-separated list of index names to use as default + :param ccs_minimize_roundtrips: Indicates whether network round-trips should + be minimized as part of cross-cluster search requests execution + :param max_concurrent_searches: Controls the maximum number of concurrent searches + the multi search api will execute + :param rest_total_hits_as_int: Indicates whether hits.total should be rendered + as an integer or an object in the rest search response + :param search_type: Search operation type + :param typed_keys: Specify whether aggregation and suggester names should be + prefixed by their respective types in the response + """ + if search_templates is None: + raise ValueError("Empty value passed for parameter 'search_templates'") + if index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_msearch/template" + else: + __path = "/_msearch/template" + __query: Dict[str, Any] = {} + if ccs_minimize_roundtrips is not None: + __query["ccs_minimize_roundtrips"] = ccs_minimize_roundtrips + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if max_concurrent_searches is not None: + __query["max_concurrent_searches"] = max_concurrent_searches + if pretty is not None: + __query["pretty"] = pretty + if rest_total_hits_as_int is not None: + __query["rest_total_hits_as_int"] = rest_total_hits_as_int + if search_type is not None: + __query["search_type"] = search_type + if typed_keys is not None: + __query["typed_keys"] = typed_keys + __body = search_templates + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = { + "accept": "application/json", + "content-type": "application/x-ndjson", + } + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, + ) + def mtermvectors( + self, + *, + index: Optional[Any] = None, + docs: Optional[List[Any]] = None, + error_trace: Optional[bool] = None, + field_statistics: Optional[bool] = None, + fields: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ids: Optional[List[Any]] = None, + offsets: Optional[bool] = None, + payloads: Optional[bool] = None, + positions: Optional[bool] = None, + preference: Optional[str] = None, + pretty: Optional[bool] = None, + realtime: Optional[bool] = None, + routing: Optional[Any] = None, + term_statistics: Optional[bool] = None, + version: Optional[Any] = None, + version_type: Optional[Any] = None, + ) -> Any: + """ + Returns multiple termvectors in one request. + + ``_ + + :param index: The index in which the document resides. + :param docs: + :param 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". + :param fields: A comma-separated list of fields to return. Applies to all returned + documents unless otherwise specified in body "params" or "docs". + :param ids: + :param offsets: Specifies if term offsets should be returned. Applies to all + returned documents unless otherwise specified in body "params" or "docs". + :param payloads: Specifies if term payloads should be returned. Applies to all + returned documents unless otherwise specified in body "params" or "docs". + :param positions: Specifies if term positions should be returned. Applies to + all returned documents unless otherwise specified in body "params" or "docs". + :param 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". + :param realtime: Specifies if requests are real-time as opposed to near-real-time + (default: true). + :param routing: Specific routing value. Applies to all returned documents unless + otherwise specified in body "params" or "docs". + :param 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". + :param version: Explicit version number for concurrency control + :param version_type: Specific version type + """ + if index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_mtermvectors" + else: + __path = "/_mtermvectors" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if docs is not None: + __body["docs"] = docs + if error_trace is not None: + __query["error_trace"] = error_trace + if field_statistics is not None: + __query["field_statistics"] = field_statistics + if fields is not None: + __query["fields"] = fields + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ids is not None: + __body["ids"] = ids + if offsets is not None: + __query["offsets"] = offsets + if payloads is not None: + __query["payloads"] = payloads + if positions is not None: + __query["positions"] = positions + if preference is not None: + __query["preference"] = preference + if pretty is not None: + __query["pretty"] = pretty + if realtime is not None: + __query["realtime"] = realtime + if routing is not None: + __query["routing"] = routing + if term_statistics is not None: + __query["term_statistics"] = term_statistics + if version is not None: + __query["version"] = version + if version_type is not None: + __query["version_type"] = version_type + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters() + def open_point_in_time( + self, + *, + index: Any, + keep_alive: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: + """ + Open a point in time that can be used in subsequent searches + + ``_ + + :param index: A comma-separated list of index names to open point in time; use + `_all` or empty string to perform the operation on all indices + :param keep_alive: Specific the time to live for the point in time + """ + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + if keep_alive is None: + raise ValueError("Empty value passed for parameter 'keep_alive'") + __path = f"/{_quote(index)}/_pit" + __query: Dict[str, Any] = {} + if keep_alive is not None: + __query["keep_alive"] = keep_alive + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) - @query_params("master_timeout", "timeout") - def put_script(self, id, body, context=None, params=None, headers=None): + @_rewrite_parameters( + body_fields=True, + ) + def put_script( + self, + *, + id: Any, + context: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + script: Optional[Any] = None, + timeout: Optional[Any] = None, + ) -> Any: """ Creates or updates a script. ``_ - :arg id: Script ID - :arg body: The document - :arg context: Context name to compile script against - :arg master_timeout: Specify timeout for connection to master - :arg timeout: Explicit operation timeout - """ - client, params = _deprecated_options(self, params) - for param in (id, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "PUT", - _make_path("_scripts", id, context), - params=params, - headers=headers, - body=body, - ) + :param id: Script ID + :param context: Script context + :param master_timeout: Specify timeout for connection to master + :param script: + :param timeout: Explicit operation timeout + """ + if id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'id'") + if id not in SKIP_IN_PATH and context not in SKIP_IN_PATH: + __path = f"/_scripts/{_quote(id)}/{_quote(context)}" + elif id not in SKIP_IN_PATH: + __path = f"/_scripts/{_quote(id)}" + else: + raise ValueError("Couldn't find a path for the given parameters") + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if script is not None: + __body["script"] = script + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("PUT", __target, headers=__headers, body=__body) - @query_params( - "allow_no_indices", "expand_wildcards", "ignore_unavailable", "search_type" + @_rewrite_parameters( + body_fields=True, ) - def rank_eval(self, body, index=None, params=None, headers=None): + def rank_eval( + self, + *, + index: Any, + requests: List[Any], + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + metric: Optional[Any] = None, + pretty: Optional[bool] = None, + search_type: Optional[str] = None, + ) -> Any: """ 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. - :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 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 search_type: Search operation type Valid choices: - query_then_fetch, dfs_query_then_fetch - """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return client._perform_request( - "POST", - _make_path(index, "_rank_eval"), - params=params, - headers=headers, - body=body, - ) + :param index: Comma-separated list of data streams, indices, and index aliases + used to limit the request. Wildcard (`*`) expressions are supported. To target + all data streams and indices in a cluster, omit this parameter or use `_all` + or `*`. + :param requests: A set of typical search requests, together with their provided + ratings. + :param allow_no_indices: If `false`, the request returns an error if any wildcard + expression, index alias, or `_all` value targets only missing or closed indices. + This behavior applies even if the request targets other open indices. For + example, a request targeting `foo*,bar*` returns an error if an index starts + with `foo` but no index starts with `bar`. + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param ignore_unavailable: If `true`, missing or closed indices are not included + in the response. + :param metric: Definition of the evaluation metric to calculate. + :param search_type: Search operation type + """ + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + if requests is None: + raise ValueError("Empty value passed for parameter 'requests'") + if index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_rank_eval" + else: + __path = "/_rank_eval" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if requests is not None: + __body["requests"] = requests + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if metric is not None: + __body["metric"] = metric + if pretty is not None: + __query["pretty"] = pretty + if search_type is not None: + __query["search_type"] = search_type + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("POST", __target, headers=__headers, body=__body) - @query_params( - "max_docs", - "refresh", - "requests_per_second", - "scroll", - "slices", - "timeout", - "wait_for_active_shards", - "wait_for_completion", + @_rewrite_parameters( + body_fields=True, ) - def reindex(self, body, params=None, headers=None): + def reindex( + self, + *, + conflicts: Optional[Any] = None, + dest: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + max_docs: Optional[int] = None, + pretty: Optional[bool] = None, + refresh: Optional[bool] = None, + requests_per_second: Optional[int] = None, + require_alias: Optional[bool] = None, + script: Optional[Any] = None, + scroll: Optional[Any] = None, + size: Optional[int] = None, + slices: Optional[int] = None, + source: Optional[Any] = None, + timeout: Optional[Any] = None, + wait_for_active_shards: Optional[Any] = None, + wait_for_completion: Optional[bool] = None, + ) -> Any: """ 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. + 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. - :arg max_docs: Maximum number of documents to process (default: - all documents) - :arg refresh: Should the affected indexes be refreshed? - :arg requests_per_second: The throttle to set on this request in - sub-requests per second. -1 means no throttle. - :arg scroll: Control how long to keep the search context alive - Default: 5m - :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 - :arg timeout: Time each individual bulk request should wait for - shards that are unavailable. Default: 1m - :arg wait_for_active_shards: Sets the number of shard copies - that must be active before proceeding with the reindex operation. - Defaults to 1, meaning the primary shard only. Set to `all` for all - shard copies, otherwise set to any non-negative value less than or equal - to the total number of copies for the shard (number of replicas + 1) - :arg wait_for_completion: Should the request should block until - the reindex is complete. Default: True - """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return client._perform_request( - "POST", "/_reindex", params=params, headers=headers, body=body - ) + :param conflicts: + :param dest: + :param max_docs: + :param refresh: Should the affected indexes be refreshed? + :param requests_per_second: The throttle to set on this request in sub-requests + per second. -1 means no throttle. + :param require_alias: + :param script: + :param scroll: Control how long to keep the search context alive + :param size: + :param 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`. + :param source: + :param timeout: Time each individual bulk request should wait for shards that + are unavailable. + :param wait_for_active_shards: Sets the number of shard copies that must be active + before proceeding with the reindex operation. Defaults to 1, meaning the + primary shard only. Set to `all` for all shard copies, otherwise set to any + non-negative value less than or equal to the total number of copies for the + shard (number of replicas + 1) + :param wait_for_completion: Should the request should block until the reindex + is complete. + """ + __path = "/_reindex" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if conflicts is not None: + __body["conflicts"] = conflicts + if dest is not None: + __body["dest"] = dest + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if max_docs is not None: + __body["max_docs"] = max_docs + if pretty is not None: + __query["pretty"] = pretty + if refresh is not None: + __query["refresh"] = refresh + if requests_per_second is not None: + __query["requests_per_second"] = requests_per_second + if require_alias is not None: + __query["require_alias"] = require_alias + if script is not None: + __body["script"] = script + if scroll is not None: + __query["scroll"] = scroll + if size is not None: + __body["size"] = size + if slices is not None: + __query["slices"] = slices + if source is not None: + __body["source"] = source + if timeout is not None: + __query["timeout"] = timeout + if wait_for_active_shards is not None: + __query["wait_for_active_shards"] = wait_for_active_shards + if wait_for_completion is not None: + __query["wait_for_completion"] = wait_for_completion + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("POST", __target, headers=__headers, body=__body) - @query_params("requests_per_second") - def reindex_rethrottle(self, task_id, params=None, headers=None): + @_rewrite_parameters() + def reindex_rethrottle( + self, + *, + task_id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + requests_per_second: Optional[int] = None, + ) -> Any: """ 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 - floating sub-requests per second. -1 means set no throttle. + :param task_id: The task id to rethrottle + :param requests_per_second: The throttle to set on this request in floating sub-requests + per second. -1 means set no throttle. """ - client, params = _deprecated_options(self, params) if task_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'task_id'.") - - return client._perform_request( - "POST", - _make_path("_reindex", task_id, "_rethrottle"), - params=params, - headers=headers, - ) + raise ValueError("Empty value passed for parameter 'task_id'") + __path = f"/_reindex/{_quote(task_id)}/_rethrottle" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if requests_per_second is not None: + __query["requests_per_second"] = requests_per_second + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) - @query_params() - def render_search_template(self, body=None, id=None, params=None, headers=None): + @_rewrite_parameters( + body_fields=True, + ignore_deprecated_options={"params"}, + ) + def render_search_template( + self, + *, + id: Optional[Any] = None, + error_trace: Optional[bool] = None, + file: Optional[str] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + params: Optional[Dict[str, Any]] = None, + pretty: Optional[bool] = None, + source: Optional[str] = None, + ) -> Any: """ 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 + :param id: The id of the stored search template + :param file: + :param params: + :param source: """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "POST", - _make_path("_render", "template", id), - params=params, - headers=headers, - body=body, - ) - - @query_params() - def scripts_painless_execute(self, body=None, params=None, headers=None): + if id not in SKIP_IN_PATH: + __path = f"/_render/template/{_quote(id)}" + else: + __path = "/_render/template" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if file is not None: + __body["file"] = file + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if params is not None: + __body["params"] = params + if pretty is not None: + __query["pretty"] = pretty + if source is not None: + __body["source"] = source + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, + ) + def scripts_painless_execute( + self, + *, + context: Optional[str] = None, + context_setup: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + script: Optional[Any] = None, + ) -> Any: """ Allows an arbitrary script to be executed and a result to be returned ``_ - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - - :arg body: The script to execute + :param context: + :param context_setup: + :param script: """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "POST", - "/_scripts/painless/_execute", - params=params, - headers=headers, - body=body, - ) - - @query_params("rest_total_hits_as_int", "scroll") - def scroll(self, body=None, scroll_id=None, params=None, headers=None): + __path = "/_scripts/painless/_execute" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if context is not None: + __body["context"] = context + if context_setup is not None: + __body["context_setup"] = context_setup + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if script is not None: + __body["script"] = script + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, + ) + def scroll( + self, + *, + scroll_id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + rest_total_hits_as_int: Optional[bool] = None, + scroll: Optional[Any] = None, + ) -> Any: """ 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. - :arg scroll_id: The scroll ID for scrolled search - :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 scroll: Specify how long a consistent view of the index - should be maintained for scrolled search - """ - client, params = _deprecated_options(self, params) - if scroll_id in SKIP_IN_PATH and body in SKIP_IN_PATH: - raise ValueError("You need to supply scroll_id or body.") - elif scroll_id and not body: - body = {"scroll_id": scroll_id} - elif scroll_id: - params["scroll_id"] = scroll_id - - return client._perform_request( - "POST", "/_search/scroll", params=params, headers=headers, body=body - ) - - @query_params( - "_source", - "_source_excludes", - "_source_includes", - "allow_no_indices", - "allow_partial_search_results", - "analyze_wildcard", - "analyzer", - "batched_reduce_size", - "ccs_minimize_roundtrips", - "default_operator", - "df", - "docvalue_fields", - "expand_wildcards", - "explain", - "from_", - "ignore_throttled", - "ignore_unavailable", - "lenient", - "max_concurrent_shard_requests", - "min_compatible_shard_node", - "pre_filter_shard_size", - "preference", - "q", - "request_cache", - "rest_total_hits_as_int", - "routing", - "scroll", - "search_type", - "seq_no_primary_term", - "size", - "sort", - "stats", - "stored_fields", - "suggest_field", - "suggest_mode", - "suggest_size", - "suggest_text", - "terminate_after", - "timeout", - "track_scores", - "track_total_hits", - "typed_keys", - "version", + :param scroll_id: Scroll ID of the search. + :param rest_total_hits_as_int: If true, the API response’s hit.total property + is returned as an integer. If false, the API response’s hit.total property + is returned as an object. + :param scroll: Period to retain the search context for scrolling. + """ + if scroll_id is None: + raise ValueError("Empty value passed for parameter 'scroll_id'") + __path = "/_search/scroll" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if scroll_id is not None: + __body["scroll_id"] = scroll_id + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if rest_total_hits_as_int is not None: + __query["rest_total_hits_as_int"] = rest_total_hits_as_int + if scroll is not None: + __body["scroll"] = scroll + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, + parameter_aliases={ + "_source": "source", + "_source_excludes": "source_excludes", + "_source_includes": "source_includes", + "from": "from_", + }, ) - def search(self, body=None, index=None, params=None, headers=None): + def search( + self, + *, + index: Optional[Any] = None, + aggregations: Optional[Dict[str, Any]] = None, + allow_no_indices: Optional[bool] = None, + allow_partial_search_results: Optional[bool] = None, + analyze_wildcard: Optional[bool] = None, + analyzer: Optional[str] = None, + batched_reduce_size: Optional[int] = None, + ccs_minimize_roundtrips: Optional[bool] = None, + collapse: Optional[Any] = None, + default_operator: Optional[Any] = None, + df: Optional[str] = None, + docvalue_fields: Optional[Union[Any, List[Any]]] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + explain: Optional[bool] = None, + fields: Optional[List[Any]] = None, + filter_path: Optional[Union[List[str], str]] = None, + from_: Optional[int] = None, + highlight: Optional[Any] = None, + human: Optional[bool] = None, + ignore_throttled: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + indices_boost: Optional[List[Dict[Any, float]]] = None, + lenient: Optional[bool] = None, + max_concurrent_shard_requests: Optional[int] = None, + min_compatible_shard_node: Optional[Any] = None, + min_score: Optional[float] = None, + pit: Optional[Any] = None, + post_filter: Optional[Any] = None, + pre_filter_shard_size: Optional[int] = None, + preference: Optional[str] = None, + pretty: Optional[bool] = None, + profile: Optional[bool] = None, + q: Optional[str] = None, + query: Optional[Any] = None, + request_cache: Optional[bool] = None, + rescore: Optional[Union[Any, List[Any]]] = None, + rest_total_hits_as_int: Optional[bool] = None, + routing: Optional[Any] = None, + runtime_mappings: Optional[Any] = None, + script_fields: Optional[Dict[str, Any]] = None, + scroll: Optional[Any] = None, + search_after: Optional[Any] = None, + search_type: Optional[Any] = None, + seq_no_primary_term: Optional[bool] = None, + size: Optional[int] = None, + slice: Optional[Any] = None, + sort: Optional[Any] = None, + source: Optional[Union[Any, bool]] = None, + source_excludes: Optional[Any] = None, + source_includes: Optional[Any] = None, + stats: Optional[List[str]] = None, + stored_fields: Optional[Any] = None, + suggest: Optional[Union[Any, Dict[str, Any]]] = None, + suggest_field: Optional[Any] = None, + suggest_mode: Optional[Any] = None, + suggest_size: Optional[int] = None, + suggest_text: Optional[str] = None, + terminate_after: Optional[int] = None, + timeout: Optional[str] = None, + track_scores: Optional[bool] = None, + track_total_hits: Optional[Union[bool, int]] = None, + typed_keys: Optional[bool] = None, + version: Optional[bool] = None, + ) -> Any: """ 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 _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 - returned _source field - :arg _source_includes: A list of fields to extract and return - from the _source field - :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 allow_partial_search_results: Indicate if an error should - be returned if there is a partial search failure or timeout Default: - True - :arg analyze_wildcard: Specify whether wildcard and prefix - queries should be analyzed (default: false) - :arg analyzer: The analyzer to use for the query string - :arg batched_reduce_size: The number of shard results that - should be reduced at once on the coordinating node. This value should be - used as a protection mechanism to reduce the memory overhead per search - request if the potential number of shards in the request can be large. - Default: 512 - :arg ccs_minimize_roundtrips: Indicates whether network round- - trips should be minimized as part of cross-cluster search requests - execution Default: true - :arg default_operator: The default operator for query string - query (AND or OR) Valid choices: AND, OR Default: OR - :arg df: The field to use as default where no field prefix is - given in the query string - :arg docvalue_fields: A comma-separated list of fields to return - as the docvalue representation of a field for each hit - :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 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 - should be ignored when unavailable (missing or closed) - :arg lenient: Specify whether format-based query failures (such - as providing text to a numeric field) should be ignored - :arg max_concurrent_shard_requests: The number of concurrent - shard requests per node this search executes concurrently. This value - should be used to limit the impact of the search on the cluster in order - to limit the number of concurrent shard requests Default: 5 - :arg min_compatible_shard_node: The minimum compatible version - that all shards involved in search should have for this request to be - successful - :arg pre_filter_shard_size: A threshold that enforces a pre- - filter roundtrip to prefilter search shards based on query rewriting if - the number of shards the search request expands to exceeds the - threshold. This filter roundtrip can limit the number of shards - significantly if for instance a shard can not match any documents based - on its rewrite method ie. if date filters are mandatory to match but the - shard bounds and the query are disjoint. - :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 request_cache: Specify if request cache should be used for - this request or not, defaults to index level setting - :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, dfs_query_then_fetch - :arg seq_no_primary_term: Specify whether to return sequence - number and primary term of the last modification of each hit - :arg size: Number of hits to return (default: 10) - :arg sort: A comma-separated list of : pairs - :arg stats: Specific 'tag' of the request for logging and - statistical purposes - :arg stored_fields: A comma-separated list of stored fields to - return as part of a hit - :arg suggest_field: Specify which field to use for suggestions - :arg suggest_mode: Specify suggest mode Valid choices: missing, - popular, always Default: missing - :arg suggest_size: How many suggestions to return in response - :arg suggest_text: The source text for which the suggestions - should be returned - :arg terminate_after: The maximum number of documents to collect - for each shard, upon reaching which the query execution will terminate - early. - :arg timeout: Explicit operation timeout - :arg track_scores: Whether to calculate and return scores even - if they are not used for sorting - :arg track_total_hits: Indicate if the number of documents that - match the query should be tracked. A number can also be specified, to - accurately track the total hit count up to the number. - :arg typed_keys: Specify whether aggregation and suggester names - should be prefixed by their respective types in the response - :arg version: Specify whether to return document version as part - of a hit - """ - client, params = _deprecated_options(self, params) - if params and "from_" in params: - params["from"] = params.pop("from_") - - return client._perform_request( - "POST", - _make_path(index, "_search"), - params=params, - headers=headers, - body=body, - ) - - @query_params( - "allow_no_indices", - "expand_wildcards", - "ignore_unavailable", - "local", - "preference", - "routing", - ) - 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 - :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 local: Return local information, do not retrieve the state - from master node (default: false) - :arg preference: Specify the node or shard the operation should - be performed on (default: random) - :arg routing: Specific routing value - """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", _make_path(index, "_search_shards"), params=params, headers=headers - ) - - @query_params( - "_source", - "_source_excludes", - "_source_includes", - "if_primary_term", - "if_seq_no", - "lang", - "refresh", - "require_alias", - "retry_on_conflict", - "routing", - "timeout", - "wait_for_active_shards", - ) - def update(self, index, id, body, doc_type=None, params=None, headers=None): + :param index: A comma-separated list of index names to search; use `_all` or + empty string to perform the operation on all indices + :param aggregations: + :param 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) + :param allow_partial_search_results: Indicate if an error should be returned + if there is a partial search failure or timeout + :param analyze_wildcard: Specify whether wildcard and prefix queries should be + analyzed (default: false) + :param analyzer: The analyzer to use for the query string + :param batched_reduce_size: The number of shard results that should be reduced + at once on the coordinating node. This value should be used as a protection + mechanism to reduce the memory overhead per search request if the potential + number of shards in the request can be large. + :param ccs_minimize_roundtrips: Indicates whether network round-trips should + be minimized as part of cross-cluster search requests execution + :param collapse: + :param default_operator: The default operator for query string query (AND or + OR) + :param df: The field to use as default where no field prefix is given in the + query string + :param docvalue_fields: Array of wildcard (*) patterns. The request returns doc + values for field names matching these patterns in the hits.fields property + of the response. + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param explain: If true, returns detailed information about score computation + as part of a hit. + :param fields: Array of wildcard (*) patterns. The request returns values for + field names matching these patterns in the hits.fields property of the response. + :param from_: Starting document offset. By default, you cannot page through more + than 10,000 hits using the from and size parameters. To page through more + hits, use the search_after parameter. + :param highlight: + :param ignore_throttled: Whether specified concrete, expanded or aliased indices + should be ignored when throttled + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param indices_boost: Boosts the _score of documents from specified indices. + :param lenient: Specify whether format-based query failures (such as providing + text to a numeric field) should be ignored + :param max_concurrent_shard_requests: The number of concurrent shard requests + per node this search executes concurrently. This value should be used to + limit the impact of the search on the cluster in order to limit the number + of concurrent shard requests + :param min_compatible_shard_node: The minimum compatible version that all shards + involved in search should have for this request to be successful + :param min_score: Minimum _score for matching documents. Documents with a lower + _score are not included in the search results. + :param pit: Limits the search to a point in time (PIT). If you provide a PIT, + you cannot specify an in the request path. + :param post_filter: + :param pre_filter_shard_size: A threshold that enforces a pre-filter roundtrip + to prefilter search shards based on query rewriting if the number of shards + the search request expands to exceeds the threshold. This filter roundtrip + can limit the number of shards significantly if for instance a shard can + not match any documents based on its rewrite method ie. if date filters are + mandatory to match but the shard bounds and the query are disjoint. + :param preference: Specify the node or shard the operation should be performed + on (default: random) + :param profile: + :param q: Query in the Lucene query string syntax + :param query: Defines the search definition using the Query DSL. + :param request_cache: Specify if request cache should be used for this request + or not, defaults to index level setting + :param rescore: + :param rest_total_hits_as_int: Indicates whether hits.total should be rendered + as an integer or an object in the rest search response + :param routing: A comma-separated list of specific routing values + :param runtime_mappings: Defines one or more runtime fields in the search request. + These fields take precedence over mapped fields with the same name. + :param script_fields: Retrieve a script evaluation (based on different fields) + for each hit. + :param scroll: Specify how long a consistent view of the index should be maintained + for scrolled search + :param search_after: + :param search_type: Search operation type + :param seq_no_primary_term: If true, returns sequence number and primary term + of the last modification of each hit. See Optimistic concurrency control. + :param size: The number of hits to return. By default, you cannot page through + more than 10,000 hits using the from and size parameters. To page through + more hits, use the search_after parameter. + :param slice: + :param sort: + :param source: Indicates which source fields are returned for matching documents. + These fields are returned in the hits._source property of the search response. + :param source_excludes: A list of fields to exclude from the returned _source + field + :param source_includes: A list of fields to extract and return from the _source + field + :param stats: Stats groups to associate with the search. Each group maintains + a statistics aggregation for its associated searches. You can retrieve these + stats using the indices stats API. + :param stored_fields: List of stored fields to return as part of a hit. If no + fields are specified, no stored fields are included in the response. If this + field is specified, the _source parameter defaults to false. You can pass + _source: true to return both source fields and stored fields in the search + response. + :param suggest: + :param suggest_field: Specifies which field to use for suggestions. + :param suggest_mode: Specify suggest mode + :param suggest_size: How many suggestions to return in response + :param suggest_text: The source text for which the suggestions should be returned. + :param terminate_after: Maximum number of documents to collect for each shard. + If a query reaches this limit, Elasticsearch terminates the query early. + Elasticsearch collects documents before sorting. Defaults to 0, which does + not terminate query execution early. + :param timeout: Specifies the period of time to wait for a response from each + shard. If no response is received before the timeout expires, the request + fails and returns an error. Defaults to no timeout. + :param track_scores: If true, calculate and return document scores, even if the + scores are not used for sorting. + :param track_total_hits: Number of hits matching the query to count accurately. + If true, the exact number of hits is returned at the cost of some performance. + If false, the response does not include the total number of hits matching + the query. Defaults to 10,000 hits. + :param typed_keys: Specify whether aggregation and suggester names should be + prefixed by their respective types in the response + :param version: If true, returns document version as part of a hit. """ - Updates a document with a script or partial document. - - ``_ - - :arg index: The name of the index - :arg id: Document ID - :arg body: The request definition requires either `script` or - partial `doc` - :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 - returned _source field - :arg _source_includes: A list of fields to extract and return - from the _source field - :arg if_primary_term: only perform the update operation if the - last operation that has changed the document has the specified primary - term - :arg if_seq_no: only perform the update operation if the last - operation that has changed the document has the specified sequence - number - :arg lang: The script language (default: painless) - :arg refresh: If `true` then refresh the affected shards to make - this operation visible to search, if `wait_for` then wait for a refresh - to make this operation visible to search, if `false` (the default) then - do nothing with refreshes. Valid choices: true, false, wait_for - :arg require_alias: When true, requires destination is an alias. - Default is false - :arg retry_on_conflict: Specify how many times should the - operation be retried when a conflict occurs (default: 0) - :arg routing: Specific routing value - :arg timeout: Explicit operation timeout - :arg wait_for_active_shards: Sets the number of shard copies - that must be active before proceeding with the update operation. - Defaults to 1, meaning the primary shard only. Set to `all` for all - shard copies, otherwise set to any non-negative value less than or equal - to the total number of copies for the shard (number of replicas + 1) - """ - client, params = _deprecated_options(self, params) - for param in (index, id, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - if doc_type in SKIP_IN_PATH: - path = _make_path(index, "_update", id) + if index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_search" else: - path = _make_path(index, doc_type, id, "_update") - - return client._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. + __path = "/_search" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if aggregations is not None: + __body["aggregations"] = aggregations + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if allow_partial_search_results is not None: + __query["allow_partial_search_results"] = allow_partial_search_results + if analyze_wildcard is not None: + __query["analyze_wildcard"] = analyze_wildcard + if analyzer is not None: + __query["analyzer"] = analyzer + if batched_reduce_size is not None: + __query["batched_reduce_size"] = batched_reduce_size + if ccs_minimize_roundtrips is not None: + __query["ccs_minimize_roundtrips"] = ccs_minimize_roundtrips + if collapse is not None: + __body["collapse"] = collapse + if default_operator is not None: + __query["default_operator"] = default_operator + if df is not None: + __query["df"] = df + if docvalue_fields is not None: + __body["docvalue_fields"] = docvalue_fields + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if explain is not None: + __body["explain"] = explain + if fields is not None: + __body["fields"] = fields + if filter_path is not None: + __query["filter_path"] = filter_path + if from_ is not None: + __body["from"] = from_ + if highlight is not None: + __body["highlight"] = highlight + if human is not None: + __query["human"] = human + if ignore_throttled is not None: + __query["ignore_throttled"] = ignore_throttled + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if indices_boost is not None: + __body["indices_boost"] = indices_boost + if lenient is not None: + __query["lenient"] = lenient + if max_concurrent_shard_requests is not None: + __query["max_concurrent_shard_requests"] = max_concurrent_shard_requests + if min_compatible_shard_node is not None: + __query["min_compatible_shard_node"] = min_compatible_shard_node + if min_score is not None: + __body["min_score"] = min_score + if pit is not None: + __body["pit"] = pit + if post_filter is not None: + __body["post_filter"] = post_filter + if pre_filter_shard_size is not None: + __query["pre_filter_shard_size"] = pre_filter_shard_size + if preference is not None: + __query["preference"] = preference + if pretty is not None: + __query["pretty"] = pretty + if profile is not None: + __body["profile"] = profile + if q is not None: + __query["q"] = q + if query is not None: + __body["query"] = query + if request_cache is not None: + __query["request_cache"] = request_cache + if rescore is not None: + __body["rescore"] = rescore + if rest_total_hits_as_int is not None: + __query["rest_total_hits_as_int"] = rest_total_hits_as_int + if routing is not None: + __query["routing"] = routing + if runtime_mappings is not None: + __body["runtime_mappings"] = runtime_mappings + if script_fields is not None: + __body["script_fields"] = script_fields + if scroll is not None: + __query["scroll"] = scroll + if search_after is not None: + __body["search_after"] = search_after + if search_type is not None: + __query["search_type"] = search_type + if seq_no_primary_term is not None: + __body["seq_no_primary_term"] = seq_no_primary_term + if size is not None: + __body["size"] = size + if slice is not None: + __body["slice"] = slice + if sort is not None: + __body["sort"] = sort + if source is not None: + __body["_source"] = source + if source_excludes is not None: + __query["_source_excludes"] = source_excludes + if source_includes is not None: + __query["_source_includes"] = source_includes + if stats is not None: + __body["stats"] = stats + if stored_fields is not None: + __body["stored_fields"] = stored_fields + if suggest is not None: + __body["suggest"] = suggest + if suggest_field is not None: + __query["suggest_field"] = suggest_field + if suggest_mode is not None: + __query["suggest_mode"] = suggest_mode + if suggest_size is not None: + __query["suggest_size"] = suggest_size + if suggest_text is not None: + __query["suggest_text"] = suggest_text + if terminate_after is not None: + __body["terminate_after"] = terminate_after + if timeout is not None: + __body["timeout"] = timeout + if track_scores is not None: + __body["track_scores"] = track_scores + if track_total_hits is not None: + __body["track_total_hits"] = track_total_hits + if typed_keys is not None: + __query["typed_keys"] = typed_keys + if version is not None: + __body["version"] = version + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, + ) + def search_mvt( + self, + *, + index: Any, + field: Any, + zoom: Any, + x: Any, + y: Any, + aggs: Optional[Dict[str, Any]] = None, + error_trace: Optional[bool] = None, + exact_bounds: Optional[bool] = None, + extent: Optional[int] = None, + fields: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + grid_precision: Optional[int] = None, + grid_type: Optional[Any] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + query: Optional[Any] = None, + runtime_mappings: Optional[Any] = None, + size: Optional[int] = None, + sort: Optional[Any] = None, + ) -> Any: """ - client, params = _deprecated_options(self, params) - if task_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'task_id'.") + Searches a vector tile for geospatial values. Returns results as a binary Mapbox + vector tile. - return client._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): + :param index: Comma-separated list of data streams, indices, or aliases to search + :param field: Field containing geospatial data to return + :param zoom: Zoom level for the vector tile to search + :param x: X coordinate for the vector tile to search + :param y: Y coordinate for the vector tile to search + :param aggs: Sub-aggregations for the geotile_grid. Supports the following aggregation + types: - avg - cardinality - max - min - sum + :param exact_bounds: If false, the meta layer’s feature is the bounding box of + the tile. If true, the meta layer’s feature is a bounding box resulting from + a geo_bounds aggregation. The aggregation runs on values that intersect + the // tile with wrap_longitude set to false. The resulting bounding + box may be larger than the vector tile. + :param extent: Size, in pixels, of a side of the tile. Vector tiles are square + with equal sides. + :param fields: Fields to return in the `hits` layer. Supports wildcards (`*`). + This parameter does not support fields with array values. Fields with array + values may return inconsistent results. + :param grid_precision: Additional zoom levels available through the aggs layer. + For example, if is 7 and grid_precision is 8, you can zoom in up to + level 15. Accepts 0-8. If 0, results don’t include the aggs layer. + :param grid_type: Determines the geometry type for features in the aggs layer. + In the aggs layer, each feature represents a geotile_grid cell. If 'grid' + each feature is a Polygon of the cells bounding box. If 'point' each feature + is a Point that is the centroid of the cell. + :param query: Query DSL used to filter documents for the search. + :param runtime_mappings: Defines one or more runtime fields in the search request. + These fields take precedence over mapped fields with the same name. + :param size: Maximum number of features to return in the hits layer. Accepts + 0-10000. If 0, results don’t include the hits layer. + :param sort: Sorts features in the hits layer. By default, the API calculates + a bounding box for each feature. It sorts features based on this box’s diagonal + length, from longest to shortest. """ - Returns all script contexts. - - ``_ + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + if field in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'field'") + if zoom in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'zoom'") + if x in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'x'") + if y in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'y'") + __path = f"/{_quote(index)}/_mvt/{_quote(field)}/{_quote(zoom)}/{_quote(x)}/{_quote(y)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if aggs is not None: + __body["aggs"] = aggs + if error_trace is not None: + __query["error_trace"] = error_trace + if exact_bounds is not None: + __body["exact_bounds"] = exact_bounds + if extent is not None: + __body["extent"] = extent + if fields is not None: + __body["fields"] = fields + if filter_path is not None: + __query["filter_path"] = filter_path + if grid_precision is not None: + __body["grid_precision"] = grid_precision + if grid_type is not None: + __body["grid_type"] = grid_type + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if query is not None: + __body["query"] = query + if runtime_mappings is not None: + __body["runtime_mappings"] = runtime_mappings + if size is not None: + __body["size"] = size + if sort is not None: + __body["sort"] = sort + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/vnd.mapbox-vector-tile"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters() + def search_shards( + self, + *, + index: Optional[Any] = None, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + local: Optional[bool] = None, + preference: Optional[str] = None, + pretty: Optional[bool] = None, + routing: Optional[Any] = None, + ) -> Any: """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", "/_script_context", params=params, headers=headers - ) + Returns information about the indices and shards that a search request would + be executed against. - @query_params() - def get_script_languages(self, params=None, headers=None): - """ - Returns available script types, languages and contexts + ``_ - ``_ + :param index: A comma-separated list of index names to search; use `_all` or + empty string to perform the operation on all indices + :param 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) + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param local: Return local information, do not retrieve the state from master + node (default: false) + :param preference: Specify the node or shard the operation should be performed + on (default: random) + :param routing: Specific routing value """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", "/_script_language", params=params, headers=headers - ) + if index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_search_shards" + else: + __path = "/_search_shards" + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if local is not None: + __query["local"] = local + if preference is not None: + __query["preference"] = preference + if pretty is not None: + __query["pretty"] = pretty + if routing is not None: + __query["routing"] = routing + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) - @query_params( - "ccs_minimize_roundtrips", - "max_concurrent_searches", - "rest_total_hits_as_int", - "search_type", - "typed_keys", + @_rewrite_parameters( + body_fields=True, + ignore_deprecated_options={"params"}, ) - def msearch_template(self, body, index=None, params=None, headers=None): + def search_template( + self, + *, + index: Optional[Any] = None, + allow_no_indices: Optional[bool] = None, + ccs_minimize_roundtrips: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + explain: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + id: Optional[Any] = None, + ignore_throttled: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + params: Optional[Dict[str, Any]] = None, + preference: Optional[str] = None, + pretty: Optional[bool] = None, + profile: Optional[bool] = None, + rest_total_hits_as_int: Optional[bool] = None, + routing: Optional[Any] = None, + scroll: Optional[Any] = None, + search_type: Optional[Any] = None, + source: Optional[str] = None, + typed_keys: Optional[bool] = None, + ) -> Any: """ - 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, dfs_query_then_fetch - :arg typed_keys: Specify whether aggregation and suggester names - should be prefixed by their respective types in the response - """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - headers["content-type"] = "application/x-ndjson" - return client._perform_request( - "POST", - _make_path(index, "_msearch", "template"), - params=params, - headers=headers, - body=body, - ) + Allows to use the Mustache language to pre-render a search definition. - @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): + ``_ + + :param index: Comma-separated list of data streams, indices, and aliases to search. + Supports wildcards (*). + :param 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) + :param ccs_minimize_roundtrips: Indicates whether network round-trips should + be minimized as part of cross-cluster search requests execution + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param explain: + :param id: ID of the search template to use. If no source is specified, this + parameter is required. + :param ignore_throttled: Whether specified concrete, expanded or aliased indices + should be ignored when throttled + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param params: + :param preference: Specify the node or shard the operation should be performed + on (default: random) + :param profile: + :param rest_total_hits_as_int: If true, hits.total are rendered as an integer + in the response. + :param routing: Custom value used to route operations to a specific shard. + :param scroll: Specifies how long a consistent view of the index should be maintained + for scrolled search. + :param search_type: The type of the search operation. + :param source: An inline search template. Supports the same parameters as the + search API's request body. Also supports Mustache variables. If no id is + specified, this parameter is required. + :param typed_keys: Specify whether aggregation and suggester names should be + prefixed by their respective types in the response """ - 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 - """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "POST", - _make_path(index, "_mtermvectors"), - params=params, - headers=headers, - body=body, - ) + if index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_search/template" + else: + __path = "/_search/template" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if ccs_minimize_roundtrips is not None: + __query["ccs_minimize_roundtrips"] = ccs_minimize_roundtrips + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if explain is not None: + __body["explain"] = explain + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if id is not None: + __body["id"] = id + if ignore_throttled is not None: + __query["ignore_throttled"] = ignore_throttled + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if params is not None: + __body["params"] = params + if preference is not None: + __query["preference"] = preference + if pretty is not None: + __query["pretty"] = pretty + if profile is not None: + __body["profile"] = profile + if rest_total_hits_as_int is not None: + __query["rest_total_hits_as_int"] = rest_total_hits_as_int + if routing is not None: + __query["routing"] = routing + if scroll is not None: + __query["scroll"] = scroll + if search_type is not None: + __query["search_type"] = search_type + if source is not None: + __body["source"] = source + if typed_keys is not None: + __query["typed_keys"] = typed_keys + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("POST", __target, 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", + @_rewrite_parameters( + body_fields=True, ) - def search_template(self, body, index=None, params=None, headers=None): + def terms_enum( + self, + *, + index: Any, + field: Any, + case_insensitive: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + index_filter: Optional[Any] = None, + pretty: Optional[bool] = None, + search_after: Optional[str] = None, + size: Optional[int] = None, + string: Optional[str] = None, + timeout: Optional[Any] = None, + ) -> Any: """ - 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, dfs_query_then_fetch - :arg typed_keys: Specify whether aggregation and suggester names - should be prefixed by their respective types in the response - """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return client._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", + The terms enum API can be used to discover terms in the index that begin with + the provided string. It is designed for low-latency look-ups used in auto-complete + scenarios. + + ``_ + + :param index: Comma-separated list of data streams, indices, and index aliases + to search. Wildcard (*) expressions are supported. + :param field: The string to match at the start of indexed terms. If not provided, + all terms in the field are considered. + :param case_insensitive: When true the provided search string is matched against + index terms without case sensitivity. + :param index_filter: Allows to filter an index shard if the provided query rewrites + to match_none. + :param search_after: + :param size: How many matching terms to return. + :param string: The string after which terms in the index should be returned. + Allows for a form of pagination if the last result from one request is passed + as the search_after parameter for a subsequent request. + :param timeout: The maximum length of time to spend collecting results. Defaults + to "1s" (one second). If the timeout is exceeded the complete flag set to + false in the response and the results may be partial or empty. + """ + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + if field is None: + raise ValueError("Empty value passed for parameter 'field'") + __path = f"/{_quote(index)}/_terms_enum" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if field is not None: + __body["field"] = field + if case_insensitive is not None: + __body["case_insensitive"] = case_insensitive + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if index_filter is not None: + __body["index_filter"] = index_filter + if pretty is not None: + __query["pretty"] = pretty + if search_after is not None: + __body["search_after"] = search_after + if size is not None: + __body["size"] = size + if string is not None: + __body["string"] = string + if timeout is not None: + __body["timeout"] = timeout + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, ) - def termvectors(self, index, body=None, id=None, params=None, headers=None): + def termvectors( + self, + *, + index: Any, + id: Optional[Any] = None, + doc: Optional[Any] = None, + error_trace: Optional[bool] = None, + field_statistics: Optional[bool] = None, + fields: Optional[Any] = None, + filter: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + offsets: Optional[bool] = None, + payloads: Optional[bool] = None, + per_field_analyzer: Optional[Dict[Any, str]] = None, + positions: Optional[bool] = None, + preference: Optional[str] = None, + pretty: Optional[bool] = None, + realtime: Optional[bool] = None, + routing: Optional[Any] = None, + term_statistics: Optional[bool] = None, + version: Optional[Any] = None, + version_type: Optional[Any] = None, + ) -> Any: """ 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 - """ - client, params = _deprecated_options(self, params) - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return client._perform_request( - "POST", - _make_path(index, "_termvectors", id), - params=params, - headers=headers, - body=body, - ) - - @query_params( - "_source", - "_source_excludes", - "_source_includes", - "allow_no_indices", - "analyze_wildcard", - "analyzer", - "conflicts", - "default_operator", - "df", - "expand_wildcards", - "from_", - "ignore_unavailable", - "lenient", - "max_docs", - "pipeline", - "preference", - "q", - "refresh", - "request_cache", - "requests_per_second", - "routing", - "scroll", - "scroll_size", - "search_timeout", - "search_type", - "slices", - "sort", - "stats", - "terminate_after", - "timeout", - "version", - "version_type", - "wait_for_active_shards", - "wait_for_completion", - ) - def update_by_query(self, index, body=None, params=None, headers=None): + :param index: The index in which the document resides. + :param id: The id of the document, when not specified a doc param should be supplied. + :param doc: + :param field_statistics: Specifies if document count, sum of document frequencies + and sum of total term frequencies should be returned. + :param fields: A comma-separated list of fields to return. + :param filter: + :param offsets: Specifies if term offsets should be returned. + :param payloads: Specifies if term payloads should be returned. + :param per_field_analyzer: + :param positions: Specifies if term positions should be returned. + :param preference: Specify the node or shard the operation should be performed + on (default: random). + :param realtime: Specifies if request is real-time as opposed to near-real-time + (default: true). + :param routing: Specific routing value. + :param term_statistics: Specifies if total term frequency and document frequency + should be returned. + :param version: Explicit version number for concurrency control + :param version_type: Specific version type """ - 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 _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 - returned _source field - :arg _source_includes: A list of fields to extract and return - from the _source field - :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 analyze_wildcard: Specify whether wildcard and prefix - queries should be analyzed (default: false) - :arg analyzer: The analyzer to use for the query string - :arg conflicts: What to do when the update by query hits version - conflicts? Valid choices: abort, proceed Default: abort - :arg default_operator: The default operator for query string - query (AND or OR) Valid choices: AND, OR Default: OR - :arg df: The field to use as default where no field prefix is - given in the query string - :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 ignore_unavailable: Whether specified concrete indices - should be ignored when unavailable (missing or closed) - :arg lenient: Specify whether format-based query failures (such - as providing text to a numeric field) should be ignored - :arg max_docs: Maximum number of documents to process (default: - all documents) - :arg pipeline: Ingest pipeline to set on index requests made by - this action. (default: none) - :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 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 to set on this request in - sub-requests per second. -1 means no throttle. - :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 scroll_size: Size on the scroll request powering the update - by query Default: 100 - :arg search_timeout: Explicit timeout for each search request. - Defaults to no timeout. - :arg search_type: Search operation type Valid choices: - query_then_fetch, dfs_query_then_fetch - :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 - :arg sort: A comma-separated list of : pairs - :arg stats: Specific 'tag' of the request for logging and - statistical purposes - :arg terminate_after: The maximum number of documents to collect - for each shard, upon reaching which the query execution will terminate - early. - :arg timeout: Time each individual bulk request should wait for - shards that are unavailable. Default: 1m - :arg version: Specify whether to return document version as part - of a hit - :arg version_type: Should the document increment the version - number (internal) on hit or not (reindex) - :arg wait_for_active_shards: Sets the number of shard copies - that must be active before proceeding with the update by query - operation. Defaults to 1, meaning the primary shard only. Set to `all` - for all shard copies, otherwise set to any non-negative value less than - or equal to the total number of copies for the shard (number of replicas - + 1) - :arg wait_for_completion: Should the request should block until - the update by query operation is complete. Default: True - """ - client, params = _deprecated_options(self, params) - if params and "from_" in params: - params["from"] = params.pop("from_") - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return client._perform_request( - "POST", - _make_path(index, "_update_by_query"), - params=params, - headers=headers, - body=body, - ) - - @query_params() - def close_point_in_time(self, body=None, params=None, headers=None): - """ - Close a point in time - - ``_ - - :arg body: a point-in-time id to close - """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "DELETE", "/_pit", params=params, headers=headers, body=body - ) - - @query_params( - "expand_wildcards", "ignore_unavailable", "keep_alive", "preference", "routing" + raise ValueError("Empty value passed for parameter 'index'") + if index not in SKIP_IN_PATH and id not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_termvectors/{_quote(id)}" + elif index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_termvectors" + else: + raise ValueError("Couldn't find a path for the given parameters") + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if doc is not None: + __body["doc"] = doc + if error_trace is not None: + __query["error_trace"] = error_trace + if field_statistics is not None: + __query["field_statistics"] = field_statistics + if fields is not None: + __query["fields"] = fields + if filter is not None: + __body["filter"] = filter + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if offsets is not None: + __query["offsets"] = offsets + if payloads is not None: + __query["payloads"] = payloads + if per_field_analyzer is not None: + __body["per_field_analyzer"] = per_field_analyzer + if positions is not None: + __query["positions"] = positions + if preference is not None: + __query["preference"] = preference + if pretty is not None: + __query["pretty"] = pretty + if realtime is not None: + __query["realtime"] = realtime + if routing is not None: + __query["routing"] = routing + if term_statistics is not None: + __query["term_statistics"] = term_statistics + if version is not None: + __query["version"] = version + if version_type is not None: + __query["version_type"] = version_type + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, + parameter_aliases={ + "_source": "source", + "_source_excludes": "source_excludes", + "_source_includes": "source_includes", + }, ) - def open_point_in_time(self, index, params=None, headers=None): - """ - Open a point in time that can be used in subsequent searches - - ``_ - - :arg index: A comma-separated list of index names to open point - in time; use `_all` or empty string to perform the operation on all - indices - :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 keep_alive: Specific the time to live for the point in time - :arg preference: Specify the node or shard the operation should - be performed on (default: random) - :arg routing: Specific routing value - """ - client, params = _deprecated_options(self, params) - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return client._perform_request( - "POST", _make_path(index, "_pit"), params=params, headers=headers - ) - - @query_params() - def terms_enum(self, index, body=None, params=None, headers=None): + def update( + self, + *, + index: Any, + id: Any, + type: Optional[Any] = None, + detect_noop: Optional[bool] = None, + doc: Optional[Any] = None, + doc_as_upsert: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + if_primary_term: Optional[int] = None, + if_seq_no: Optional[Any] = None, + lang: Optional[str] = None, + pretty: Optional[bool] = None, + refresh: Optional[Any] = None, + require_alias: Optional[bool] = None, + retry_on_conflict: Optional[int] = None, + routing: Optional[Any] = None, + script: Optional[Any] = None, + scripted_upsert: Optional[bool] = None, + source: Optional[Union[Any, bool]] = None, + source_excludes: Optional[Any] = None, + source_includes: Optional[Any] = None, + timeout: Optional[Any] = None, + upsert: Optional[Any] = None, + wait_for_active_shards: Optional[Any] = None, + ) -> Any: """ - The terms enum API can be used to discover terms in the index that begin with - the provided string. It is designed for low-latency look-ups used in auto- - complete scenarios. + Updates a document with a script or partial document. - ``_ + ``_ - :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: field name, string which is the prefix expected in - matching terms, timeout and size for max number of results + :param index: The name of the index + :param id: Document ID + :param type: The type of the document + :param detect_noop: Set to false to disable setting 'result' in the response + to 'noop' if no change to the document occurred. + :param doc: A partial update to an existing document. + :param doc_as_upsert: Set to true to use the contents of 'doc' as the value of + 'upsert' + :param if_primary_term: Only perform the operation if the document has this primary + term. + :param if_seq_no: Only perform the operation if the document has this sequence + number. + :param lang: The script language. + :param refresh: If 'true', Elasticsearch refreshes the affected shards to make + this operation visible to search, if 'wait_for' then wait for a refresh to + make this operation visible to search, if 'false' do nothing with refreshes. + :param require_alias: If true, the destination must be an index alias. + :param retry_on_conflict: Specify how many times should the operation be retried + when a conflict occurs. + :param routing: Custom value used to route operations to a specific shard. + :param script: Script to execute to update the document. + :param scripted_upsert: Set to true to execute the script whether or not the + document exists. + :param source: Set to false to disable source retrieval. You can also specify + a comma-separated list of the fields you want to retrieve. + :param source_excludes: Specify the source fields you want to exclude. + :param source_includes: Specify the source fields you want to retrieve. + :param timeout: Period to wait for dynamic mapping updates and active shards. + This guarantees Elasticsearch waits for at least the timeout before failing. + The actual wait time could be longer, particularly when multiple waits occur. + :param upsert: If the document does not already exist, the contents of 'upsert' + are inserted as a new document. If the document exists, the 'script' is executed. + :param wait_for_active_shards: The number of shard copies that must be active + before proceeding with the operations. Set to 'all' or any positive integer + up to the total number of shards in the index (number_of_replicas+1). Defaults + to 1 meaning the primary shard. """ - client, params = _deprecated_options(self, params) if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return client._perform_request( - "POST", - _make_path(index, "_terms_enum"), - params=params, - headers=headers, - body=body, - ) - - @query_params( - "exact_bounds", - "extent", - "grid_precision", - "grid_type", - "size", - "track_total_hits", + raise ValueError("Empty value passed for parameter 'index'") + if id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'id'") + if ( + index not in SKIP_IN_PATH + and type not in SKIP_IN_PATH + and id not in SKIP_IN_PATH + ): + __path = f"/{_quote(index)}/{_quote(type)}/{_quote(id)}/_update" + elif index not in SKIP_IN_PATH and id not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_update/{_quote(id)}" + else: + raise ValueError("Couldn't find a path for the given parameters") + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if detect_noop is not None: + __body["detect_noop"] = detect_noop + if doc is not None: + __body["doc"] = doc + if doc_as_upsert is not None: + __body["doc_as_upsert"] = doc_as_upsert + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if if_primary_term is not None: + __query["if_primary_term"] = if_primary_term + if if_seq_no is not None: + __query["if_seq_no"] = if_seq_no + if lang is not None: + __query["lang"] = lang + if pretty is not None: + __query["pretty"] = pretty + if refresh is not None: + __query["refresh"] = refresh + if require_alias is not None: + __query["require_alias"] = require_alias + if retry_on_conflict is not None: + __query["retry_on_conflict"] = retry_on_conflict + if routing is not None: + __query["routing"] = routing + if script is not None: + __body["script"] = script + if scripted_upsert is not None: + __body["scripted_upsert"] = scripted_upsert + if source is not None: + __body["_source"] = source + if source_excludes is not None: + __query["_source_excludes"] = source_excludes + if source_includes is not None: + __query["_source_includes"] = source_includes + if timeout is not None: + __query["timeout"] = timeout + if upsert is not None: + __body["upsert"] = upsert + if wait_for_active_shards is not None: + __query["wait_for_active_shards"] = wait_for_active_shards + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, + parameter_aliases={ + "_source": "source", + "_source_excludes": "source_excludes", + "_source_includes": "source_includes", + "from": "from_", + }, ) - def search_mvt( - self, index, field, zoom, x, y, body=None, params=None, headers=None - ): + def update_by_query( + self, + *, + index: Any, + allow_no_indices: Optional[bool] = None, + analyze_wildcard: Optional[bool] = None, + analyzer: Optional[str] = None, + conflicts: Optional[Any] = None, + default_operator: Optional[Any] = None, + df: Optional[str] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + from_: Optional[int] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + lenient: Optional[bool] = None, + max_docs: Optional[int] = None, + pipeline: Optional[str] = None, + preference: Optional[str] = None, + pretty: Optional[bool] = None, + query: Optional[Any] = None, + refresh: Optional[bool] = None, + request_cache: Optional[bool] = None, + requests_per_second: Optional[int] = None, + routing: Optional[Any] = None, + script: Optional[Any] = None, + scroll: Optional[Any] = None, + scroll_size: Optional[int] = None, + search_timeout: Optional[Any] = None, + search_type: Optional[Any] = None, + size: Optional[int] = None, + slice: Optional[Any] = None, + slices: Optional[int] = None, + sort: Optional[List[str]] = None, + source: Optional[Union[Any, bool]] = None, + source_excludes: Optional[Any] = None, + source_includes: Optional[Any] = None, + stats: Optional[List[str]] = None, + terminate_after: Optional[int] = None, + timeout: Optional[Any] = None, + version: Optional[bool] = None, + version_type: Optional[bool] = None, + wait_for_active_shards: Optional[Any] = None, + wait_for_completion: Optional[bool] = None, + ) -> Any: """ - Searches a vector tile for geospatial values. Returns results as a binary - Mapbox vector tile. - - ``_ + Performs an update on every document in the index without changing the source, + for example to pick up a mapping change. - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - - :arg index: Comma-separated list of data streams, indices, or - aliases to search - :arg field: Field containing geospatial data to return - :arg zoom: Zoom level for the vector tile to search - :arg x: X coordinate for the vector tile to search - :arg y: Y coordinate for the vector tile to search - :arg body: Search request body. - :arg exact_bounds: If false, the meta layer's feature is the - bounding box of the tile. If true, the meta layer's feature is a - bounding box resulting from a `geo_bounds` aggregation. - :arg extent: Size, in pixels, of a side of the vector tile. - Default: 4096 - :arg grid_precision: Additional zoom levels available through - the aggs layer. Accepts 0-8. Default: 8 - :arg grid_type: Determines the geometry type for features in the - aggs layer. Valid choices: grid, point, centroid Default: grid - :arg size: Maximum number of features to return in the hits - layer. Accepts 0-10000. Default: 10000 - :arg track_total_hits: Indicate if the number of documents that - match the query should be tracked. A number can also be specified, to - accurately track the total hit count up to the number. - """ - client, params = _deprecated_options(self, params) - for param in (index, field, zoom, x, y): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "POST", - _make_path(index, "_mvt", field, zoom, x, y), - params=params, - headers=headers, - body=body, - ) + ``_ - @query_params("routing") - def knn_search(self, index, body=None, params=None, headers=None): + :param index: A comma-separated list of index names to search; use `_all` or + empty string to perform the operation on all indices + :param 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) + :param analyze_wildcard: Specify whether wildcard and prefix queries should be + analyzed (default: false) + :param analyzer: The analyzer to use for the query string + :param conflicts: + :param default_operator: The default operator for query string query (AND or + OR) + :param df: The field to use as default where no field prefix is given in the + query string + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param from_: Starting offset (default: 0) + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param lenient: Specify whether format-based query failures (such as providing + text to a numeric field) should be ignored + :param max_docs: + :param pipeline: Ingest pipeline to set on index requests made by this action. + (default: none) + :param preference: Specify the node or shard the operation should be performed + on (default: random) + :param query: + :param refresh: Should the affected indexes be refreshed? + :param request_cache: Specify if request cache should be used for this request + or not, defaults to index level setting + :param requests_per_second: The throttle to set on this request in sub-requests + per second. -1 means no throttle. + :param routing: A comma-separated list of specific routing values + :param script: + :param scroll: Specify how long a consistent view of the index should be maintained + for scrolled search + :param scroll_size: Size on the scroll request powering the update by query + :param search_timeout: Explicit timeout for each search request. Defaults to + no timeout. + :param search_type: Search operation type + :param size: + :param slice: + :param 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`. + :param sort: A comma-separated list of : pairs + :param source: True or false to return the _source field or not, or a list of + fields to return + :param source_excludes: A list of fields to exclude from the returned _source + field + :param source_includes: A list of fields to extract and return from the _source + field + :param stats: Specific 'tag' of the request for logging and statistical purposes + :param terminate_after: The maximum number of documents to collect for each shard, + upon reaching which the query execution will terminate early. + :param timeout: Time each individual bulk request should wait for shards that + are unavailable. + :param version: Specify whether to return document version as part of a hit + :param version_type: Should the document increment the version number (internal) + on hit or not (reindex) + :param wait_for_active_shards: Sets the number of shard copies that must be active + before proceeding with the update by query operation. Defaults to 1, meaning + the primary shard only. Set to `all` for all shard copies, otherwise set + to any non-negative value less than or equal to the total number of copies + for the shard (number of replicas + 1) + :param wait_for_completion: Should the request should block until the update + by query operation is complete. """ - Performs a kNN search. - - ``_ - - .. warning:: + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + __path = f"/{_quote(index)}/_update_by_query" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if analyze_wildcard is not None: + __query["analyze_wildcard"] = analyze_wildcard + if analyzer is not None: + __query["analyzer"] = analyzer + if conflicts is not None: + __body["conflicts"] = conflicts + if default_operator is not None: + __query["default_operator"] = default_operator + if df is not None: + __query["df"] = df + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if from_ is not None: + __query["from"] = from_ + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if lenient is not None: + __query["lenient"] = lenient + if max_docs is not None: + __body["max_docs"] = max_docs + if pipeline is not None: + __query["pipeline"] = pipeline + if preference is not None: + __query["preference"] = preference + if pretty is not None: + __query["pretty"] = pretty + if query is not None: + __body["query"] = query + if refresh is not None: + __query["refresh"] = refresh + if request_cache is not None: + __query["request_cache"] = request_cache + if requests_per_second is not None: + __query["requests_per_second"] = requests_per_second + if routing is not None: + __query["routing"] = routing + if script is not None: + __body["script"] = script + if scroll is not None: + __query["scroll"] = scroll + if scroll_size is not None: + __query["scroll_size"] = scroll_size + if search_timeout is not None: + __query["search_timeout"] = search_timeout + if search_type is not None: + __query["search_type"] = search_type + if size is not None: + __query["size"] = size + if slice is not None: + __body["slice"] = slice + if slices is not None: + __query["slices"] = slices + if sort is not None: + __query["sort"] = sort + if source is not None: + __query["_source"] = source + if source_excludes is not None: + __query["_source_excludes"] = source_excludes + if source_includes is not None: + __query["_source_includes"] = source_includes + if stats is not None: + __query["stats"] = stats + if terminate_after is not None: + __query["terminate_after"] = terminate_after + if timeout is not None: + __query["timeout"] = timeout + if version is not None: + __query["version"] = version + if version_type is not None: + __query["version_type"] = version_type + if wait_for_active_shards is not None: + __query["wait_for_active_shards"] = wait_for_active_shards + if wait_for_completion is not None: + __query["wait_for_completion"] = wait_for_completion + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters() + def update_by_query_rethrottle( + self, + *, + task_id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + requests_per_second: Optional[int] = None, + ) -> Any: + """ + Changes the number of requests per second for a particular Update By Query operation. - This API is **experimental** so may include breaking changes - or be removed in a future version + ``_ - :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 - :arg routing: A comma-separated list of specific routing values + :param task_id: The task id to rethrottle + :param requests_per_second: The throttle to set on this request in floating sub-requests + per second. -1 means set no throttle. """ - client, params = _deprecated_options(self, params) - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return client._perform_request( - "POST", - _make_path(index, "_knn_search"), - params=params, - headers=headers, - body=body, - ) + if task_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'task_id'") + __path = f"/_update_by_query/{_quote(task_id)}/_rethrottle" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if requests_per_second is not None: + __query["requests_per_second"] = requests_per_second + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) diff --git a/elasticsearch/_sync/client/__init__.pyi b/elasticsearch/_sync/client/__init__.pyi deleted file mode 100644 index 70eef7519..000000000 --- a/elasticsearch/_sync/client/__init__.pyi +++ /dev/null @@ -1,1197 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -import logging -from typing import Any, Collection, MutableMapping, Optional, Tuple, Type, Union - -from elastic_transport import HeadApiResponse, ObjectApiResponse, Transport - -from ._base import BaseClient -from .async_search import AsyncSearchClient -from .autoscaling import AutoscalingClient -from .cat import CatClient -from .ccr import CcrClient -from .cluster import ClusterClient -from .dangling_indices import DanglingIndicesClient -from .enrich import EnrichClient -from .eql import EqlClient -from .features import FeaturesClient -from .fleet import FleetClient -from .graph import GraphClient -from .ilm import IlmClient -from .indices import IndicesClient -from .ingest import IngestClient -from .license import LicenseClient -from .migration import MigrationClient -from .ml import MlClient -from .monitoring import MonitoringClient -from .nodes import NodesClient -from .rollup import RollupClient -from .searchable_snapshots import SearchableSnapshotsClient -from .security import SecurityClient -from .shutdown import ShutdownClient -from .slm import SlmClient -from .snapshot import SnapshotClient -from .sql import SqlClient -from .ssl import SslClient -from .tasks import TasksClient -from .text_structure import TextStructureClient -from .transform import TransformClient -from .watcher import WatcherClient -from .xpack import XPackClient - -logger: logging.Logger - -class Elasticsearch(BaseClient): - transport: Transport - - async_search: AsyncSearchClient - autoscaling: AutoscalingClient - cat: CatClient - cluster: ClusterClient - indices: IndicesClient - ingest: IngestClient - nodes: NodesClient - snapshot: SnapshotClient - tasks: TasksClient - - xpack: XPackClient - ccr: CcrClient - dangling_indices: DanglingIndicesClient - enrich: EnrichClient - eql: EqlClient - features: FeaturesClient - fleet: FleetClient - graph: GraphClient - ilm: IlmClient - license: LicenseClient - migration: MigrationClient - ml: MlClient - monitoring: MonitoringClient - rollup: RollupClient - searchable_snapshots: SearchableSnapshotsClient - security: SecurityClient - slm: SlmClient - shutdown: ShutdownClient - sql: SqlClient - ssl: SslClient - text_structure: TextStructureClient - transform: TransformClient - watcher: WatcherClient - def __init__( - self, - hosts: Any = ..., - transport_class: Type[Transport] = ..., - **kwargs: Any, - ) -> None: ... - def __repr__(self) -> str: ... - def __enter__(self) -> "Elasticsearch": ... - def __exit__(self, *_: Any) -> None: ... - def close(self) -> None: ... - # AUTO-GENERATED-API-DEFINITIONS # - def ping( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> HeadApiResponse: ... - def info( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def create( - self, - index: Any, - id: Any, - *, - body: Any, - doc_type: Optional[Any] = ..., - pipeline: Optional[Any] = ..., - refresh: Optional[Any] = ..., - routing: Optional[Any] = ..., - timeout: Optional[Any] = ..., - version: Optional[Any] = ..., - version_type: Optional[Any] = ..., - wait_for_active_shards: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def index( - self, - index: Any, - *, - body: Any, - id: Optional[Any] = ..., - if_primary_term: Optional[Any] = ..., - if_seq_no: Optional[Any] = ..., - op_type: Optional[Any] = ..., - pipeline: Optional[Any] = ..., - refresh: Optional[Any] = ..., - require_alias: Optional[Any] = ..., - routing: Optional[Any] = ..., - timeout: Optional[Any] = ..., - version: Optional[Any] = ..., - version_type: Optional[Any] = ..., - wait_for_active_shards: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def bulk( - self, - *, - body: Any, - index: Optional[Any] = ..., - doc_type: Optional[Any] = ..., - _source: Optional[Any] = ..., - _source_excludes: Optional[Any] = ..., - _source_includes: Optional[Any] = ..., - pipeline: Optional[Any] = ..., - refresh: Optional[Any] = ..., - require_alias: Optional[Any] = ..., - routing: Optional[Any] = ..., - timeout: Optional[Any] = ..., - wait_for_active_shards: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def clear_scroll( - self, - *, - body: Optional[Any] = ..., - scroll_id: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def count( - self, - *, - body: Optional[Any] = ..., - index: Optional[Any] = ..., - allow_no_indices: Optional[Any] = ..., - analyze_wildcard: Optional[Any] = ..., - analyzer: Optional[Any] = ..., - default_operator: Optional[Any] = ..., - df: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - ignore_throttled: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - lenient: Optional[Any] = ..., - min_score: Optional[Any] = ..., - preference: Optional[Any] = ..., - q: Optional[Any] = ..., - routing: Optional[Any] = ..., - terminate_after: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def delete( - self, - index: Any, - id: Any, - *, - doc_type: Optional[Any] = ..., - if_primary_term: Optional[Any] = ..., - if_seq_no: Optional[Any] = ..., - refresh: Optional[Any] = ..., - routing: Optional[Any] = ..., - timeout: Optional[Any] = ..., - version: Optional[Any] = ..., - version_type: Optional[Any] = ..., - wait_for_active_shards: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def delete_by_query( - self, - index: Any, - *, - body: Any, - _source: Optional[Any] = ..., - _source_excludes: Optional[Any] = ..., - _source_includes: Optional[Any] = ..., - allow_no_indices: Optional[Any] = ..., - analyze_wildcard: Optional[Any] = ..., - analyzer: Optional[Any] = ..., - conflicts: Optional[Any] = ..., - default_operator: Optional[Any] = ..., - df: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - from_: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - lenient: Optional[Any] = ..., - max_docs: Optional[Any] = ..., - preference: Optional[Any] = ..., - q: Optional[Any] = ..., - refresh: Optional[Any] = ..., - request_cache: Optional[Any] = ..., - requests_per_second: Optional[Any] = ..., - routing: Optional[Any] = ..., - scroll: Optional[Any] = ..., - scroll_size: Optional[Any] = ..., - search_timeout: Optional[Any] = ..., - search_type: Optional[Any] = ..., - slices: Optional[Any] = ..., - sort: Optional[Any] = ..., - stats: Optional[Any] = ..., - terminate_after: Optional[Any] = ..., - timeout: Optional[Any] = ..., - version: Optional[Any] = ..., - wait_for_active_shards: Optional[Any] = ..., - wait_for_completion: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def delete_by_query_rethrottle( - self, - task_id: Any, - *, - requests_per_second: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def delete_script( - self, - id: Any, - *, - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def exists( - self, - index: Any, - id: Any, - *, - _source: Optional[Any] = ..., - _source_excludes: Optional[Any] = ..., - _source_includes: Optional[Any] = ..., - preference: Optional[Any] = ..., - realtime: Optional[Any] = ..., - refresh: Optional[Any] = ..., - routing: Optional[Any] = ..., - stored_fields: Optional[Any] = ..., - version: Optional[Any] = ..., - version_type: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> HeadApiResponse: ... - def exists_source( - self, - index: Any, - id: Any, - *, - doc_type: Optional[Any] = ..., - _source: Optional[Any] = ..., - _source_excludes: Optional[Any] = ..., - _source_includes: Optional[Any] = ..., - preference: Optional[Any] = ..., - realtime: Optional[Any] = ..., - refresh: Optional[Any] = ..., - routing: Optional[Any] = ..., - version: Optional[Any] = ..., - version_type: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> HeadApiResponse: ... - def explain( - self, - index: Any, - id: Any, - *, - body: Optional[Any] = ..., - _source: Optional[Any] = ..., - _source_excludes: Optional[Any] = ..., - _source_includes: Optional[Any] = ..., - analyze_wildcard: Optional[Any] = ..., - analyzer: Optional[Any] = ..., - default_operator: Optional[Any] = ..., - df: Optional[Any] = ..., - lenient: Optional[Any] = ..., - preference: Optional[Any] = ..., - q: Optional[Any] = ..., - routing: Optional[Any] = ..., - stored_fields: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def field_caps( - self, - *, - body: Optional[Any] = ..., - index: Optional[Any] = ..., - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - fields: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - include_unmapped: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get( - self, - index: Any, - id: Any, - *, - _source: Optional[Any] = ..., - _source_excludes: Optional[Any] = ..., - _source_includes: Optional[Any] = ..., - preference: Optional[Any] = ..., - realtime: Optional[Any] = ..., - refresh: Optional[Any] = ..., - routing: Optional[Any] = ..., - stored_fields: Optional[Any] = ..., - version: Optional[Any] = ..., - version_type: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_script( - self, - id: Any, - *, - master_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_source( - self, - index: Any, - id: Any, - *, - _source: Optional[Any] = ..., - _source_excludes: Optional[Any] = ..., - _source_includes: Optional[Any] = ..., - preference: Optional[Any] = ..., - realtime: Optional[Any] = ..., - refresh: Optional[Any] = ..., - routing: Optional[Any] = ..., - version: Optional[Any] = ..., - version_type: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def mget( - self, - *, - body: Any, - index: Optional[Any] = ..., - _source: Optional[Any] = ..., - _source_excludes: Optional[Any] = ..., - _source_includes: Optional[Any] = ..., - preference: Optional[Any] = ..., - realtime: Optional[Any] = ..., - refresh: Optional[Any] = ..., - routing: Optional[Any] = ..., - stored_fields: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def msearch( - self, - *, - body: Any, - index: Optional[Any] = ..., - ccs_minimize_roundtrips: Optional[Any] = ..., - max_concurrent_searches: Optional[Any] = ..., - max_concurrent_shard_requests: Optional[Any] = ..., - pre_filter_shard_size: Optional[Any] = ..., - rest_total_hits_as_int: Optional[Any] = ..., - search_type: Optional[Any] = ..., - typed_keys: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def put_script( - self, - id: Any, - *, - body: Any, - context: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def rank_eval( - self, - *, - body: Any, - index: Optional[Any] = ..., - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - search_type: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def reindex( - self, - *, - body: Any, - max_docs: Optional[Any] = ..., - refresh: Optional[Any] = ..., - requests_per_second: Optional[Any] = ..., - scroll: Optional[Any] = ..., - slices: Optional[Any] = ..., - timeout: Optional[Any] = ..., - wait_for_active_shards: Optional[Any] = ..., - wait_for_completion: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def reindex_rethrottle( - self, - task_id: Any, - *, - requests_per_second: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def render_search_template( - self, - *, - body: Optional[Any] = ..., - id: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def scripts_painless_execute( - self, - *, - body: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def scroll( - self, - *, - body: Optional[Any] = ..., - scroll_id: Optional[Any] = ..., - rest_total_hits_as_int: Optional[Any] = ..., - scroll: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def search( - self, - *, - body: Optional[Any] = ..., - index: Optional[Any] = ..., - _source: Optional[Any] = ..., - _source_excludes: Optional[Any] = ..., - _source_includes: Optional[Any] = ..., - allow_no_indices: Optional[Any] = ..., - allow_partial_search_results: Optional[Any] = ..., - analyze_wildcard: Optional[Any] = ..., - analyzer: Optional[Any] = ..., - batched_reduce_size: Optional[Any] = ..., - ccs_minimize_roundtrips: Optional[Any] = ..., - default_operator: Optional[Any] = ..., - df: Optional[Any] = ..., - docvalue_fields: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - explain: Optional[Any] = ..., - from_: Optional[Any] = ..., - ignore_throttled: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - lenient: Optional[Any] = ..., - max_concurrent_shard_requests: Optional[Any] = ..., - min_compatible_shard_node: Optional[Any] = ..., - pre_filter_shard_size: Optional[Any] = ..., - preference: Optional[Any] = ..., - q: Optional[Any] = ..., - request_cache: Optional[Any] = ..., - rest_total_hits_as_int: Optional[Any] = ..., - routing: Optional[Any] = ..., - scroll: Optional[Any] = ..., - search_type: Optional[Any] = ..., - seq_no_primary_term: Optional[Any] = ..., - size: Optional[Any] = ..., - sort: Optional[Any] = ..., - stats: Optional[Any] = ..., - stored_fields: Optional[Any] = ..., - suggest_field: Optional[Any] = ..., - suggest_mode: Optional[Any] = ..., - suggest_size: Optional[Any] = ..., - suggest_text: Optional[Any] = ..., - terminate_after: Optional[Any] = ..., - timeout: Optional[Any] = ..., - track_scores: Optional[Any] = ..., - track_total_hits: Optional[Any] = ..., - typed_keys: Optional[Any] = ..., - version: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def search_shards( - self, - *, - index: Optional[Any] = ..., - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - local: Optional[Any] = ..., - preference: Optional[Any] = ..., - routing: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def update( - self, - index: Any, - id: Any, - *, - body: Any, - doc_type: Optional[Any] = ..., - _source: Optional[Any] = ..., - _source_excludes: Optional[Any] = ..., - _source_includes: Optional[Any] = ..., - if_primary_term: Optional[Any] = ..., - if_seq_no: Optional[Any] = ..., - lang: Optional[Any] = ..., - refresh: Optional[Any] = ..., - require_alias: Optional[Any] = ..., - retry_on_conflict: Optional[Any] = ..., - routing: Optional[Any] = ..., - timeout: Optional[Any] = ..., - wait_for_active_shards: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def update_by_query_rethrottle( - self, - task_id: Any, - *, - requests_per_second: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_script_context( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_script_languages( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def msearch_template( - self, - *, - body: Any, - index: Optional[Any] = ..., - ccs_minimize_roundtrips: Optional[Any] = ..., - max_concurrent_searches: Optional[Any] = ..., - rest_total_hits_as_int: Optional[Any] = ..., - search_type: Optional[Any] = ..., - typed_keys: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def mtermvectors( - self, - *, - body: Optional[Any] = ..., - index: Optional[Any] = ..., - field_statistics: Optional[Any] = ..., - fields: Optional[Any] = ..., - ids: Optional[Any] = ..., - offsets: Optional[Any] = ..., - payloads: Optional[Any] = ..., - positions: Optional[Any] = ..., - preference: Optional[Any] = ..., - realtime: Optional[Any] = ..., - routing: Optional[Any] = ..., - term_statistics: Optional[Any] = ..., - version: Optional[Any] = ..., - version_type: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def search_template( - self, - *, - body: Any, - index: Optional[Any] = ..., - allow_no_indices: Optional[Any] = ..., - ccs_minimize_roundtrips: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - explain: Optional[Any] = ..., - ignore_throttled: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - preference: Optional[Any] = ..., - profile: Optional[Any] = ..., - rest_total_hits_as_int: Optional[Any] = ..., - routing: Optional[Any] = ..., - scroll: Optional[Any] = ..., - search_type: Optional[Any] = ..., - typed_keys: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def termvectors( - self, - index: Any, - *, - body: Optional[Any] = ..., - id: Optional[Any] = ..., - field_statistics: Optional[Any] = ..., - fields: Optional[Any] = ..., - offsets: Optional[Any] = ..., - payloads: Optional[Any] = ..., - positions: Optional[Any] = ..., - preference: Optional[Any] = ..., - realtime: Optional[Any] = ..., - routing: Optional[Any] = ..., - term_statistics: Optional[Any] = ..., - version: Optional[Any] = ..., - version_type: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def update_by_query( - self, - index: Any, - *, - body: Optional[Any] = ..., - _source: Optional[Any] = ..., - _source_excludes: Optional[Any] = ..., - _source_includes: Optional[Any] = ..., - allow_no_indices: Optional[Any] = ..., - analyze_wildcard: Optional[Any] = ..., - analyzer: Optional[Any] = ..., - conflicts: Optional[Any] = ..., - default_operator: Optional[Any] = ..., - df: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - from_: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - lenient: Optional[Any] = ..., - max_docs: Optional[Any] = ..., - pipeline: Optional[Any] = ..., - preference: Optional[Any] = ..., - q: Optional[Any] = ..., - refresh: Optional[Any] = ..., - request_cache: Optional[Any] = ..., - requests_per_second: Optional[Any] = ..., - routing: Optional[Any] = ..., - scroll: Optional[Any] = ..., - scroll_size: Optional[Any] = ..., - search_timeout: Optional[Any] = ..., - search_type: Optional[Any] = ..., - slices: Optional[Any] = ..., - sort: Optional[Any] = ..., - stats: Optional[Any] = ..., - terminate_after: Optional[Any] = ..., - timeout: Optional[Any] = ..., - version: Optional[Any] = ..., - version_type: Optional[Any] = ..., - wait_for_active_shards: Optional[Any] = ..., - wait_for_completion: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def close_point_in_time( - self, - *, - body: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def open_point_in_time( - self, - index: Any, - *, - expand_wildcards: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - keep_alive: Optional[Any] = ..., - preference: Optional[Any] = ..., - routing: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def terms_enum( - self, - index: Any, - *, - body: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def search_mvt( - self, - index: Any, - field: Any, - zoom: Any, - x: Any, - y: Any, - *, - body: Optional[Any] = ..., - exact_bounds: Optional[Any] = ..., - extent: Optional[Any] = ..., - grid_precision: Optional[Any] = ..., - grid_type: Optional[Any] = ..., - size: Optional[Any] = ..., - track_total_hits: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> Any: ... - def knn_search( - self, - index: Any, - *, - body: Optional[Any] = ..., - routing: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_sync/client/_base.py b/elasticsearch/_sync/client/_base.py index a43d799d2..bd1138000 100644 --- a/elasticsearch/_sync/client/_base.py +++ b/elasticsearch/_sync/client/_base.py @@ -45,7 +45,7 @@ ) from elastic_transport.client_utils import DEFAULT, DefaultType, resolve_default -from ...compat import urlencode, warn_stacklevel +from ...compat import warn_stacklevel from ...exceptions import ( HTTP_EXCEPTIONS, ApiError, @@ -250,16 +250,8 @@ def _perform_request( method: str, target: str, headers: Optional[Mapping[str, str]] = None, - params: Optional[Mapping[str, str]] = None, body: Optional[Any] = None, ) -> ApiResponse[Any, Any]: - # Handle the passing of 'params' as additional query parameters. - # This behavior is deprecated and should be removed in 9.0.0. - if params: - if "?" in target: - raise ValueError("Can't add query to a target that already has a query") - target = f"{target}?{urlencode(params)}" - if headers: request_headers = self._headers.copy() request_headers.update(headers) @@ -418,11 +410,8 @@ def _perform_request( method: str, target: str, headers: Optional[Mapping[str, str]] = None, - params: Optional[Mapping[str, str]] = None, body: Optional[Any] = None, ) -> Any: # Use the internal clients .perform_request() implementation # so we take advantage of their transport options. - return self._client._perform_request( - method, target, headers=headers, params=params, body=body - ) + return self._client._perform_request(method, target, headers=headers, body=body) diff --git a/elasticsearch/_sync/client/async_search.py b/elasticsearch/_sync/client/async_search.py index 3269eb45e..f560aed92 100644 --- a/elasticsearch/_sync/client/async_search.py +++ b/elasticsearch/_sync/client/async_search.py @@ -15,218 +15,487 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params +from .utils import SKIP_IN_PATH, _quote, _quote_query, _rewrite_parameters class AsyncSearchClient(NamespacedClient): - @query_params() - def delete(self, id, params=None, headers=None): + @_rewrite_parameters() + def delete( + self, + *, + id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - 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. + 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 + :param id: The async search ID """ - client, params = _deprecated_options(self, params) if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'id'.") - - return client._perform_request( - "DELETE", _make_path("_async_search", id), params=params, headers=headers - ) + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/_async_search/{_quote(id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("DELETE", __target, headers=__headers) - @query_params("keep_alive", "typed_keys", "wait_for_completion_timeout") - def get(self, id, params=None, headers=None): + @_rewrite_parameters() + def get( + self, + *, + id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + keep_alive: Optional[Any] = None, + pretty: Optional[bool] = None, + typed_keys: Optional[bool] = None, + wait_for_completion_timeout: Optional[Any] = None, + ) -> Any: """ 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 - (partial or final) for this search will be available - :arg typed_keys: Specify whether aggregation and suggester names - should be prefixed by their respective types in the response - :arg wait_for_completion_timeout: Specify the time that the - request should block waiting for the final response + :param id: The async search ID + :param keep_alive: Specify the time interval in which the results (partial or + final) for this search will be available + :param typed_keys: Specify whether aggregation and suggester names should be + prefixed by their respective types in the response + :param wait_for_completion_timeout: Specify the time that the request should + block waiting for the final response """ - client, params = _deprecated_options(self, params) if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'id'.") + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/_async_search/{_quote(id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if keep_alive is not None: + __query["keep_alive"] = keep_alive + if pretty is not None: + __query["pretty"] = pretty + if typed_keys is not None: + __query["typed_keys"] = typed_keys + if wait_for_completion_timeout is not None: + __query["wait_for_completion_timeout"] = wait_for_completion_timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) - return client._perform_request( - "GET", _make_path("_async_search", id), params=params, headers=headers - ) - - @query_params( - "_source", - "_source_excludes", - "_source_includes", - "allow_no_indices", - "allow_partial_search_results", - "analyze_wildcard", - "analyzer", - "batched_reduce_size", - "default_operator", - "df", - "docvalue_fields", - "expand_wildcards", - "explain", - "from_", - "ignore_throttled", - "ignore_unavailable", - "keep_alive", - "keep_on_completion", - "lenient", - "max_concurrent_shard_requests", - "preference", - "q", - "request_cache", - "routing", - "search_type", - "seq_no_primary_term", - "size", - "sort", - "stats", - "stored_fields", - "suggest_field", - "suggest_mode", - "suggest_size", - "suggest_text", - "terminate_after", - "timeout", - "track_scores", - "track_total_hits", - "typed_keys", - "version", - "wait_for_completion_timeout", - ) - def submit(self, body=None, index=None, params=None, headers=None): + @_rewrite_parameters() + def status( + self, + *, + id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Executes a search request asynchronously. + Retrieves the status of a previously submitted async search request given its + ID. - ``_ + ``_ - :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 _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 - returned _source field - :arg _source_includes: A list of fields to extract and return - from the _source field - :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 allow_partial_search_results: Indicate if an error should - be returned if there is a partial search failure or timeout Default: - True - :arg analyze_wildcard: Specify whether wildcard and prefix - queries should be analyzed (default: false) - :arg analyzer: The analyzer to use for the query string - :arg batched_reduce_size: The number of shard results that - should be reduced at once on the coordinating node. This value should be - used as the granularity at which progress results will be made - available. Default: 5 - :arg default_operator: The default operator for query string - query (AND or OR) Valid choices: AND, OR Default: OR - :arg df: The field to use as default where no field prefix is - given in the query string - :arg docvalue_fields: A comma-separated list of fields to return - as the docvalue representation of a field for each hit - :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 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 - should be ignored when unavailable (missing or closed) - :arg keep_alive: Update the time interval in which the results - (partial or final) for this search will be available Default: 5d - :arg keep_on_completion: Control whether the response should be - stored in the cluster if it completed within the provided - [wait_for_completion] time (default: false) - :arg lenient: Specify whether format-based query failures (such - as providing text to a numeric field) should be ignored - :arg max_concurrent_shard_requests: The number of concurrent - shard requests per node this search executes concurrently. This value - should be used to limit the impact of the search on the cluster in order - to limit the number of concurrent shard requests Default: 5 - :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 request_cache: Specify if request cache should be used for - this request or not, defaults to true - :arg routing: A comma-separated list of specific routing values - :arg search_type: Search operation type Valid choices: - query_then_fetch, dfs_query_then_fetch - :arg seq_no_primary_term: Specify whether to return sequence - number and primary term of the last modification of each hit - :arg size: Number of hits to return (default: 10) - :arg sort: A comma-separated list of : pairs - :arg stats: Specific 'tag' of the request for logging and - statistical purposes - :arg stored_fields: A comma-separated list of stored fields to - return as part of a hit - :arg suggest_field: Specify which field to use for suggestions - :arg suggest_mode: Specify suggest mode Valid choices: missing, - popular, always Default: missing - :arg suggest_size: How many suggestions to return in response - :arg suggest_text: The source text for which the suggestions - should be returned - :arg terminate_after: The maximum number of documents to collect - for each shard, upon reaching which the query execution will terminate - early. - :arg timeout: Explicit operation timeout - :arg track_scores: Whether to calculate and return scores even - if they are not used for sorting - :arg track_total_hits: Indicate if the number of documents that - match the query should be tracked. A number can also be specified, to - accurately track the total hit count up to the number. - :arg typed_keys: Specify whether aggregation and suggester names - should be prefixed by their respective types in the response - :arg version: Specify whether to return document version as part - of a hit - :arg wait_for_completion_timeout: Specify the time that the - request should block waiting for the final response Default: 1s + :param id: The async search ID """ - client, params = _deprecated_options(self, params) - if params and "from_" in params: - params["from"] = params.pop("from_") - - return client._perform_request( - "POST", - _make_path(index, "_async_search"), - params=params, - headers=headers, - body=body, - ) + if id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/_async_search/status/{_quote(id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) - @query_params() - def status(self, id, params=None, headers=None): + @_rewrite_parameters( + body_fields=True, + parameter_aliases={ + "_source": "source", + "_source_excludes": "source_excludes", + "_source_includes": "source_includes", + "from": "from_", + }, + ) + def submit( + self, + *, + index: Optional[Any] = None, + aggregations: Optional[Dict[str, Any]] = None, + allow_no_indices: Optional[bool] = None, + allow_partial_search_results: Optional[bool] = None, + analyze_wildcard: Optional[bool] = None, + analyzer: Optional[str] = None, + batched_reduce_size: Optional[int] = None, + ccs_minimize_roundtrips: Optional[bool] = None, + collapse: Optional[Any] = None, + default_operator: Optional[Any] = None, + df: Optional[str] = None, + docvalue_fields: Optional[Union[Any, List[Any]]] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + explain: Optional[bool] = None, + fields: Optional[List[Any]] = None, + filter_path: Optional[Union[List[str], str]] = None, + from_: Optional[int] = None, + highlight: Optional[Any] = None, + human: Optional[bool] = None, + ignore_throttled: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + indices_boost: Optional[List[Dict[Any, float]]] = None, + keep_alive: Optional[Any] = None, + keep_on_completion: Optional[bool] = None, + lenient: Optional[bool] = None, + max_concurrent_shard_requests: Optional[int] = None, + min_compatible_shard_node: Optional[Any] = None, + min_score: Optional[float] = None, + pit: Optional[Any] = None, + post_filter: Optional[Any] = None, + pre_filter_shard_size: Optional[int] = None, + preference: Optional[str] = None, + pretty: Optional[bool] = None, + profile: Optional[bool] = None, + q: Optional[str] = None, + query: Optional[Any] = None, + request_cache: Optional[bool] = None, + rescore: Optional[Union[Any, List[Any]]] = None, + rest_total_hits_as_int: Optional[bool] = None, + routing: Optional[Any] = None, + runtime_mappings: Optional[Any] = None, + script_fields: Optional[Dict[str, Any]] = None, + scroll: Optional[Any] = None, + search_after: Optional[Any] = None, + search_type: Optional[Any] = None, + seq_no_primary_term: Optional[bool] = None, + size: Optional[int] = None, + slice: Optional[Any] = None, + sort: Optional[Any] = None, + source: Optional[Union[Any, bool]] = None, + source_excludes: Optional[Any] = None, + source_includes: Optional[Any] = None, + stats: Optional[List[str]] = None, + stored_fields: Optional[Any] = None, + suggest: Optional[Union[Any, Dict[str, Any]]] = None, + suggest_field: Optional[Any] = None, + suggest_mode: Optional[Any] = None, + suggest_size: Optional[int] = None, + suggest_text: Optional[str] = None, + terminate_after: Optional[int] = None, + timeout: Optional[str] = None, + track_scores: Optional[bool] = None, + track_total_hits: Optional[Union[bool, int]] = None, + typed_keys: Optional[bool] = None, + version: Optional[bool] = None, + wait_for_completion_timeout: Optional[Any] = None, + ) -> Any: """ - Retrieves the status of a previously submitted async search request given its - ID. + Executes a search request asynchronously. - ``_ + ``_ - :arg id: The async search ID + :param index: A comma-separated list of index names to search; use `_all` or + empty string to perform the operation on all indices + :param aggregations: + :param 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) + :param allow_partial_search_results: Indicate if an error should be returned + if there is a partial search failure or timeout + :param analyze_wildcard: Specify whether wildcard and prefix queries should be + analyzed (default: false) + :param analyzer: The analyzer to use for the query string + :param batched_reduce_size: The number of shard results that should be reduced + at once on the coordinating node. This value should be used as the granularity + at which progress results will be made available. + :param ccs_minimize_roundtrips: + :param collapse: + :param default_operator: The default operator for query string query (AND or + OR) + :param df: The field to use as default where no field prefix is given in the + query string + :param docvalue_fields: Array of wildcard (*) patterns. The request returns doc + values for field names matching these patterns in the hits.fields property + of the response. + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param explain: If true, returns detailed information about score computation + as part of a hit. + :param fields: Array of wildcard (*) patterns. The request returns values for + field names matching these patterns in the hits.fields property of the response. + :param from_: Starting document offset. By default, you cannot page through more + than 10,000 hits using the from and size parameters. To page through more + hits, use the search_after parameter. + :param highlight: + :param ignore_throttled: Whether specified concrete, expanded or aliased indices + should be ignored when throttled + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param indices_boost: Boosts the _score of documents from specified indices. + :param keep_alive: Update the time interval in which the results (partial or + final) for this search will be available + :param keep_on_completion: Control whether the response should be stored in the + cluster if it completed within the provided [wait_for_completion] time (default: + false) + :param lenient: Specify whether format-based query failures (such as providing + text to a numeric field) should be ignored + :param max_concurrent_shard_requests: The number of concurrent shard requests + per node this search executes concurrently. This value should be used to + limit the impact of the search on the cluster in order to limit the number + of concurrent shard requests + :param min_compatible_shard_node: + :param min_score: Minimum _score for matching documents. Documents with a lower + _score are not included in the search results. + :param pit: Limits the search to a point in time (PIT). If you provide a PIT, + you cannot specify an in the request path. + :param post_filter: + :param pre_filter_shard_size: + :param preference: Specify the node or shard the operation should be performed + on (default: random) + :param profile: + :param q: Query in the Lucene query string syntax + :param query: Defines the search definition using the Query DSL. + :param request_cache: Specify if request cache should be used for this request + or not, defaults to true + :param rescore: + :param rest_total_hits_as_int: + :param routing: A comma-separated list of specific routing values + :param runtime_mappings: Defines one or more runtime fields in the search request. + These fields take precedence over mapped fields with the same name. + :param script_fields: Retrieve a script evaluation (based on different fields) + for each hit. + :param scroll: + :param search_after: + :param search_type: Search operation type + :param seq_no_primary_term: If true, returns sequence number and primary term + of the last modification of each hit. See Optimistic concurrency control. + :param size: The number of hits to return. By default, you cannot page through + more than 10,000 hits using the from and size parameters. To page through + more hits, use the search_after parameter. + :param slice: + :param sort: + :param source: Indicates which source fields are returned for matching documents. + These fields are returned in the hits._source property of the search response. + :param source_excludes: A list of fields to exclude from the returned _source + field + :param source_includes: A list of fields to extract and return from the _source + field + :param stats: Stats groups to associate with the search. Each group maintains + a statistics aggregation for its associated searches. You can retrieve these + stats using the indices stats API. + :param stored_fields: List of stored fields to return as part of a hit. If no + fields are specified, no stored fields are included in the response. If this + field is specified, the _source parameter defaults to false. You can pass + _source: true to return both source fields and stored fields in the search + response. + :param suggest: + :param suggest_field: Specifies which field to use for suggestions. + :param suggest_mode: Specify suggest mode + :param suggest_size: How many suggestions to return in response + :param suggest_text: The source text for which the suggestions should be returned. + :param terminate_after: Maximum number of documents to collect for each shard. + If a query reaches this limit, Elasticsearch terminates the query early. + Elasticsearch collects documents before sorting. Defaults to 0, which does + not terminate query execution early. + :param timeout: Specifies the period of time to wait for a response from each + shard. If no response is received before the timeout expires, the request + fails and returns an error. Defaults to no timeout. + :param track_scores: If true, calculate and return document scores, even if the + scores are not used for sorting. + :param track_total_hits: Number of hits matching the query to count accurately. + If true, the exact number of hits is returned at the cost of some performance. + If false, the response does not include the total number of hits matching + the query. Defaults to 10,000 hits. + :param typed_keys: Specify whether aggregation and suggester names should be + prefixed by their respective types in the response + :param version: If true, returns document version as part of a hit. + :param wait_for_completion_timeout: Specify the time that the request should + block waiting for the final response """ - client, params = _deprecated_options(self, params) - if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'id'.") - - return client._perform_request( - "GET", - _make_path("_async_search", "status", id), - params=params, - headers=headers, - ) + if index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_async_search" + else: + __path = "/_async_search" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if aggregations is not None: + __body["aggregations"] = aggregations + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if allow_partial_search_results is not None: + __query["allow_partial_search_results"] = allow_partial_search_results + if analyze_wildcard is not None: + __query["analyze_wildcard"] = analyze_wildcard + if analyzer is not None: + __query["analyzer"] = analyzer + if batched_reduce_size is not None: + __query["batched_reduce_size"] = batched_reduce_size + if ccs_minimize_roundtrips is not None: + __query["ccs_minimize_roundtrips"] = ccs_minimize_roundtrips + if collapse is not None: + __body["collapse"] = collapse + if default_operator is not None: + __query["default_operator"] = default_operator + if df is not None: + __query["df"] = df + if docvalue_fields is not None: + __body["docvalue_fields"] = docvalue_fields + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if explain is not None: + __body["explain"] = explain + if fields is not None: + __body["fields"] = fields + if filter_path is not None: + __query["filter_path"] = filter_path + if from_ is not None: + __body["from"] = from_ + if highlight is not None: + __body["highlight"] = highlight + if human is not None: + __query["human"] = human + if ignore_throttled is not None: + __query["ignore_throttled"] = ignore_throttled + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if indices_boost is not None: + __body["indices_boost"] = indices_boost + if keep_alive is not None: + __query["keep_alive"] = keep_alive + if keep_on_completion is not None: + __query["keep_on_completion"] = keep_on_completion + if lenient is not None: + __query["lenient"] = lenient + if max_concurrent_shard_requests is not None: + __query["max_concurrent_shard_requests"] = max_concurrent_shard_requests + if min_compatible_shard_node is not None: + __query["min_compatible_shard_node"] = min_compatible_shard_node + if min_score is not None: + __body["min_score"] = min_score + if pit is not None: + __body["pit"] = pit + if post_filter is not None: + __body["post_filter"] = post_filter + if pre_filter_shard_size is not None: + __query["pre_filter_shard_size"] = pre_filter_shard_size + if preference is not None: + __query["preference"] = preference + if pretty is not None: + __query["pretty"] = pretty + if profile is not None: + __body["profile"] = profile + if q is not None: + __query["q"] = q + if query is not None: + __body["query"] = query + if request_cache is not None: + __query["request_cache"] = request_cache + if rescore is not None: + __body["rescore"] = rescore + if rest_total_hits_as_int is not None: + __query["rest_total_hits_as_int"] = rest_total_hits_as_int + if routing is not None: + __query["routing"] = routing + if runtime_mappings is not None: + __body["runtime_mappings"] = runtime_mappings + if script_fields is not None: + __body["script_fields"] = script_fields + if scroll is not None: + __query["scroll"] = scroll + if search_after is not None: + __body["search_after"] = search_after + if search_type is not None: + __query["search_type"] = search_type + if seq_no_primary_term is not None: + __body["seq_no_primary_term"] = seq_no_primary_term + if size is not None: + __body["size"] = size + if slice is not None: + __body["slice"] = slice + if sort is not None: + __body["sort"] = sort + if source is not None: + __body["_source"] = source + if source_excludes is not None: + __query["_source_excludes"] = source_excludes + if source_includes is not None: + __query["_source_includes"] = source_includes + if stats is not None: + __body["stats"] = stats + if stored_fields is not None: + __body["stored_fields"] = stored_fields + if suggest is not None: + __body["suggest"] = suggest + if suggest_field is not None: + __query["suggest_field"] = suggest_field + if suggest_mode is not None: + __query["suggest_mode"] = suggest_mode + if suggest_size is not None: + __query["suggest_size"] = suggest_size + if suggest_text is not None: + __query["suggest_text"] = suggest_text + if terminate_after is not None: + __body["terminate_after"] = terminate_after + if timeout is not None: + __body["timeout"] = timeout + if track_scores is not None: + __body["track_scores"] = track_scores + if track_total_hits is not None: + __body["track_total_hits"] = track_total_hits + if typed_keys is not None: + __query["typed_keys"] = typed_keys + if version is not None: + __body["version"] = version + if wait_for_completion_timeout is not None: + __query["wait_for_completion_timeout"] = wait_for_completion_timeout + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("POST", __target, headers=__headers, body=__body) diff --git a/elasticsearch/_sync/client/async_search.pyi b/elasticsearch/_sync/client/async_search.pyi deleted file mode 100644 index 18b741ade..000000000 --- a/elasticsearch/_sync/client/async_search.pyi +++ /dev/null @@ -1,137 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class AsyncSearchClient(NamespacedClient): - def delete( - self, - id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get( - self, - id: Any, - *, - keep_alive: Optional[Any] = ..., - typed_keys: Optional[Any] = ..., - wait_for_completion_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def submit( - self, - *, - body: Optional[Any] = ..., - index: Optional[Any] = ..., - _source: Optional[Any] = ..., - _source_excludes: Optional[Any] = ..., - _source_includes: Optional[Any] = ..., - allow_no_indices: Optional[Any] = ..., - allow_partial_search_results: Optional[Any] = ..., - analyze_wildcard: Optional[Any] = ..., - analyzer: Optional[Any] = ..., - batched_reduce_size: Optional[Any] = ..., - default_operator: Optional[Any] = ..., - df: Optional[Any] = ..., - docvalue_fields: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - explain: Optional[Any] = ..., - from_: Optional[Any] = ..., - ignore_throttled: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - keep_alive: Optional[Any] = ..., - keep_on_completion: Optional[Any] = ..., - lenient: Optional[Any] = ..., - max_concurrent_shard_requests: Optional[Any] = ..., - preference: Optional[Any] = ..., - q: Optional[Any] = ..., - request_cache: Optional[Any] = ..., - routing: Optional[Any] = ..., - search_type: Optional[Any] = ..., - seq_no_primary_term: Optional[Any] = ..., - size: Optional[Any] = ..., - sort: Optional[Any] = ..., - stats: Optional[Any] = ..., - stored_fields: Optional[Any] = ..., - suggest_field: Optional[Any] = ..., - suggest_mode: Optional[Any] = ..., - suggest_size: Optional[Any] = ..., - suggest_text: Optional[Any] = ..., - terminate_after: Optional[Any] = ..., - timeout: Optional[Any] = ..., - track_scores: Optional[Any] = ..., - track_total_hits: Optional[Any] = ..., - typed_keys: Optional[Any] = ..., - version: Optional[Any] = ..., - wait_for_completion_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def status( - self, - id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_sync/client/autoscaling.py b/elasticsearch/_sync/client/autoscaling.py index 2a2d9d740..39d1fbb33 100644 --- a/elasticsearch/_sync/client/autoscaling.py +++ b/elasticsearch/_sync/client/autoscaling.py @@ -15,87 +15,159 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params +from .utils import SKIP_IN_PATH, _quote, _quote_query, _rewrite_parameters class AutoscalingClient(NamespacedClient): - @query_params() - def delete_autoscaling_policy(self, name, params=None, headers=None): + @_rewrite_parameters() + def delete_autoscaling_policy( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Deletes an autoscaling policy. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported. - ``_ + ``_ - :arg name: the name of the autoscaling policy + :param name: the name of the autoscaling policy """ - client, params = _deprecated_options(self, params) if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'name'.") - - return client._perform_request( - "DELETE", - _make_path("_autoscaling", "policy", name), - params=params, - headers=headers, - ) - - @query_params() - def put_autoscaling_policy(self, name, body, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_autoscaling/policy/{_quote(name)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + def get_autoscaling_capacity( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Creates a new autoscaling policy. Designed for indirect use by ECE/ESS and ECK. - Direct use is not supported. - - ``_ + Gets the current autoscaling capacity based on the configured autoscaling policy. + Designed for indirect use by ECE/ESS and ECK. Direct use is not supported. - :arg name: the name of the autoscaling policy - :arg body: the specification of the autoscaling policy + ``_ """ - client, params = _deprecated_options(self, params) - for param in (name, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._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): + __path = "/_autoscaling/capacity" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def get_autoscaling_policy( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Retrieves an autoscaling policy. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported. - ``_ + ``_ - :arg name: the name of the autoscaling policy + :param name: the name of the autoscaling policy """ - client, params = _deprecated_options(self, params) if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'name'.") - - return client._perform_request( - "GET", - _make_path("_autoscaling", "policy", name), - params=params, - headers=headers, - ) - - @query_params() - def get_autoscaling_capacity(self, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_autoscaling/policy/{_quote(name)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + body_name="policy", + ) + def put_autoscaling_policy( + self, + *, + name: Any, + policy: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Gets the current autoscaling capacity based on the configured autoscaling - policy. Designed for indirect use by ECE/ESS and ECK. Direct use is not - supported. + Creates a new autoscaling policy. Designed for indirect use by ECE/ESS and ECK. + Direct use is not supported. + + ``_ - ``_ + :param name: the name of the autoscaling policy + :param policy: """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", "/_autoscaling/capacity", params=params, headers=headers - ) + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + if policy is None: + raise ValueError("Empty value passed for parameter 'policy'") + __path = f"/_autoscaling/policy/{_quote(name)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + __body = policy + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("PUT", __target, headers=__headers, body=__body) diff --git a/elasticsearch/_sync/client/autoscaling.pyi b/elasticsearch/_sync/client/autoscaling.pyi deleted file mode 100644 index a69c21722..000000000 --- a/elasticsearch/_sync/client/autoscaling.pyi +++ /dev/null @@ -1,92 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class AutoscalingClient(NamespacedClient): - def delete_autoscaling_policy( - self, - name: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def put_autoscaling_policy( - self, - name: Any, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_autoscaling_policy( - self, - name: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_autoscaling_capacity( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_sync/client/cat.py b/elasticsearch/_sync/client/cat.py index e6001cb18..68a4a8fe3 100644 --- a/elasticsearch/_sync/client/cat.py +++ b/elasticsearch/_sync/client/cat.py @@ -15,790 +15,1954 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import _deprecated_options, _make_path, query_params +from .utils import SKIP_IN_PATH, _quote, _quote_query, _rewrite_parameters class CatClient(NamespacedClient): - @query_params("expand_wildcards", "format", "h", "help", "local", "s", "v") - def aliases(self, name=None, params=None, headers=None): + @_rewrite_parameters() + def aliases( + self, + *, + name: Optional[Any] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + h: Optional[Any] = None, + help: Optional[bool] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + s: Optional[List[str]] = None, + v: Optional[bool] = None, + ) -> Any: """ - Shows information about currently configured aliases to indices including - filter and routing infos. + 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 - concrete indices that are open, closed or both. Valid choices: open, - closed, hidden, none, all Default: all - :arg format: a short version of the Accept header, e.g. json, - yaml - :arg h: Comma-separated list of column names to display - :arg help: Return help information - :arg local: Return local information, do not retrieve the state - from master node (default: false) - :arg s: Comma-separated list of column names or column aliases - to sort by - :arg v: Verbose mode. Display column headers - """ - client, params = _deprecated_options(self, params) - return client._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): + :param name: A comma-separated list of alias names to return + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param format: Specifies the format to return the columnar data in, can be set + to `text`, `json`, `cbor`, `yaml`, or `smile`. + :param h: List of columns to appear in the response. Supports simple wildcards. + :param help: When set to `true` will output available columns. This option can't + be combined with any other query string option. + :param local: If `true`, the request computes the list of selected nodes from + the local cluster state. If `false` the list of selected nodes are computed + from the cluster state of the master node. In both cases the coordinating + node will send requests for further information to each selected node. + :param master_timeout: Period to wait for a connection to the master node. + :param s: List of columns that determine how the table should be sorted. Sorting + defaults to ascending and can be changed by setting `:asc` or `:desc` as + a suffix to the column name. + :param v: When set to `true` will enable verbose output. + """ + if name not in SKIP_IN_PATH: + __path = f"/_cat/aliases/{_quote(name)}" + else: + __path = "/_cat/aliases" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if h is not None: + __query["h"] = h + if help is not None: + __query["help"] = help + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if s is not None: + __query["s"] = s + if v is not None: + __query["v"] = v + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain,application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def allocation( + self, + *, + node_id: Optional[Any] = None, + bytes: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + h: Optional[Any] = None, + help: Optional[bool] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + s: Optional[List[str]] = None, + v: Optional[bool] = None, + ) -> Any: """ 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 - :arg bytes: The unit in which to display byte values Valid - 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 h: Comma-separated list of column names to display - :arg help: Return help information - :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 - :arg s: Comma-separated list of column names or column aliases - to sort by - :arg v: Verbose mode. Display column headers - """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", - _make_path("_cat", "allocation", node_id), - params=params, - headers=headers, - ) - - @query_params("format", "h", "help", "s", "v") - def count(self, index=None, params=None, headers=None): - """ - Provides quick access to the document count of the entire cluster, or - individual indices. + :param node_id: A comma-separated list of node IDs or names to limit the returned + information + :param bytes: The unit in which to display byte values + :param format: Specifies the format to return the columnar data in, can be set + to `text`, `json`, `cbor`, `yaml`, or `smile`. + :param h: List of columns to appear in the response. Supports simple wildcards. + :param help: When set to `true` will output available columns. This option can't + be combined with any other query string option. + :param local: If `true`, the request computes the list of selected nodes from + the local cluster state. If `false` the list of selected nodes are computed + from the cluster state of the master node. In both cases the coordinating + node will send requests for further information to each selected node. + :param master_timeout: Period to wait for a connection to the master node. + :param s: List of columns that determine how the table should be sorted. Sorting + defaults to ascending and can be changed by setting `:asc` or `:desc` as + a suffix to the column name. + :param v: When set to `true` will enable verbose output. + """ + if node_id not in SKIP_IN_PATH: + __path = f"/_cat/allocation/{_quote(node_id)}" + else: + __path = "/_cat/allocation" + __query: Dict[str, Any] = {} + if bytes is not None: + __query["bytes"] = bytes + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if h is not None: + __query["h"] = h + if help is not None: + __query["help"] = help + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if s is not None: + __query["s"] = s + if v is not None: + __query["v"] = v + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain,application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def count( + self, + *, + index: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + h: Optional[Any] = None, + help: Optional[bool] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + s: Optional[List[str]] = None, + v: Optional[bool] = None, + ) -> Any: + """ + 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 - :arg format: a short version of the Accept header, e.g. json, - yaml - :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 - to sort by - :arg v: Verbose mode. Display column headers + :param index: A comma-separated list of index names to limit the returned information + :param format: Specifies the format to return the columnar data in, can be set + to `text`, `json`, `cbor`, `yaml`, or `smile`. + :param h: List of columns to appear in the response. Supports simple wildcards. + :param help: When set to `true` will output available columns. This option can't + be combined with any other query string option. + :param local: If `true`, the request computes the list of selected nodes from + the local cluster state. If `false` the list of selected nodes are computed + from the cluster state of the master node. In both cases the coordinating + node will send requests for further information to each selected node. + :param master_timeout: Period to wait for a connection to the master node. + :param s: List of columns that determine how the table should be sorted. Sorting + defaults to ascending and can be changed by setting `:asc` or `:desc` as + a suffix to the column name. + :param v: When set to `true` will enable verbose output. + """ + if index not in SKIP_IN_PATH: + __path = f"/_cat/count/{_quote(index)}" + else: + __path = "/_cat/count" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if h is not None: + __query["h"] = h + if help is not None: + __query["help"] = help + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if s is not None: + __query["s"] = s + if v is not None: + __query["v"] = v + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain,application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def fielddata( + self, + *, + fields: Optional[Any] = None, + bytes: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + h: Optional[Any] = None, + help: Optional[bool] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + s: Optional[List[str]] = None, + v: Optional[bool] = None, + ) -> Any: """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", _make_path("_cat", "count", index), params=params, headers=headers - ) + Shows how much heap memory is currently being used by fielddata on every data + node in the cluster. + + ``_ - @query_params("format", "h", "help", "s", "time", "ts", "v") - def health(self, params=None, headers=None): + :param fields: A comma-separated list of fields to return the fielddata size + :param bytes: The unit in which to display byte values + :param format: Specifies the format to return the columnar data in, can be set + to `text`, `json`, `cbor`, `yaml`, or `smile`. + :param h: List of columns to appear in the response. Supports simple wildcards. + :param help: When set to `true` will output available columns. This option can't + be combined with any other query string option. + :param local: If `true`, the request computes the list of selected nodes from + the local cluster state. If `false` the list of selected nodes are computed + from the cluster state of the master node. In both cases the coordinating + node will send requests for further information to each selected node. + :param master_timeout: Period to wait for a connection to the master node. + :param s: List of columns that determine how the table should be sorted. Sorting + defaults to ascending and can be changed by setting `:asc` or `:desc` as + a suffix to the column name. + :param v: When set to `true` will enable verbose output. + """ + if fields not in SKIP_IN_PATH: + __path = f"/_cat/fielddata/{_quote(fields)}" + else: + __path = "/_cat/fielddata" + __query: Dict[str, Any] = {} + if bytes is not None: + __query["bytes"] = bytes + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if h is not None: + __query["h"] = h + if help is not None: + __query["help"] = help + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if s is not None: + __query["s"] = s + if v is not None: + __query["v"] = v + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain,application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def health( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + h: Optional[Any] = None, + help: Optional[bool] = None, + human: Optional[bool] = None, + include_timestamp: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + s: Optional[List[str]] = None, + ts: Optional[bool] = None, + v: Optional[bool] = None, + ) -> Any: """ Returns a concise representation of the cluster health. ``_ - :arg format: a short version of the Accept header, e.g. json, - yaml - :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 - to sort by - :arg time: The unit in which to display time values Valid - choices: d, h, m, s, ms, micros, nanos - :arg ts: Set to false to disable timestamping Default: True - :arg v: Verbose mode. Display column headers - """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", "/_cat/health", params=params, headers=headers - ) - - @query_params("help", "s") - def help(self, params=None, headers=None): + :param format: Specifies the format to return the columnar data in, can be set + to `text`, `json`, `cbor`, `yaml`, or `smile`. + :param h: List of columns to appear in the response. Supports simple wildcards. + :param help: When set to `true` will output available columns. This option can't + be combined with any other query string option. + :param include_timestamp: + :param local: If `true`, the request computes the list of selected nodes from + the local cluster state. If `false` the list of selected nodes are computed + from the cluster state of the master node. In both cases the coordinating + node will send requests for further information to each selected node. + :param master_timeout: Period to wait for a connection to the master node. + :param s: List of columns that determine how the table should be sorted. Sorting + defaults to ascending and can be changed by setting `:asc` or `:desc` as + a suffix to the column name. + :param ts: Set to false to disable timestamping + :param v: When set to `true` will enable verbose output. + """ + __path = "/_cat/health" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if h is not None: + __query["h"] = h + if help is not None: + __query["help"] = help + if human is not None: + __query["human"] = human + if include_timestamp is not None: + __query["include_timestamp"] = include_timestamp + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if s is not None: + __query["s"] = s + if ts is not None: + __query["ts"] = ts + if v is not None: + __query["v"] = v + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain,application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def help( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + h: Optional[Any] = None, + help: Optional[bool] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + s: Optional[List[str]] = None, + v: Optional[bool] = None, + ) -> Any: """ 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 - """ - client, params = _deprecated_options(self, params) - return client._perform_request("GET", "/_cat", params=params, headers=headers) - - @query_params( - "bytes", - "expand_wildcards", - "format", - "h", - "health", - "help", - "include_unloaded_segments", - "master_timeout", - "pri", - "s", - "time", - "v", - ) - def indices(self, index=None, params=None, headers=None): + :param format: Specifies the format to return the columnar data in, can be set + to `text`, `json`, `cbor`, `yaml`, or `smile`. + :param h: List of columns to appear in the response. Supports simple wildcards. + :param help: When set to `true` will output available columns. This option can't + be combined with any other query string option. + :param local: If `true`, the request computes the list of selected nodes from + the local cluster state. If `false` the list of selected nodes are computed + from the cluster state of the master node. In both cases the coordinating + node will send requests for further information to each selected node. + :param master_timeout: Period to wait for a connection to the master node. + :param s: List of columns that determine how the table should be sorted. Sorting + defaults to ascending and can be changed by setting `:asc` or `:desc` as + a suffix to the column name. + :param v: When set to `true` will enable verbose output. + """ + __path = "/_cat" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if h is not None: + __query["h"] = h + if help is not None: + __query["help"] = help + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if s is not None: + __query["s"] = s + if v is not None: + __query["v"] = v + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def indices( + self, + *, + index: Optional[Any] = None, + bytes: Optional[Any] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + h: Optional[Any] = None, + health: Optional[Any] = None, + help: Optional[bool] = None, + human: Optional[bool] = None, + include_unloaded_segments: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + pri: Optional[bool] = None, + s: Optional[List[str]] = None, + v: Optional[bool] = None, + ) -> Any: """ 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 - :arg bytes: The unit in which to display byte values Valid - choices: b, k, kb, m, mb, g, gb, t, tb, p, pb - :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: all - :arg format: a short version of the Accept header, e.g. json, - yaml - :arg h: Comma-separated list of column names to display - :arg health: A health status ("green", "yellow", or "red" to - filter only indices matching the specified health status Valid choices: - green, yellow, red - :arg help: Return help information - :arg include_unloaded_segments: If set to true segment stats - will include stats for segments that are not currently loaded into - memory - :arg master_timeout: Explicit operation timeout for connection - to master node - :arg pri: Set to true to return stats only for primary shards - :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 v: Verbose mode. Display column headers - """ - client, params = _deprecated_options(self, params) - return client._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): + :param index: A comma-separated list of index names to limit the returned information + :param bytes: The unit in which to display byte values + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param format: Specifies the format to return the columnar data in, can be set + to `text`, `json`, `cbor`, `yaml`, or `smile`. + :param h: List of columns to appear in the response. Supports simple wildcards. + :param health: A health status ("green", "yellow", or "red" to filter only indices + matching the specified health status + :param help: When set to `true` will output available columns. This option can't + be combined with any other query string option. + :param include_unloaded_segments: If set to true segment stats will include stats + for segments that are not currently loaded into memory + :param local: If `true`, the request computes the list of selected nodes from + the local cluster state. If `false` the list of selected nodes are computed + from the cluster state of the master node. In both cases the coordinating + node will send requests for further information to each selected node. + :param master_timeout: Period to wait for a connection to the master node. + :param pri: Set to true to return stats only for primary shards + :param s: List of columns that determine how the table should be sorted. Sorting + defaults to ascending and can be changed by setting `:asc` or `:desc` as + a suffix to the column name. + :param v: When set to `true` will enable verbose output. + """ + if index not in SKIP_IN_PATH: + __path = f"/_cat/indices/{_quote(index)}" + else: + __path = "/_cat/indices" + __query: Dict[str, Any] = {} + if bytes is not None: + __query["bytes"] = bytes + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if h is not None: + __query["h"] = h + if health is not None: + __query["health"] = health + if help is not None: + __query["help"] = help + if human is not None: + __query["human"] = human + if include_unloaded_segments is not None: + __query["include_unloaded_segments"] = include_unloaded_segments + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if pri is not None: + __query["pri"] = pri + if s is not None: + __query["s"] = s + if v is not None: + __query["v"] = v + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain,application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def master( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + h: Optional[Any] = None, + help: Optional[bool] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + s: Optional[List[str]] = None, + v: Optional[bool] = None, + ) -> Any: """ Returns information about the master node. ``_ - :arg format: a short version of the Accept header, e.g. json, - yaml - :arg h: Comma-separated list of column names to display - :arg help: Return help information - :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 - :arg s: Comma-separated list of column names or column aliases - to sort by - :arg v: Verbose mode. Display column headers - """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", "/_cat/master", params=params, headers=headers - ) - - @query_params( - "bytes", - "format", - "full_id", - "h", - "help", - "include_unloaded_segments", - "master_timeout", - "s", - "time", - "v", - ) - def nodes(self, params=None, headers=None): + :param format: Specifies the format to return the columnar data in, can be set + to `text`, `json`, `cbor`, `yaml`, or `smile`. + :param h: List of columns to appear in the response. Supports simple wildcards. + :param help: When set to `true` will output available columns. This option can't + be combined with any other query string option. + :param local: If `true`, the request computes the list of selected nodes from + the local cluster state. If `false` the list of selected nodes are computed + from the cluster state of the master node. In both cases the coordinating + node will send requests for further information to each selected node. + :param master_timeout: Period to wait for a connection to the master node. + :param s: List of columns that determine how the table should be sorted. Sorting + defaults to ascending and can be changed by setting `:asc` or `:desc` as + a suffix to the column name. + :param v: When set to `true` will enable verbose output. """ - Returns basic statistics about performance of cluster nodes. + __path = "/_cat/master" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if h is not None: + __query["h"] = h + if help is not None: + __query["help"] = help + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if s is not None: + __query["s"] = s + if v is not None: + __query["v"] = v + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain,application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def ml_data_frame_analytics( + self, + *, + id: Optional[Any] = None, + allow_no_match: Optional[bool] = None, + bytes: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + h: Optional[Any] = None, + help: Optional[bool] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + s: Optional[List[str]] = None, + v: Optional[bool] = None, + ) -> Any: + """ + Gets configuration and usage information about data frame analytics jobs. - ``_ + ``_ + + :param id: The ID of the data frame analytics to fetch + :param allow_no_match: Whether to ignore if a wildcard expression matches no + configs. (This includes `_all` string or when no configs have been specified) + :param bytes: The unit in which to display byte values + :param format: Specifies the format to return the columnar data in, can be set + to `text`, `json`, `cbor`, `yaml`, or `smile`. + :param h: List of columns to appear in the response. Supports simple wildcards. + :param help: When set to `true` will output available columns. This option can't + be combined with any other query string option. + :param local: If `true`, the request computes the list of selected nodes from + the local cluster state. If `false` the list of selected nodes are computed + from the cluster state of the master node. In both cases the coordinating + node will send requests for further information to each selected node. + :param master_timeout: Period to wait for a connection to the master node. + :param s: List of columns that determine how the table should be sorted. Sorting + defaults to ascending and can be changed by setting `:asc` or `:desc` as + a suffix to the column name. + :param v: When set to `true` will enable verbose output. + """ + if id not in SKIP_IN_PATH: + __path = f"/_cat/ml/data_frame/analytics/{_quote(id)}" + else: + __path = "/_cat/ml/data_frame/analytics" + __query: Dict[str, Any] = {} + if allow_no_match is not None: + __query["allow_no_match"] = allow_no_match + if bytes is not None: + __query["bytes"] = bytes + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if h is not None: + __query["h"] = h + if help is not None: + __query["help"] = help + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if s is not None: + __query["s"] = s + if v is not None: + __query["v"] = v + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain,application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def ml_datafeeds( + self, + *, + datafeed_id: Optional[Any] = None, + allow_no_match: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + h: Optional[Any] = None, + help: Optional[bool] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + s: Optional[List[str]] = None, + time: Optional[Any] = None, + v: Optional[bool] = None, + ) -> Any: + """ + Gets configuration and usage information about datafeeds. + + ``_ + + :param datafeed_id: A numerical character string that uniquely identifies the + datafeed. This identifier can contain lowercase alphanumeric characters (a-z + and 0-9), hyphens, and underscores. It must start and end with alphanumeric + characters. + :param allow_no_match: Specifies what to do when the request: * Contains wildcard + expressions and there are no datafeeds that match. * Contains the `_all` + string or no identifiers and there are no matches. * Contains wildcard expressions + and there are only partial matches. If `true`, the API returns an empty datafeeds + array when there are no matches and the subset of results when there are + partial matches. If `false`, the API returns a 404 status code when there + are no matches or only partial matches. + :param format: Specifies the format to return the columnar data in, can be set + to `text`, `json`, `cbor`, `yaml`, or `smile`. + :param h: List of columns to appear in the response. Supports simple wildcards. + :param help: When set to `true` will output available columns. This option can't + be combined with any other query string option. + :param local: If `true`, the request computes the list of selected nodes from + the local cluster state. If `false` the list of selected nodes are computed + from the cluster state of the master node. In both cases the coordinating + node will send requests for further information to each selected node. + :param master_timeout: Period to wait for a connection to the master node. + :param s: List of columns that determine how the table should be sorted. Sorting + defaults to ascending and can be changed by setting `:asc` or `:desc` as + a suffix to the column name. + :param time: The unit used to display time values. + :param v: When set to `true` will enable verbose output. + """ + if datafeed_id not in SKIP_IN_PATH: + __path = f"/_cat/ml/datafeeds/{_quote(datafeed_id)}" + else: + __path = "/_cat/ml/datafeeds" + __query: Dict[str, Any] = {} + if allow_no_match is not None: + __query["allow_no_match"] = allow_no_match + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if h is not None: + __query["h"] = h + if help is not None: + __query["help"] = help + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if s is not None: + __query["s"] = s + if time is not None: + __query["time"] = time + if v is not None: + __query["v"] = v + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain,application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def ml_jobs( + self, + *, + job_id: Optional[Any] = None, + allow_no_match: Optional[bool] = None, + bytes: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + h: Optional[Any] = None, + help: Optional[bool] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + s: Optional[List[str]] = None, + time: Optional[Any] = None, + v: Optional[bool] = None, + ) -> Any: + """ + Gets configuration and usage information about anomaly detection jobs. - :arg bytes: The unit in which to display byte values Valid - 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 full_id: Return the full node ID instead of the shortened - version (default: false) - :arg h: Comma-separated list of column names to display - :arg help: Return help information - :arg include_unloaded_segments: If set to true segment stats - will include stats for segments that are not currently loaded into - memory - :arg master_timeout: Explicit operation timeout for connection - 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 v: Verbose mode. Display column headers - """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", "/_cat/nodes", params=params, headers=headers - ) - - @query_params( - "active_only", "bytes", "detailed", "format", "h", "help", "s", "time", "v" + ``_ + + :param job_id: Identifier for the anomaly detection job. + :param allow_no_match: Specifies what to do when the request: * Contains wildcard + expressions and there are no jobs that match. * Contains the `_all` string + or no identifiers and there are no matches. * Contains wildcard expressions + and there are only partial matches. If `true`, the API returns an empty jobs + array when there are no matches and the subset of results when there are + partial matches. If `false`, the API returns a 404 status code when there + are no matches or only partial matches. + :param bytes: The unit used to display byte values. + :param format: Specifies the format to return the columnar data in, can be set + to `text`, `json`, `cbor`, `yaml`, or `smile`. + :param h: List of columns to appear in the response. Supports simple wildcards. + :param help: When set to `true` will output available columns. This option can't + be combined with any other query string option. + :param local: If `true`, the request computes the list of selected nodes from + the local cluster state. If `false` the list of selected nodes are computed + from the cluster state of the master node. In both cases the coordinating + node will send requests for further information to each selected node. + :param master_timeout: Period to wait for a connection to the master node. + :param s: List of columns that determine how the table should be sorted. Sorting + defaults to ascending and can be changed by setting `:asc` or `:desc` as + a suffix to the column name. + :param time: The unit used to display time values. + :param v: When set to `true` will enable verbose output. + """ + if job_id not in SKIP_IN_PATH: + __path = f"/_cat/ml/anomaly_detectors/{_quote(job_id)}" + else: + __path = "/_cat/ml/anomaly_detectors" + __query: Dict[str, Any] = {} + if allow_no_match is not None: + __query["allow_no_match"] = allow_no_match + if bytes is not None: + __query["bytes"] = bytes + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if h is not None: + __query["h"] = h + if help is not None: + __query["help"] = help + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if s is not None: + __query["s"] = s + if time is not None: + __query["time"] = time + if v is not None: + __query["v"] = v + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain,application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + parameter_aliases={"from": "from_"}, ) - def recovery(self, index=None, params=None, headers=None): + def ml_trained_models( + self, + *, + model_id: Optional[Any] = None, + allow_no_match: Optional[bool] = None, + bytes: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + from_: Optional[int] = None, + h: Optional[Any] = None, + help: Optional[bool] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + s: Optional[List[str]] = None, + size: Optional[int] = None, + v: Optional[bool] = None, + ) -> Any: """ - Returns information about index shard recoveries, both on-going completed. + Gets configuration and usage information about inference trained models. - ``_ + ``_ - :arg index: Comma-separated list or wildcard expression of index - names to limit the returned information - :arg active_only: If `true`, the response only includes ongoing - shard recoveries - :arg bytes: The unit in which to display byte values Valid - choices: b, k, kb, m, mb, g, gb, t, tb, p, pb - :arg detailed: If `true`, the response includes detailed - information about shard recoveries - :arg format: a short version of the Accept header, e.g. json, - yaml - :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 - to sort by - :arg time: The unit in which to display time values Valid - choices: d, h, m, s, ms, micros, nanos - :arg v: Verbose mode. Display column headers - """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", _make_path("_cat", "recovery", index), params=params, headers=headers - ) - - @query_params("bytes", "format", "h", "help", "master_timeout", "s", "time", "v") - def shards(self, index=None, params=None, headers=None): + :param model_id: The ID of the trained models stats to fetch + :param 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) + :param bytes: The unit in which to display byte values + :param format: Specifies the format to return the columnar data in, can be set + to `text`, `json`, `cbor`, `yaml`, or `smile`. + :param from_: skips a number of trained models + :param h: List of columns to appear in the response. Supports simple wildcards. + :param help: When set to `true` will output available columns. This option can't + be combined with any other query string option. + :param local: If `true`, the request computes the list of selected nodes from + the local cluster state. If `false` the list of selected nodes are computed + from the cluster state of the master node. In both cases the coordinating + node will send requests for further information to each selected node. + :param master_timeout: Period to wait for a connection to the master node. + :param s: List of columns that determine how the table should be sorted. Sorting + defaults to ascending and can be changed by setting `:asc` or `:desc` as + a suffix to the column name. + :param size: specifies a max number of trained models to get + :param v: When set to `true` will enable verbose output. """ - Provides a detailed view of shard allocation on nodes. + if model_id not in SKIP_IN_PATH: + __path = f"/_cat/ml/trained_models/{_quote(model_id)}" + else: + __path = "/_cat/ml/trained_models" + __query: Dict[str, Any] = {} + if allow_no_match is not None: + __query["allow_no_match"] = allow_no_match + if bytes is not None: + __query["bytes"] = bytes + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if from_ is not None: + __query["from"] = from_ + if h is not None: + __query["h"] = h + if help is not None: + __query["help"] = help + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if s is not None: + __query["s"] = s + if size is not None: + __query["size"] = size + if v is not None: + __query["v"] = v + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain,application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def nodeattrs( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + h: Optional[Any] = None, + help: Optional[bool] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + s: Optional[List[str]] = None, + v: Optional[bool] = None, + ) -> Any: + """ + Returns information about custom node attributes. - ``_ + ``_ - :arg index: A comma-separated list of index names to limit the - returned information - :arg bytes: The unit in which to display byte values Valid - 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 h: Comma-separated list of column names to display - :arg help: Return help information - :arg master_timeout: Explicit operation timeout for connection - 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 v: Verbose mode. Display column headers - """ - client, params = _deprecated_options(self, params) - return client._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): + :param format: Specifies the format to return the columnar data in, can be set + to `text`, `json`, `cbor`, `yaml`, or `smile`. + :param h: List of columns to appear in the response. Supports simple wildcards. + :param help: When set to `true` will output available columns. This option can't + be combined with any other query string option. + :param local: If `true`, the request computes the list of selected nodes from + the local cluster state. If `false` the list of selected nodes are computed + from the cluster state of the master node. In both cases the coordinating + node will send requests for further information to each selected node. + :param master_timeout: Period to wait for a connection to the master node. + :param s: List of columns that determine how the table should be sorted. Sorting + defaults to ascending and can be changed by setting `:asc` or `:desc` as + a suffix to the column name. + :param v: When set to `true` will enable verbose output. """ - Provides low-level information about the segments in the shards of an index. + __path = "/_cat/nodeattrs" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if h is not None: + __query["h"] = h + if help is not None: + __query["help"] = help + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if s is not None: + __query["s"] = s + if v is not None: + __query["v"] = v + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain,application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def nodes( + self, + *, + bytes: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + full_id: Optional[Union[bool, str]] = None, + h: Optional[Any] = None, + help: Optional[bool] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + s: Optional[List[str]] = None, + v: Optional[bool] = None, + ) -> Any: + """ + Returns basic statistics about performance of cluster nodes. - ``_ + ``_ - :arg index: A comma-separated list of index names to limit the - returned information - :arg bytes: The unit in which to display byte values Valid - 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 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 - to sort by - :arg v: Verbose mode. Display column headers - """ - client, params = _deprecated_options(self, params) - return client._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): + :param bytes: The unit in which to display byte values + :param format: Specifies the format to return the columnar data in, can be set + to `text`, `json`, `cbor`, `yaml`, or `smile`. + :param full_id: Return the full node ID instead of the shortened version (default: + false) + :param h: List of columns to appear in the response. Supports simple wildcards. + :param help: When set to `true` will output available columns. This option can't + be combined with any other query string option. + :param local: If `true`, the request computes the list of selected nodes from + the local cluster state. If `false` the list of selected nodes are computed + from the cluster state of the master node. In both cases the coordinating + node will send requests for further information to each selected node. + :param master_timeout: Period to wait for a connection to the master node. + :param s: List of columns that determine how the table should be sorted. Sorting + defaults to ascending and can be changed by setting `:asc` or `:desc` as + a suffix to the column name. + :param v: When set to `true` will enable verbose output. + """ + __path = "/_cat/nodes" + __query: Dict[str, Any] = {} + if bytes is not None: + __query["bytes"] = bytes + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if full_id is not None: + __query["full_id"] = full_id + if h is not None: + __query["h"] = h + if help is not None: + __query["help"] = help + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if s is not None: + __query["s"] = s + if v is not None: + __query["v"] = v + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain,application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def pending_tasks( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + h: Optional[Any] = None, + help: Optional[bool] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + s: Optional[List[str]] = None, + v: Optional[bool] = None, + ) -> Any: """ Returns a concise representation of the cluster pending tasks. ``_ - :arg format: a short version of the Accept header, e.g. json, - yaml - :arg h: Comma-separated list of column names to display - :arg help: Return help information - :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 - :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 v: Verbose mode. Display column headers - """ - client, params = _deprecated_options(self, params) - return client._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): + :param format: Specifies the format to return the columnar data in, can be set + to `text`, `json`, `cbor`, `yaml`, or `smile`. + :param h: List of columns to appear in the response. Supports simple wildcards. + :param help: When set to `true` will output available columns. This option can't + be combined with any other query string option. + :param local: If `true`, the request computes the list of selected nodes from + the local cluster state. If `false` the list of selected nodes are computed + from the cluster state of the master node. In both cases the coordinating + node will send requests for further information to each selected node. + :param master_timeout: Period to wait for a connection to the master node. + :param s: List of columns that determine how the table should be sorted. Sorting + defaults to ascending and can be changed by setting `:asc` or `:desc` as + a suffix to the column name. + :param v: When set to `true` will enable verbose output. """ - Returns cluster-wide thread pool statistics per node. By default the active, - queue and rejected statistics are returned for all thread pools. + __path = "/_cat/pending_tasks" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if h is not None: + __query["h"] = h + if help is not None: + __query["help"] = help + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if s is not None: + __query["s"] = s + if v is not None: + __query["v"] = v + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain,application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def plugins( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + h: Optional[Any] = None, + help: Optional[bool] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + s: Optional[List[str]] = None, + v: Optional[bool] = None, + ) -> Any: + """ + Returns information about installed plugins across nodes node. - ``_ + ``_ - :arg thread_pool_patterns: A comma-separated list of regular- - expressions to filter the thread pools in the output - :arg format: a short version of the Accept header, e.g. json, - yaml - :arg h: Comma-separated list of column names to display - :arg help: Return help information - :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 - :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 v: Verbose mode. Display column headers - """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", - _make_path("_cat", "thread_pool", thread_pool_patterns), - params=params, - headers=headers, - ) - - @query_params("bytes", "format", "h", "help", "s", "v") - def fielddata(self, fields=None, params=None, headers=None): + :param format: Specifies the format to return the columnar data in, can be set + to `text`, `json`, `cbor`, `yaml`, or `smile`. + :param h: List of columns to appear in the response. Supports simple wildcards. + :param help: When set to `true` will output available columns. This option can't + be combined with any other query string option. + :param local: If `true`, the request computes the list of selected nodes from + the local cluster state. If `false` the list of selected nodes are computed + from the cluster state of the master node. In both cases the coordinating + node will send requests for further information to each selected node. + :param master_timeout: Period to wait for a connection to the master node. + :param s: List of columns that determine how the table should be sorted. Sorting + defaults to ascending and can be changed by setting `:asc` or `:desc` as + a suffix to the column name. + :param v: When set to `true` will enable verbose output. """ - Shows how much heap memory is currently being used by fielddata on every data - node in the cluster. + __path = "/_cat/plugins" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if h is not None: + __query["h"] = h + if help is not None: + __query["help"] = help + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if s is not None: + __query["s"] = s + if v is not None: + __query["v"] = v + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain,application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def recovery( + self, + *, + index: Optional[Any] = None, + active_only: Optional[bool] = None, + bytes: Optional[Any] = None, + detailed: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + h: Optional[Any] = None, + help: Optional[bool] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + s: Optional[List[str]] = None, + v: Optional[bool] = None, + ) -> Any: + """ + Returns information about index shard recoveries, both on-going completed. - ``_ + ``_ - :arg fields: A comma-separated list of fields to return in the - output - :arg bytes: The unit in which to display byte values Valid - 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 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 - to sort by - :arg v: Verbose mode. Display column headers - """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", - _make_path("_cat", "fielddata", fields), - params=params, - headers=headers, - ) - - @query_params( - "format", "h", "help", "include_bootstrap", "local", "master_timeout", "s", "v" - ) - def plugins(self, params=None, headers=None): + :param index: Comma-separated list or wildcard expression of index names to limit + the returned information + :param active_only: If `true`, the response only includes ongoing shard recoveries + :param bytes: The unit in which to display byte values + :param detailed: If `true`, the response includes detailed information about + shard recoveries + :param format: Specifies the format to return the columnar data in, can be set + to `text`, `json`, `cbor`, `yaml`, or `smile`. + :param h: List of columns to appear in the response. Supports simple wildcards. + :param help: When set to `true` will output available columns. This option can't + be combined with any other query string option. + :param local: If `true`, the request computes the list of selected nodes from + the local cluster state. If `false` the list of selected nodes are computed + from the cluster state of the master node. In both cases the coordinating + node will send requests for further information to each selected node. + :param master_timeout: Period to wait for a connection to the master node. + :param s: List of columns that determine how the table should be sorted. Sorting + defaults to ascending and can be changed by setting `:asc` or `:desc` as + a suffix to the column name. + :param v: When set to `true` will enable verbose output. """ - Returns information about installed plugins across nodes node. + if index not in SKIP_IN_PATH: + __path = f"/_cat/recovery/{_quote(index)}" + else: + __path = "/_cat/recovery" + __query: Dict[str, Any] = {} + if active_only is not None: + __query["active_only"] = active_only + if bytes is not None: + __query["bytes"] = bytes + if detailed is not None: + __query["detailed"] = detailed + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if h is not None: + __query["h"] = h + if help is not None: + __query["help"] = help + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if s is not None: + __query["s"] = s + if v is not None: + __query["v"] = v + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain,application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def repositories( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + h: Optional[Any] = None, + help: Optional[bool] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + s: Optional[List[str]] = None, + v: Optional[bool] = None, + ) -> Any: + """ + Returns information about snapshot repositories registered in the cluster. - ``_ + ``_ - :arg format: a short version of the Accept header, e.g. json, - yaml - :arg h: Comma-separated list of column names to display - :arg help: Return help information - :arg include_bootstrap: Include bootstrap plugins in the - response - :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 - :arg s: Comma-separated list of column names or column aliases - to sort by - :arg v: Verbose mode. Display column headers - """ - client, params = _deprecated_options(self, params) - return client._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): + :param format: Specifies the format to return the columnar data in, can be set + to `text`, `json`, `cbor`, `yaml`, or `smile`. + :param h: List of columns to appear in the response. Supports simple wildcards. + :param help: When set to `true` will output available columns. This option can't + be combined with any other query string option. + :param local: If `true`, the request computes the list of selected nodes from + the local cluster state. If `false` the list of selected nodes are computed + from the cluster state of the master node. In both cases the coordinating + node will send requests for further information to each selected node. + :param master_timeout: Period to wait for a connection to the master node. + :param s: List of columns that determine how the table should be sorted. Sorting + defaults to ascending and can be changed by setting `:asc` or `:desc` as + a suffix to the column name. + :param v: When set to `true` will enable verbose output. """ - Returns information about custom node attributes. + __path = "/_cat/repositories" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if h is not None: + __query["h"] = h + if help is not None: + __query["help"] = help + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if s is not None: + __query["s"] = s + if v is not None: + __query["v"] = v + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain,application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def segments( + self, + *, + index: Optional[Any] = None, + bytes: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + h: Optional[Any] = None, + help: Optional[bool] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + s: Optional[List[str]] = None, + v: Optional[bool] = None, + ) -> Any: + """ + Provides low-level information about the segments in the shards of an index. - ``_ + ``_ - :arg format: a short version of the Accept header, e.g. json, - yaml - :arg h: Comma-separated list of column names to display - :arg help: Return help information - :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 - :arg s: Comma-separated list of column names or column aliases - to sort by - :arg v: Verbose mode. Display column headers - """ - client, params = _deprecated_options(self, params) - return client._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): + :param index: A comma-separated list of index names to limit the returned information + :param bytes: The unit in which to display byte values + :param format: Specifies the format to return the columnar data in, can be set + to `text`, `json`, `cbor`, `yaml`, or `smile`. + :param h: List of columns to appear in the response. Supports simple wildcards. + :param help: When set to `true` will output available columns. This option can't + be combined with any other query string option. + :param local: If `true`, the request computes the list of selected nodes from + the local cluster state. If `false` the list of selected nodes are computed + from the cluster state of the master node. In both cases the coordinating + node will send requests for further information to each selected node. + :param master_timeout: Period to wait for a connection to the master node. + :param s: List of columns that determine how the table should be sorted. Sorting + defaults to ascending and can be changed by setting `:asc` or `:desc` as + a suffix to the column name. + :param v: When set to `true` will enable verbose output. """ - Returns information about snapshot repositories registered in the cluster. + if index not in SKIP_IN_PATH: + __path = f"/_cat/segments/{_quote(index)}" + else: + __path = "/_cat/segments" + __query: Dict[str, Any] = {} + if bytes is not None: + __query["bytes"] = bytes + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if h is not None: + __query["h"] = h + if help is not None: + __query["help"] = help + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if s is not None: + __query["s"] = s + if v is not None: + __query["v"] = v + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain,application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def shards( + self, + *, + index: Optional[Any] = None, + bytes: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + h: Optional[Any] = None, + help: Optional[bool] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + s: Optional[List[str]] = None, + v: Optional[bool] = None, + ) -> Any: + """ + Provides a detailed view of shard allocation on nodes. - ``_ + ``_ - :arg format: a short version of the Accept header, e.g. json, - yaml - :arg h: Comma-separated list of column names to display - :arg help: Return help information - :arg local: Return local information, do not retrieve the state - from master node - :arg master_timeout: Explicit operation timeout for connection - to master node - :arg s: Comma-separated list of column names or column aliases - to sort by - :arg v: Verbose mode. Display column headers - """ - client, params = _deprecated_options(self, params) - return client._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): + :param index: A comma-separated list of index names to limit the returned information + :param bytes: The unit in which to display byte values + :param format: Specifies the format to return the columnar data in, can be set + to `text`, `json`, `cbor`, `yaml`, or `smile`. + :param h: List of columns to appear in the response. Supports simple wildcards. + :param help: When set to `true` will output available columns. This option can't + be combined with any other query string option. + :param local: If `true`, the request computes the list of selected nodes from + the local cluster state. If `false` the list of selected nodes are computed + from the cluster state of the master node. In both cases the coordinating + node will send requests for further information to each selected node. + :param master_timeout: Period to wait for a connection to the master node. + :param s: List of columns that determine how the table should be sorted. Sorting + defaults to ascending and can be changed by setting `:asc` or `:desc` as + a suffix to the column name. + :param v: When set to `true` will enable verbose output. + """ + if index not in SKIP_IN_PATH: + __path = f"/_cat/shards/{_quote(index)}" + else: + __path = "/_cat/shards" + __query: Dict[str, Any] = {} + if bytes is not None: + __query["bytes"] = bytes + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if h is not None: + __query["h"] = h + if help is not None: + __query["help"] = help + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if s is not None: + __query["s"] = s + if v is not None: + __query["v"] = v + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain,application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def snapshots( + self, + *, + repository: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + h: Optional[Any] = None, + help: Optional[bool] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + s: Optional[List[str]] = None, + v: Optional[bool] = None, + ) -> Any: """ Returns all snapshots in a specific repository. ``_ - :arg repository: Name of repository from which to fetch the - snapshot information - :arg format: a short version of the Accept header, e.g. json, - yaml - :arg h: Comma-separated list of column names to display - :arg help: Return help information - :arg ignore_unavailable: Set to true to ignore unavailable - snapshots - :arg master_timeout: Explicit operation timeout for connection - 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 v: Verbose mode. Display column headers - """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", - _make_path("_cat", "snapshots", repository), - params=params, - headers=headers, - ) - - @query_params( - "actions", - "detailed", - "format", - "h", - "help", - "nodes", - "parent_task_id", - "s", - "time", - "v", - ) - def tasks(self, params=None, headers=None): + :param repository: Name of repository from which to fetch the snapshot information + :param format: Specifies the format to return the columnar data in, can be set + to `text`, `json`, `cbor`, `yaml`, or `smile`. + :param h: List of columns to appear in the response. Supports simple wildcards. + :param help: When set to `true` will output available columns. This option can't + be combined with any other query string option. + :param ignore_unavailable: Set to true to ignore unavailable snapshots + :param local: If `true`, the request computes the list of selected nodes from + the local cluster state. If `false` the list of selected nodes are computed + from the cluster state of the master node. In both cases the coordinating + node will send requests for further information to each selected node. + :param master_timeout: Period to wait for a connection to the master node. + :param s: List of columns that determine how the table should be sorted. Sorting + defaults to ascending and can be changed by setting `:asc` or `:desc` as + a suffix to the column name. + :param v: When set to `true` will enable verbose output. """ - Returns information about the tasks currently executing on one or more nodes in - the cluster. + if repository not in SKIP_IN_PATH: + __path = f"/_cat/snapshots/{_quote(repository)}" + else: + __path = "/_cat/snapshots" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if h is not None: + __query["h"] = h + if help is not None: + __query["help"] = help + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if s is not None: + __query["s"] = s + if v is not None: + __query["v"] = v + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain,application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def tasks( + self, + *, + actions: Optional[List[str]] = None, + detailed: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + h: Optional[Any] = None, + help: Optional[bool] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + node_id: Optional[List[str]] = None, + parent_task: Optional[int] = None, + pretty: Optional[bool] = None, + s: Optional[List[str]] = None, + v: Optional[bool] = None, + ) -> Any: + """ + Returns information about the tasks currently executing on one or more nodes + in the cluster. ``_ - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - - :arg actions: A comma-separated list of actions that should be - returned. Leave empty to return all. - :arg detailed: Return detailed task information (default: false) - :arg format: a short version of the Accept header, e.g. json, - yaml - :arg h: Comma-separated list of column names to display - :arg help: Return help information - :arg nodes: 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 parent_task_id: Return tasks with specified parent task id - (node_id:task_number). Set to -1 to return all. - :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 v: Verbose mode. Display column headers - """ - client, params = _deprecated_options(self, params) - return client._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): + :param actions: A comma-separated list of actions that should be returned. Leave + empty to return all. + :param detailed: Return detailed task information (default: false) + :param format: Specifies the format to return the columnar data in, can be set + to `text`, `json`, `cbor`, `yaml`, or `smile`. + :param h: List of columns to appear in the response. Supports simple wildcards. + :param help: When set to `true` will output available columns. This option can't + be combined with any other query string option. + :param local: If `true`, the request computes the list of selected nodes from + the local cluster state. If `false` the list of selected nodes are computed + from the cluster state of the master node. In both cases the coordinating + node will send requests for further information to each selected node. + :param master_timeout: Period to wait for a connection to the master node. + :param node_id: + :param parent_task: + :param s: List of columns that determine how the table should be sorted. Sorting + defaults to ascending and can be changed by setting `:asc` or `:desc` as + a suffix to the column name. + :param v: When set to `true` will enable verbose output. + """ + __path = "/_cat/tasks" + __query: Dict[str, Any] = {} + if actions is not None: + __query["actions"] = actions + if detailed is not None: + __query["detailed"] = detailed + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if h is not None: + __query["h"] = h + if help is not None: + __query["help"] = help + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if node_id is not None: + __query["node_id"] = node_id + if parent_task is not None: + __query["parent_task"] = parent_task + if pretty is not None: + __query["pretty"] = pretty + if s is not None: + __query["s"] = s + if v is not None: + __query["v"] = v + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain,application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def templates( + self, + *, + name: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + h: Optional[Any] = None, + help: Optional[bool] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + s: Optional[List[str]] = None, + v: Optional[bool] = None, + ) -> Any: """ 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, - yaml - :arg h: Comma-separated list of column names to display - :arg help: Return help information - :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 - :arg s: Comma-separated list of column names or column aliases - to sort by - :arg v: Verbose mode. Display column headers - """ - client, params = _deprecated_options(self, params) - return client._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): + :param name: A pattern that returned template names must match + :param format: Specifies the format to return the columnar data in, can be set + to `text`, `json`, `cbor`, `yaml`, or `smile`. + :param h: List of columns to appear in the response. Supports simple wildcards. + :param help: When set to `true` will output available columns. This option can't + be combined with any other query string option. + :param local: If `true`, the request computes the list of selected nodes from + the local cluster state. If `false` the list of selected nodes are computed + from the cluster state of the master node. In both cases the coordinating + node will send requests for further information to each selected node. + :param master_timeout: Period to wait for a connection to the master node. + :param s: List of columns that determine how the table should be sorted. Sorting + defaults to ascending and can be changed by setting `:asc` or `:desc` as + a suffix to the column name. + :param v: When set to `true` will enable verbose output. """ - Gets configuration and usage information about data frame analytics jobs. + if name not in SKIP_IN_PATH: + __path = f"/_cat/templates/{_quote(name)}" + else: + __path = "/_cat/templates" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if h is not None: + __query["h"] = h + if help is not None: + __query["help"] = help + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if s is not None: + __query["s"] = s + if v is not None: + __query["v"] = v + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain,application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def thread_pool( + self, + *, + thread_pool_patterns: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + h: Optional[Any] = None, + help: Optional[bool] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + s: Optional[List[str]] = None, + size: Optional[Union[Any, bool]] = None, + v: Optional[bool] = None, + ) -> Any: + """ + Returns cluster-wide thread pool statistics per node. By default the active, + queue and rejected statistics are returned for all thread pools. - ``_ + ``_ - :arg id: The ID of the data frame analytics to fetch - :arg allow_no_match: Whether to ignore if a wildcard expression - matches no configs. (This includes `_all` string or when no configs have - been specified) - :arg bytes: The unit in which to display byte values Valid - 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 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 - to sort by - :arg time: The unit in which to display time values Valid - choices: d, h, m, s, ms, micros, nanos - :arg v: Verbose mode. Display column headers - """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", - _make_path("_cat", "ml", "data_frame", "analytics", id), - params=params, - headers=headers, - ) - - @query_params( - "allow_no_datafeeds", "allow_no_match", "format", "h", "help", "s", "time", "v" - ) - def ml_datafeeds(self, datafeed_id=None, params=None, headers=None): + :param thread_pool_patterns: A comma-separated list of regular-expressions to + filter the thread pools in the output + :param format: Specifies the format to return the columnar data in, can be set + to `text`, `json`, `cbor`, `yaml`, or `smile`. + :param h: List of columns to appear in the response. Supports simple wildcards. + :param help: When set to `true` will output available columns. This option can't + be combined with any other query string option. + :param local: If `true`, the request computes the list of selected nodes from + the local cluster state. If `false` the list of selected nodes are computed + from the cluster state of the master node. In both cases the coordinating + node will send requests for further information to each selected node. + :param master_timeout: Period to wait for a connection to the master node. + :param s: List of columns that determine how the table should be sorted. Sorting + defaults to ascending and can be changed by setting `:asc` or `:desc` as + a suffix to the column name. + :param size: + :param v: When set to `true` will enable verbose output. """ - 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 - expression matches no datafeeds. (This includes `_all` string or when no - datafeeds have been specified) - :arg allow_no_match: Whether to ignore if a wildcard expression - matches no datafeeds. (This includes `_all` string or when no datafeeds - have been specified) - :arg format: a short version of the Accept header, e.g. json, - yaml - :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 - to sort by - :arg time: The unit in which to display time values Valid - choices: d, h, m, s, ms, micros, nanos - :arg v: Verbose mode. Display column headers - """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", - _make_path("_cat", "ml", "datafeeds", datafeed_id), - params=params, - headers=headers, - ) - - @query_params( - "allow_no_jobs", - "allow_no_match", - "bytes", - "format", - "h", - "help", - "s", - "time", - "v", + if thread_pool_patterns not in SKIP_IN_PATH: + __path = f"/_cat/thread_pool/{_quote(thread_pool_patterns)}" + else: + __path = "/_cat/thread_pool" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if h is not None: + __query["h"] = h + if help is not None: + __query["help"] = help + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if s is not None: + __query["s"] = s + if size is not None: + __query["size"] = size + if v is not None: + __query["v"] = v + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain,application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + parameter_aliases={"from": "from_"}, ) - def ml_jobs(self, job_id=None, params=None, headers=None): + def transforms( + self, + *, + transform_id: Optional[Any] = None, + allow_no_match: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + from_: Optional[int] = None, + h: Optional[Any] = None, + help: Optional[bool] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + s: Optional[List[str]] = None, + size: Optional[int] = None, + v: Optional[bool] = None, + ) -> Any: """ - Gets configuration and usage information about anomaly detection jobs. + Gets configuration and usage information about transforms. - ``_ + ``_ - :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) - :arg allow_no_match: Whether to ignore if a wildcard expression - matches no jobs. (This includes `_all` string or when no jobs have been + :param transform_id: The id of the transform for which to get stats. '_all' or + '*' implies all transforms + :param 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 bytes: The unit in which to display byte values Valid - 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 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 - to sort by - :arg time: The unit in which to display time values Valid - choices: d, h, m, s, ms, micros, nanos - :arg v: Verbose mode. Display column headers - """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", - _make_path("_cat", "ml", "anomaly_detectors", job_id), - params=params, - headers=headers, - ) - - @query_params( - "allow_no_match", - "bytes", - "format", - "from_", - "h", - "help", - "s", - "size", - "time", - "v", - ) - def ml_trained_models(self, model_id=None, params=None, headers=None): + :param format: Specifies the format to return the columnar data in, can be set + to `text`, `json`, `cbor`, `yaml`, or `smile`. + :param from_: skips a number of transform configs, defaults to 0 + :param h: List of columns to appear in the response. Supports simple wildcards. + :param help: When set to `true` will output available columns. This option can't + be combined with any other query string option. + :param local: If `true`, the request computes the list of selected nodes from + the local cluster state. If `false` the list of selected nodes are computed + from the cluster state of the master node. In both cases the coordinating + node will send requests for further information to each selected node. + :param master_timeout: Period to wait for a connection to the master node. + :param s: List of columns that determine how the table should be sorted. Sorting + defaults to ascending and can be changed by setting `:asc` or `:desc` as + a suffix to the column name. + :param size: specifies a max number of transforms to get, defaults to 100 + :param v: When set to `true` will enable verbose output. """ - 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 - matches no trained models. (This includes `_all` string or when no - trained models have been specified) Default: True - :arg bytes: The unit in which to display byte values Valid - 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 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 - to sort by - :arg size: specifies a max number of trained models to get - Default: 100 - :arg time: The unit in which to display time values Valid - choices: d, h, m, s, ms, micros, nanos - :arg v: Verbose mode. Display column headers - """ - client, params = _deprecated_options(self, params) - if params and "from_" in params: - params["from"] = params.pop("from_") - - return client._perform_request( - "GET", - _make_path("_cat", "ml", "trained_models", model_id), - params=params, - headers=headers, - ) - - @query_params( - "allow_no_match", "format", "from_", "h", "help", "s", "size", "time", "v" - ) - 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 - :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 format: a short version of the Accept header, e.g. json, - yaml - :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 - to sort by - :arg size: specifies a max number of transforms to get, defaults - to 100 - :arg time: The unit in which to display time values Valid - choices: d, h, m, s, ms, micros, nanos - :arg v: Verbose mode. Display column headers - """ - client, params = _deprecated_options(self, params) - if params and "from_" in params: - params["from"] = params.pop("from_") - - return client._perform_request( - "GET", - _make_path("_cat", "transforms", transform_id), - params=params, - headers=headers, - ) + if transform_id not in SKIP_IN_PATH: + __path = f"/_cat/transforms/{_quote(transform_id)}" + else: + __path = "/_cat/transforms" + __query: Dict[str, Any] = {} + if allow_no_match is not None: + __query["allow_no_match"] = allow_no_match + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if from_ is not None: + __query["from"] = from_ + if h is not None: + __query["h"] = h + if help is not None: + __query["help"] = help + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if s is not None: + __query["s"] = s + if size is not None: + __query["size"] = size + if v is not None: + __query["v"] = v + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain,application/json"} + return self._perform_request("GET", __target, headers=__headers) diff --git a/elasticsearch/_sync/client/cat.pyi b/elasticsearch/_sync/client/cat.pyi deleted file mode 100644 index 8b99ac504..000000000 --- a/elasticsearch/_sync/client/cat.pyi +++ /dev/null @@ -1,610 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse, TextApiResponse - -from ._base import NamespacedClient - -class CatClient(NamespacedClient): - def aliases( - self, - *, - name: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - format: Optional[Any] = ..., - h: Optional[Any] = ..., - help: Optional[Any] = ..., - local: Optional[Any] = ..., - s: Optional[Any] = ..., - v: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> Union[ObjectApiResponse[None], TextApiResponse]: ... - def allocation( - self, - *, - node_id: Optional[Any] = ..., - bytes: Optional[Any] = ..., - format: Optional[Any] = ..., - h: Optional[Any] = ..., - help: Optional[Any] = ..., - local: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - s: Optional[Any] = ..., - v: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> Union[ObjectApiResponse[None], TextApiResponse]: ... - def count( - self, - *, - index: Optional[Any] = ..., - format: Optional[Any] = ..., - h: Optional[Any] = ..., - help: Optional[Any] = ..., - s: Optional[Any] = ..., - v: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> Union[ObjectApiResponse[None], TextApiResponse]: ... - def health( - self, - *, - format: Optional[Any] = ..., - h: Optional[Any] = ..., - help: Optional[Any] = ..., - s: Optional[Any] = ..., - time: Optional[Any] = ..., - ts: Optional[Any] = ..., - v: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> Union[ObjectApiResponse[None], TextApiResponse]: ... - def help( - self, - *, - help: Optional[Any] = ..., - s: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> TextApiResponse: ... - def indices( - self, - *, - index: Optional[Any] = ..., - bytes: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - format: Optional[Any] = ..., - h: Optional[Any] = ..., - health: Optional[Any] = ..., - help: Optional[Any] = ..., - include_unloaded_segments: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - pri: Optional[Any] = ..., - s: Optional[Any] = ..., - time: Optional[Any] = ..., - v: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> Union[ObjectApiResponse[None], TextApiResponse]: ... - def master( - self, - *, - format: Optional[Any] = ..., - h: Optional[Any] = ..., - help: Optional[Any] = ..., - local: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - s: Optional[Any] = ..., - v: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> Union[ObjectApiResponse[None], TextApiResponse]: ... - def nodes( - self, - *, - bytes: Optional[Any] = ..., - format: Optional[Any] = ..., - full_id: Optional[Any] = ..., - h: Optional[Any] = ..., - help: Optional[Any] = ..., - include_unloaded_segments: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - s: Optional[Any] = ..., - time: Optional[Any] = ..., - v: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> Union[ObjectApiResponse[None], TextApiResponse]: ... - def recovery( - self, - *, - index: Optional[Any] = ..., - active_only: Optional[Any] = ..., - bytes: Optional[Any] = ..., - detailed: Optional[Any] = ..., - format: Optional[Any] = ..., - h: Optional[Any] = ..., - help: Optional[Any] = ..., - s: Optional[Any] = ..., - time: Optional[Any] = ..., - v: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> Union[ObjectApiResponse[None], TextApiResponse]: ... - def shards( - self, - *, - index: Optional[Any] = ..., - bytes: Optional[Any] = ..., - format: Optional[Any] = ..., - h: Optional[Any] = ..., - help: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - s: Optional[Any] = ..., - time: Optional[Any] = ..., - v: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> Union[ObjectApiResponse[None], TextApiResponse]: ... - def segments( - self, - *, - index: Optional[Any] = ..., - bytes: Optional[Any] = ..., - format: Optional[Any] = ..., - h: Optional[Any] = ..., - help: Optional[Any] = ..., - s: Optional[Any] = ..., - v: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> Union[ObjectApiResponse[None], TextApiResponse]: ... - def pending_tasks( - self, - *, - format: Optional[Any] = ..., - h: Optional[Any] = ..., - help: Optional[Any] = ..., - local: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - s: Optional[Any] = ..., - time: Optional[Any] = ..., - v: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> Union[ObjectApiResponse[None], TextApiResponse]: ... - def thread_pool( - self, - *, - thread_pool_patterns: Optional[Any] = ..., - format: Optional[Any] = ..., - h: Optional[Any] = ..., - help: Optional[Any] = ..., - local: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - s: Optional[Any] = ..., - time: Optional[Any] = ..., - v: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> Union[ObjectApiResponse[None], TextApiResponse]: ... - def fielddata( - self, - *, - fields: Optional[Any] = ..., - bytes: Optional[Any] = ..., - format: Optional[Any] = ..., - h: Optional[Any] = ..., - help: Optional[Any] = ..., - s: Optional[Any] = ..., - v: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> Union[ObjectApiResponse[None], TextApiResponse]: ... - def plugins( - self, - *, - format: Optional[Any] = ..., - h: Optional[Any] = ..., - help: Optional[Any] = ..., - include_bootstrap: Optional[Any] = ..., - local: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - s: Optional[Any] = ..., - v: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> Union[ObjectApiResponse[None], TextApiResponse]: ... - def nodeattrs( - self, - *, - format: Optional[Any] = ..., - h: Optional[Any] = ..., - help: Optional[Any] = ..., - local: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - s: Optional[Any] = ..., - v: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> Union[ObjectApiResponse[None], TextApiResponse]: ... - def repositories( - self, - *, - format: Optional[Any] = ..., - h: Optional[Any] = ..., - help: Optional[Any] = ..., - local: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - s: Optional[Any] = ..., - v: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> Union[ObjectApiResponse[None], TextApiResponse]: ... - def snapshots( - self, - *, - repository: Optional[Any] = ..., - format: Optional[Any] = ..., - h: Optional[Any] = ..., - help: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - s: Optional[Any] = ..., - time: Optional[Any] = ..., - v: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> Union[ObjectApiResponse[None], TextApiResponse]: ... - def tasks( - self, - *, - actions: Optional[Any] = ..., - detailed: Optional[Any] = ..., - format: Optional[Any] = ..., - h: Optional[Any] = ..., - help: Optional[Any] = ..., - nodes: Optional[Any] = ..., - parent_task_id: Optional[Any] = ..., - s: Optional[Any] = ..., - time: Optional[Any] = ..., - v: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> Union[ObjectApiResponse[None], TextApiResponse]: ... - def templates( - self, - *, - name: Optional[Any] = ..., - format: Optional[Any] = ..., - h: Optional[Any] = ..., - help: Optional[Any] = ..., - local: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - s: Optional[Any] = ..., - v: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> Union[ObjectApiResponse[None], TextApiResponse]: ... - def ml_data_frame_analytics( - self, - *, - id: Optional[Any] = ..., - allow_no_match: Optional[Any] = ..., - bytes: Optional[Any] = ..., - format: Optional[Any] = ..., - h: Optional[Any] = ..., - help: Optional[Any] = ..., - s: Optional[Any] = ..., - time: Optional[Any] = ..., - v: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> Union[ObjectApiResponse[None], TextApiResponse]: ... - def ml_datafeeds( - self, - *, - datafeed_id: Optional[Any] = ..., - allow_no_datafeeds: Optional[Any] = ..., - allow_no_match: Optional[Any] = ..., - format: Optional[Any] = ..., - h: Optional[Any] = ..., - help: Optional[Any] = ..., - s: Optional[Any] = ..., - time: Optional[Any] = ..., - v: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> Union[ObjectApiResponse[None], TextApiResponse]: ... - def ml_jobs( - self, - *, - job_id: Optional[Any] = ..., - allow_no_jobs: Optional[Any] = ..., - allow_no_match: Optional[Any] = ..., - bytes: Optional[Any] = ..., - format: Optional[Any] = ..., - h: Optional[Any] = ..., - help: Optional[Any] = ..., - s: Optional[Any] = ..., - time: Optional[Any] = ..., - v: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> Union[ObjectApiResponse[None], TextApiResponse]: ... - def ml_trained_models( - self, - *, - model_id: Optional[Any] = ..., - allow_no_match: Optional[Any] = ..., - bytes: Optional[Any] = ..., - format: Optional[Any] = ..., - from_: Optional[Any] = ..., - h: Optional[Any] = ..., - help: Optional[Any] = ..., - s: Optional[Any] = ..., - size: Optional[Any] = ..., - time: Optional[Any] = ..., - v: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> Union[ObjectApiResponse[None], TextApiResponse]: ... - def transforms( - self, - *, - transform_id: Optional[Any] = ..., - allow_no_match: Optional[Any] = ..., - format: Optional[Any] = ..., - from_: Optional[Any] = ..., - h: Optional[Any] = ..., - help: Optional[Any] = ..., - s: Optional[Any] = ..., - size: Optional[Any] = ..., - time: Optional[Any] = ..., - v: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> Union[ObjectApiResponse[None], TextApiResponse]: ... diff --git a/elasticsearch/_sync/client/ccr.py b/elasticsearch/_sync/client/ccr.py index d01aee260..66744e064 100644 --- a/elasticsearch/_sync/client/ccr.py +++ b/elasticsearch/_sync/client/ccr.py @@ -15,285 +15,715 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params +from .utils import SKIP_IN_PATH, _quote, _quote_query, _rewrite_parameters class CcrClient(NamespacedClient): - @query_params() - def delete_auto_follow_pattern(self, name, params=None, headers=None): + @_rewrite_parameters() + def delete_auto_follow_pattern( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Deletes auto-follow patterns. - ``_ + ``_ - :arg name: The name of the auto follow pattern. + :param name: The name of the auto follow pattern. """ - client, params = _deprecated_options(self, params) if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'name'.") - - return client._perform_request( - "DELETE", - _make_path("_ccr", "auto_follow", name), - params=params, - headers=headers, - ) - - @query_params("wait_for_active_shards") - def follow(self, index, body, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_ccr/auto_follow/{_quote(name)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + def follow( + self, + *, + index: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + leader_index: Optional[Any] = None, + max_outstanding_read_requests: Optional[int] = None, + max_outstanding_write_requests: Optional[int] = None, + max_read_request_operation_count: Optional[int] = None, + max_read_request_size: Optional[str] = None, + max_retry_delay: Optional[Any] = None, + max_write_buffer_count: Optional[int] = None, + max_write_buffer_size: Optional[str] = None, + max_write_request_operation_count: Optional[int] = None, + max_write_request_size: Optional[str] = None, + pretty: Optional[bool] = None, + read_poll_timeout: Optional[Any] = None, + remote_cluster: Optional[str] = None, + wait_for_active_shards: Optional[Any] = None, + ) -> Any: """ 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 - related parameters - :arg wait_for_active_shards: Sets the number of shard copies - that must be active before returning. Defaults to 0. Set to `all` for - all shard copies, otherwise set to any non-negative value less than or - equal to the total number of copies for the shard (number of replicas + - 1) Default: 0 + ``_ + + :param index: The name of the follower index + :param leader_index: + :param max_outstanding_read_requests: + :param max_outstanding_write_requests: + :param max_read_request_operation_count: + :param max_read_request_size: + :param max_retry_delay: + :param max_write_buffer_count: + :param max_write_buffer_size: + :param max_write_request_operation_count: + :param max_write_request_size: + :param read_poll_timeout: + :param remote_cluster: + :param wait_for_active_shards: Sets the number of shard copies that must be active + before returning. Defaults to 0. Set to `all` for all shard copies, otherwise + set to any non-negative value less than or equal to the total number of copies + for the shard (number of replicas + 1) """ - client, params = _deprecated_options(self, params) - for param in (index, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "PUT", - _make_path(index, "_ccr", "follow"), - params=params, - headers=headers, - body=body, - ) - - @query_params() - def follow_info(self, index, params=None, headers=None): + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + __path = f"/{_quote(index)}/_ccr/follow" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if leader_index is not None: + __body["leader_index"] = leader_index + if max_outstanding_read_requests is not None: + __body["max_outstanding_read_requests"] = max_outstanding_read_requests + if max_outstanding_write_requests is not None: + __body["max_outstanding_write_requests"] = max_outstanding_write_requests + if max_read_request_operation_count is not None: + __body[ + "max_read_request_operation_count" + ] = max_read_request_operation_count + if max_read_request_size is not None: + __body["max_read_request_size"] = max_read_request_size + if max_retry_delay is not None: + __body["max_retry_delay"] = max_retry_delay + if max_write_buffer_count is not None: + __body["max_write_buffer_count"] = max_write_buffer_count + if max_write_buffer_size is not None: + __body["max_write_buffer_size"] = max_write_buffer_size + if max_write_request_operation_count is not None: + __body[ + "max_write_request_operation_count" + ] = max_write_request_operation_count + if max_write_request_size is not None: + __body["max_write_request_size"] = max_write_request_size + if pretty is not None: + __query["pretty"] = pretty + if read_poll_timeout is not None: + __body["read_poll_timeout"] = read_poll_timeout + if remote_cluster is not None: + __body["remote_cluster"] = remote_cluster + if wait_for_active_shards is not None: + __query["wait_for_active_shards"] = wait_for_active_shards + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("PUT", __target, headers=__headers, body=__body) + + @_rewrite_parameters() + def follow_info( + self, + *, + index: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Retrieves information about all follower indices, including parameters and - status for each follower index + 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 + :param index: A comma-separated list of index patterns; use `_all` to perform + the operation on all indices """ - client, params = _deprecated_options(self, params) if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return client._perform_request( - "GET", _make_path(index, "_ccr", "info"), params=params, headers=headers - ) - - @query_params() - def follow_stats(self, index, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'index'") + __path = f"/{_quote(index)}/_ccr/info" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def follow_stats( + self, + *, + index: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ 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 + :param index: A comma-separated list of index patterns; use `_all` to perform + the operation on all indices """ - client, params = _deprecated_options(self, params) if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return client._perform_request( - "GET", _make_path(index, "_ccr", "stats"), params=params, headers=headers - ) - - @query_params() - def forget_follower(self, index, body, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'index'") + __path = f"/{_quote(index)}/_ccr/stats" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + def forget_follower( + self, + *, + index: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + follower_cluster: Optional[str] = None, + follower_index: Optional[Any] = None, + follower_index_uuid: Optional[Any] = None, + human: Optional[bool] = None, + leader_remote_cluster: Optional[str] = None, + pretty: Optional[bool] = None, + ) -> Any: """ 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 - :arg body: the name and UUID of the follower index, the name of - the cluster containing the follower index, and the alias from the - perspective of that cluster for the remote cluster containing the leader - index + :param index: the name of the leader index for which specified follower retention + leases should be removed + :param follower_cluster: + :param follower_index: + :param follower_index_uuid: + :param leader_remote_cluster: """ - client, params = _deprecated_options(self, params) - for param in (index, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "POST", - _make_path(index, "_ccr", "forget_follower"), - params=params, - headers=headers, - body=body, - ) - - @query_params() - def get_auto_follow_pattern(self, name=None, params=None, headers=None): + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + __path = f"/{_quote(index)}/_ccr/forget_follower" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if follower_cluster is not None: + __body["follower_cluster"] = follower_cluster + if follower_index is not None: + __body["follower_index"] = follower_index + if follower_index_uuid is not None: + __body["follower_index_uuid"] = follower_index_uuid + if human is not None: + __query["human"] = human + if leader_remote_cluster is not None: + __body["leader_remote_cluster"] = leader_remote_cluster + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters() + def get_auto_follow_pattern( + self, + *, + name: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Gets configured auto-follow patterns. Returns the specified auto-follow pattern collection. - ``_ + ``_ - :arg name: The name of the auto follow pattern. + :param name: Specifies the auto-follow pattern collection that you want to retrieve. + If you do not specify a name, the API returns information for all collections. """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", - _make_path("_ccr", "auto_follow", name), - params=params, - headers=headers, - ) - - @query_params() - def pause_follow(self, index, params=None, headers=None): + if name not in SKIP_IN_PATH: + __path = f"/_ccr/auto_follow/{_quote(name)}" + else: + __path = "/_ccr/auto_follow" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def pause_auto_follow_pattern( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Pauses a follower index. The follower index will not fetch any additional - operations from the leader index. + Pauses an auto-follow pattern - ``_ + ``_ - :arg index: The name of the follower index that should pause - following its leader index. + :param name: The name of the auto follow pattern that should pause discovering + new indices to follow. """ - client, params = _deprecated_options(self, params) - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return client._perform_request( - "POST", - _make_path(index, "_ccr", "pause_follow"), - params=params, - headers=headers, - ) - - @query_params() - def put_auto_follow_pattern(self, name, body, params=None, headers=None): + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_ccr/auto_follow/{_quote(name)}/pause" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters() + def pause_follow( + self, + *, + index: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - 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. + Pauses a follower index. The follower index will not fetch any additional operations + from the leader index. - ``_ + ``_ - :arg name: The name of the auto follow pattern. - :arg body: The specification of the auto follow pattern + :param index: The name of the follower index that should pause following its + leader index. """ - client, params = _deprecated_options(self, params) - for param in (name, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "PUT", - _make_path("_ccr", "auto_follow", name), - params=params, - headers=headers, - body=body, - ) - - @query_params() - def resume_follow(self, index, body=None, params=None, headers=None): + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + __path = f"/{_quote(index)}/_ccr/pause_follow" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + def put_auto_follow_pattern( + self, + *, + name: Any, + remote_cluster: str, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + follow_index_pattern: Optional[Any] = None, + human: Optional[bool] = None, + leader_index_exclusion_patterns: Optional[Any] = None, + leader_index_patterns: Optional[Any] = None, + max_outstanding_read_requests: Optional[int] = None, + max_outstanding_write_requests: Optional[int] = None, + max_read_request_operation_count: Optional[int] = None, + max_read_request_size: Optional[Any] = None, + max_retry_delay: Optional[Any] = None, + max_write_buffer_count: Optional[int] = None, + max_write_buffer_size: Optional[Any] = None, + max_write_request_operation_count: Optional[int] = None, + max_write_request_size: Optional[Any] = None, + pretty: Optional[bool] = None, + read_poll_timeout: Optional[Any] = None, + settings: Optional[Dict[str, Any]] = None, + ) -> Any: """ - 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 - related parameters + 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. + + ``_ + + :param name: The name of the collection of auto-follow patterns. + :param remote_cluster: The remote cluster containing the leader indices to match + against. + :param follow_index_pattern: The name of follower index. The template {{leader_index}} + can be used to derive the name of the follower index from the name of the + leader index. When following a data stream, use {{leader_index}}; CCR does + not support changes to the names of a follower data stream’s backing indices. + :param leader_index_exclusion_patterns: An array of simple index patterns that + can be used to exclude indices from being auto-followed. Indices in the remote + cluster whose names are matching one or more leader_index_patterns and one + or more leader_index_exclusion_patterns won’t be followed. + :param leader_index_patterns: An array of simple index patterns to match against + indices in the remote cluster specified by the remote_cluster field. + :param max_outstanding_read_requests: The maximum number of outstanding reads + requests from the remote cluster. + :param max_outstanding_write_requests: The maximum number of outstanding reads + requests from the remote cluster. + :param max_read_request_operation_count: The maximum number of operations to + pull per read from the remote cluster. + :param max_read_request_size: The maximum size in bytes of per read of a batch + of operations pulled from the remote cluster. + :param max_retry_delay: The maximum time to wait before retrying an operation + that failed exceptionally. An exponential backoff strategy is employed when + retrying. + :param max_write_buffer_count: The maximum number of operations that can be queued + for writing. When this limit is reached, reads from the remote cluster will + be deferred until the number of queued operations goes below the limit. + :param max_write_buffer_size: The maximum total bytes of operations that can + be queued for writing. When this limit is reached, reads from the remote + cluster will be deferred until the total bytes of queued operations goes + below the limit. + :param max_write_request_operation_count: The maximum number of operations per + bulk write request executed on the follower. + :param max_write_request_size: The maximum total bytes of operations per bulk + write request executed on the follower. + :param read_poll_timeout: The maximum time to wait for new operations on the + remote cluster when the follower index is synchronized with the leader index. + When the timeout has elapsed, the poll for operations will return to the + follower so that it can update some statistics. Then the follower will immediately + attempt to read from the leader again. + :param settings: Settings to override from the leader index. Note that certain + settings can not be overrode (e.g., index.number_of_shards). """ - client, params = _deprecated_options(self, params) - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return client._perform_request( - "POST", - _make_path(index, "_ccr", "resume_follow"), - params=params, - headers=headers, - body=body, - ) - - @query_params() - def stats(self, params=None, headers=None): + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + if remote_cluster is None: + raise ValueError("Empty value passed for parameter 'remote_cluster'") + __path = f"/_ccr/auto_follow/{_quote(name)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if remote_cluster is not None: + __body["remote_cluster"] = remote_cluster + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if follow_index_pattern is not None: + __body["follow_index_pattern"] = follow_index_pattern + if human is not None: + __query["human"] = human + if leader_index_exclusion_patterns is not None: + __body["leader_index_exclusion_patterns"] = leader_index_exclusion_patterns + if leader_index_patterns is not None: + __body["leader_index_patterns"] = leader_index_patterns + if max_outstanding_read_requests is not None: + __body["max_outstanding_read_requests"] = max_outstanding_read_requests + if max_outstanding_write_requests is not None: + __body["max_outstanding_write_requests"] = max_outstanding_write_requests + if max_read_request_operation_count is not None: + __body[ + "max_read_request_operation_count" + ] = max_read_request_operation_count + if max_read_request_size is not None: + __body["max_read_request_size"] = max_read_request_size + if max_retry_delay is not None: + __body["max_retry_delay"] = max_retry_delay + if max_write_buffer_count is not None: + __body["max_write_buffer_count"] = max_write_buffer_count + if max_write_buffer_size is not None: + __body["max_write_buffer_size"] = max_write_buffer_size + if max_write_request_operation_count is not None: + __body[ + "max_write_request_operation_count" + ] = max_write_request_operation_count + if max_write_request_size is not None: + __body["max_write_request_size"] = max_write_request_size + if pretty is not None: + __query["pretty"] = pretty + if read_poll_timeout is not None: + __body["read_poll_timeout"] = read_poll_timeout + if settings is not None: + __body["settings"] = settings + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("PUT", __target, headers=__headers, body=__body) + + @_rewrite_parameters() + def resume_auto_follow_pattern( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Gets all stats related to cross-cluster replication. + Resumes an auto-follow pattern that has been paused - ``_ - """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", "/_ccr/stats", params=params, headers=headers - ) + ``_ - @query_params() - def unfollow(self, index, params=None, headers=None): + :param name: The name of the auto follow pattern to resume discovering new indices + to follow. """ - Stops the following task associated with a follower index and removes index - metadata and settings associated with cross-cluster replication. - - ``_ + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_ccr/auto_follow/{_quote(name)}/resume" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + def resume_follow( + self, + *, + index: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + max_outstanding_read_requests: Optional[int] = None, + max_outstanding_write_requests: Optional[int] = None, + max_read_request_operation_count: Optional[int] = None, + max_read_request_size: Optional[str] = None, + max_retry_delay: Optional[Any] = None, + max_write_buffer_count: Optional[int] = None, + max_write_buffer_size: Optional[str] = None, + max_write_request_operation_count: Optional[int] = None, + max_write_request_size: Optional[str] = None, + pretty: Optional[bool] = None, + read_poll_timeout: Optional[Any] = None, + ) -> Any: + """ + Resumes a follower index that has been paused - :arg index: The name of the follower index that should be turned - into a regular index. + ``_ + + :param index: The name of the follow index to resume following. + :param max_outstanding_read_requests: + :param max_outstanding_write_requests: + :param max_read_request_operation_count: + :param max_read_request_size: + :param max_retry_delay: + :param max_write_buffer_count: + :param max_write_buffer_size: + :param max_write_request_operation_count: + :param max_write_request_size: + :param read_poll_timeout: """ - client, params = _deprecated_options(self, params) if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return client._perform_request( - "POST", - _make_path(index, "_ccr", "unfollow"), - params=params, - headers=headers, - ) - - @query_params() - def pause_auto_follow_pattern(self, name, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'index'") + __path = f"/{_quote(index)}/_ccr/resume_follow" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if max_outstanding_read_requests is not None: + __body["max_outstanding_read_requests"] = max_outstanding_read_requests + if max_outstanding_write_requests is not None: + __body["max_outstanding_write_requests"] = max_outstanding_write_requests + if max_read_request_operation_count is not None: + __body[ + "max_read_request_operation_count" + ] = max_read_request_operation_count + if max_read_request_size is not None: + __body["max_read_request_size"] = max_read_request_size + if max_retry_delay is not None: + __body["max_retry_delay"] = max_retry_delay + if max_write_buffer_count is not None: + __body["max_write_buffer_count"] = max_write_buffer_count + if max_write_buffer_size is not None: + __body["max_write_buffer_size"] = max_write_buffer_size + if max_write_request_operation_count is not None: + __body[ + "max_write_request_operation_count" + ] = max_write_request_operation_count + if max_write_request_size is not None: + __body["max_write_request_size"] = max_write_request_size + if pretty is not None: + __query["pretty"] = pretty + if read_poll_timeout is not None: + __body["read_poll_timeout"] = read_poll_timeout + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters() + def stats( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Pauses an auto-follow pattern - - ``_ + Gets all stats related to cross-cluster replication. - :arg name: The name of the auto follow pattern that should pause - discovering new indices to follow. + ``_ """ - client, params = _deprecated_options(self, params) - if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'name'.") - - return client._perform_request( - "POST", - _make_path("_ccr", "auto_follow", name, "pause"), - params=params, - headers=headers, - ) - - @query_params() - def resume_auto_follow_pattern(self, name, params=None, headers=None): + __path = "/_ccr/stats" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def unfollow( + self, + *, + index: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Resumes an auto-follow pattern that has been paused + Stops the following task associated with a follower index and removes index metadata + and settings associated with cross-cluster replication. - ``_ + ``_ - :arg name: The name of the auto follow pattern to resume - discovering new indices to follow. + :param index: The name of the follower index that should be turned into a regular + index. """ - client, params = _deprecated_options(self, params) - if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'name'.") - - return client._perform_request( - "POST", - _make_path("_ccr", "auto_follow", name, "resume"), - params=params, - headers=headers, - ) + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + __path = f"/{_quote(index)}/_ccr/unfollow" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) diff --git a/elasticsearch/_sync/client/ccr.pyi b/elasticsearch/_sync/client/ccr.pyi deleted file mode 100644 index 45b57b9c2..000000000 --- a/elasticsearch/_sync/client/ccr.pyi +++ /dev/null @@ -1,249 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class CcrClient(NamespacedClient): - def delete_auto_follow_pattern( - self, - name: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def follow( - self, - index: Any, - *, - body: Any, - wait_for_active_shards: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def follow_info( - self, - index: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def follow_stats( - self, - index: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def forget_follower( - self, - index: Any, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_auto_follow_pattern( - self, - *, - name: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def pause_follow( - self, - index: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def put_auto_follow_pattern( - self, - name: Any, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def resume_follow( - self, - index: Any, - *, - body: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def stats( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def unfollow( - self, - index: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def pause_auto_follow_pattern( - self, - name: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def resume_auto_follow_pattern( - self, - name: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_sync/client/cluster.py b/elasticsearch/_sync/client/cluster.py index 5e01e88a9..b70a2e1c7 100644 --- a/elasticsearch/_sync/client/cluster.py +++ b/elasticsearch/_sync/client/cluster.py @@ -15,395 +15,869 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params +from .utils import SKIP_IN_PATH, _quote, _quote_query, _rewrite_parameters class ClusterClient(NamespacedClient): - @query_params( - "expand_wildcards", - "level", - "local", - "master_timeout", - "return_200_for_cluster_health_timeout", - "timeout", - "wait_for_active_shards", - "wait_for_events", - "wait_for_no_initializing_shards", - "wait_for_no_relocating_shards", - "wait_for_nodes", - "wait_for_status", + @_rewrite_parameters( + body_fields=True, ) - def health(self, index=None, params=None, headers=None): + def allocation_explain( + self, + *, + current_node: Optional[str] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + include_disk_info: Optional[bool] = None, + include_yes_decisions: Optional[bool] = None, + index: Optional[Any] = None, + pretty: Optional[bool] = None, + primary: Optional[bool] = None, + shard: Optional[int] = None, + ) -> Any: """ - Returns basic information about the health of the cluster. + Provides explanations for shard allocations in the cluster. - ``_ + ``_ - :arg index: Limit the information returned to a specific index - :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: all - :arg level: Specify the level of detail for returned information - Valid choices: cluster, indices, shards Default: cluster - :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 - :arg return_200_for_cluster_health_timeout: Whether to return - HTTP 200 instead of 408 in case of a cluster health timeout from the - server side - :arg timeout: Explicit operation timeout - :arg wait_for_active_shards: Wait until the specified number of - shards is active - :arg wait_for_events: Wait until all currently queued events - with the given priority are processed Valid choices: immediate, urgent, - high, normal, low, languid - :arg wait_for_no_initializing_shards: Whether to wait until - there are no initializing shards in the cluster - :arg wait_for_no_relocating_shards: Whether to wait until there - are no relocating shards in the cluster - :arg wait_for_nodes: Wait until the specified number of nodes is - available - :arg wait_for_status: Wait until cluster is in a specific state - Valid choices: green, yellow, red + :param current_node: Specifies the node ID or the name of the node to only explain + a shard that is currently located on the specified node. + :param include_disk_info: If true, returns information about disk usage and shard + sizes. + :param include_yes_decisions: If true, returns YES decisions in explanation. + :param index: Specifies the name of the index that you would like an explanation + for. + :param primary: If true, returns explanation for the primary shard for the given + shard ID. + :param shard: Specifies the ID of the shard that you would like an explanation + for. """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", - _make_path("_cluster", "health", index), - params=params, - headers=headers, - ) - - @query_params("local", "master_timeout") - def pending_tasks(self, params=None, headers=None): + __path = "/_cluster/allocation/explain" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if current_node is not None: + __body["current_node"] = current_node + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if include_disk_info is not None: + __query["include_disk_info"] = include_disk_info + if include_yes_decisions is not None: + __query["include_yes_decisions"] = include_yes_decisions + if index is not None: + __body["index"] = index + if pretty is not None: + __query["pretty"] = pretty + if primary is not None: + __body["primary"] = primary + if shard is not None: + __body["shard"] = shard + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters() + def delete_component_template( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ - Returns a list of any cluster-level changes (e.g. create index, update mapping, - allocate or fail shard) which have not yet been executed. + Deletes a component template - ``_ + ``_ - :arg local: Return local information, do not retrieve the state - from master node (default: false) - :arg master_timeout: Specify timeout for connection to master + :param name: The name of the template + :param master_timeout: Specify timeout for connection to master + :param timeout: Explicit operation timeout """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", "/_cluster/pending_tasks", params=params, headers=headers - ) - - @query_params( - "allow_no_indices", - "expand_wildcards", - "flat_settings", - "ignore_unavailable", - "local", - "master_timeout", - "wait_for_metadata_version", - "wait_for_timeout", - ) - def state(self, metric=None, index=None, params=None, headers=None): + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_component_template/{_quote(name)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + def delete_voting_config_exclusions( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + wait_for_removal: Optional[bool] = None, + ) -> Any: """ - Returns a comprehensive information about the state of the cluster. + Clears cluster voting config exclusions. - ``_ + ``_ - :arg metric: Limit the information returned to the specified - metrics Valid choices: _all, blocks, metadata, nodes, routing_table, - routing_nodes, master_node, version - :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 flat_settings: Return settings in flat format (default: - false) - :arg ignore_unavailable: Whether specified concrete indices - should be ignored when unavailable (missing or closed) - :arg local: Return local information, do not retrieve the state - from master node (default: false) - :arg master_timeout: Specify timeout for connection to master - :arg wait_for_metadata_version: Wait for the metadata version to - be equal or greater than the specified metadata version - :arg wait_for_timeout: The maximum time to wait for - wait_for_metadata_version before timing out + :param wait_for_removal: Specifies whether to wait for all excluded nodes to + be removed from the cluster before clearing the voting configuration exclusions + list. Defaults to true, meaning that all excluded nodes must be removed from + the cluster before this API takes any action. If set to false then the voting + configuration exclusions list is cleared even if some excluded nodes are + still in the cluster. """ - client, params = _deprecated_options(self, params) - if index and metric in SKIP_IN_PATH: - metric = "_all" - - return client._perform_request( - "GET", - _make_path("_cluster", "state", metric, index), - params=params, - headers=headers, - ) - - @query_params("flat_settings", "timeout") - def stats(self, node_id=None, params=None, headers=None): + __path = "/_cluster/voting_config_exclusions" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if wait_for_removal is not None: + __query["wait_for_removal"] = wait_for_removal + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + def exists_component_template( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Returns high-level overview of cluster statistics. + Returns information about whether a particular component template exist - ``_ + ``_ - :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 flat_settings: Return settings in flat format (default: - false) - :arg timeout: Explicit operation timeout + :param name: Comma-separated list of component template names used to limit the + request. Wildcard (*) expressions are supported. + :param local: If true, the request retrieves information from the local node + only. Defaults to false, which means information is retrieved from the master + node. + :param master_timeout: Period to wait for a connection to the master node. If + no response is received before the timeout expires, the request fails and + returns an error. """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", - "/_cluster/stats" - if node_id in SKIP_IN_PATH - else _make_path("_cluster", "stats", "nodes", node_id), - params=params, - headers=headers, - ) - - @query_params( - "dry_run", "explain", "master_timeout", "metric", "retry_failed", "timeout" - ) - def reroute(self, body=None, params=None, headers=None): + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_component_template/{_quote(name)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("HEAD", __target, headers=__headers) + + @_rewrite_parameters() + def get_component_template( + self, + *, + name: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + flat_settings: Optional[bool] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Allows to manually change the allocation of individual shards in the cluster. + Returns one or more component templates - ``_ + ``_ - :arg body: The definition of `commands` to perform (`move`, - `cancel`, `allocate`) - :arg dry_run: Simulate the operation only and return the - resulting state - :arg explain: Return an explanation of why the commands can or - cannot be executed - :arg master_timeout: Explicit operation timeout for connection - to master node - :arg metric: Limit the information returned to the specified - metrics. Defaults to all but metadata Valid choices: _all, blocks, - metadata, nodes, routing_table, master_node, version - :arg retry_failed: Retries allocation of shards that are blocked - due to too many subsequent allocation failures - :arg timeout: Explicit operation timeout + :param name: The comma separated names of the component templates + :param flat_settings: + :param local: Return local information, do not retrieve the state from master + node (default: false) + :param master_timeout: Explicit operation timeout for connection to master node """ - client, params = _deprecated_options(self, params) - return client._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): + if name not in SKIP_IN_PATH: + __path = f"/_component_template/{_quote(name)}" + else: + __path = "/_component_template" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if flat_settings is not None: + __query["flat_settings"] = flat_settings + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def get_settings( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + flat_settings: Optional[bool] = None, + human: Optional[bool] = None, + include_defaults: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ Returns cluster settings. ``_ - :arg flat_settings: Return settings in flat format (default: - false) - :arg include_defaults: Whether to return all default clusters - setting. - :arg master_timeout: Explicit operation timeout for connection - to master node - :arg timeout: Explicit operation timeout + :param flat_settings: Return settings in flat format (default: false) + :param include_defaults: Whether to return all default clusters setting. + :param master_timeout: Explicit operation timeout for connection to master node + :param timeout: Explicit operation timeout """ - client, params = _deprecated_options(self, params) - return client._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): + __path = "/_cluster/settings" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if flat_settings is not None: + __query["flat_settings"] = flat_settings + if human is not None: + __query["human"] = human + if include_defaults is not None: + __query["include_defaults"] = include_defaults + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def health( + self, + *, + index: Optional[Any] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + level: Optional[Any] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + wait_for_active_shards: Optional[Any] = None, + wait_for_events: Optional[Any] = None, + wait_for_no_initializing_shards: Optional[bool] = None, + wait_for_no_relocating_shards: Optional[bool] = None, + wait_for_nodes: Optional[str] = None, + wait_for_status: Optional[Any] = None, + ) -> Any: """ - Updates the cluster settings. + Returns basic information about the health of the cluster. - ``_ + ``_ - :arg body: The settings to be updated. Can be either `transient` - or `persistent` (survives cluster restart). - :arg flat_settings: Return settings in flat format (default: - false) - :arg master_timeout: Explicit operation timeout for connection - to master node - :arg timeout: Explicit operation timeout + :param index: Comma-separated list of data streams, indices, and index aliases + used to limit the request. Wildcard expressions (*) are supported. To target + all data streams and indices in a cluster, omit this parameter or use _all + or *. + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param level: Can be one of cluster, indices or shards. Controls the details + level of the health information returned. + :param local: If true, the request retrieves information from the local node + only. Defaults to false, which means information is retrieved from the master + node. + :param master_timeout: Period to wait for a connection to the master node. If + no response is received before the timeout expires, the request fails and + returns an error. + :param timeout: Period to wait for a response. If no response is received before + the timeout expires, the request fails and returns an error. + :param wait_for_active_shards: A number controlling to how many active shards + to wait for, all to wait for all shards in the cluster to be active, or 0 + to not wait. + :param wait_for_events: Can be one of immediate, urgent, high, normal, low, languid. + Wait until all currently queued events with the given priority are processed. + :param wait_for_no_initializing_shards: A boolean value which controls whether + to wait (until the timeout provided) for the cluster to have no shard initializations. + Defaults to false, which means it will not wait for initializing shards. + :param wait_for_no_relocating_shards: A boolean value which controls whether + to wait (until the timeout provided) for the cluster to have no shard relocations. + Defaults to false, which means it will not wait for relocating shards. + :param wait_for_nodes: The request waits until the specified number N of nodes + is available. It also accepts >=N, <=N, >N and yellow > red. By default, will not wait for any status. """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return client._perform_request( - "PUT", "/_cluster/settings", params=params, headers=headers, body=body - ) - - @query_params() - def remote_info(self, params=None, headers=None): + if index not in SKIP_IN_PATH: + __path = f"/_cluster/health/{_quote(index)}" + else: + __path = "/_cluster/health" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if level is not None: + __query["level"] = level + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if wait_for_active_shards is not None: + __query["wait_for_active_shards"] = wait_for_active_shards + if wait_for_events is not None: + __query["wait_for_events"] = wait_for_events + if wait_for_no_initializing_shards is not None: + __query["wait_for_no_initializing_shards"] = wait_for_no_initializing_shards + if wait_for_no_relocating_shards is not None: + __query["wait_for_no_relocating_shards"] = wait_for_no_relocating_shards + if wait_for_nodes is not None: + __query["wait_for_nodes"] = wait_for_nodes + if wait_for_status is not None: + __query["wait_for_status"] = wait_for_status + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def pending_tasks( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Returns the information about configured remote clusters. + Returns a list of any cluster-level changes (e.g. create index, update mapping, + allocate or fail shard) which have not yet been executed. - ``_ - """ - client, params = _deprecated_options(self, params) - return client._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): + :param local: Return local information, do not retrieve the state from master + node (default: false) + :param master_timeout: Specify timeout for connection to master """ - Provides explanations for shard allocations in the cluster. + __path = "/_cluster/pending_tasks" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def post_voting_config_exclusions( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + node_ids: Optional[Any] = None, + node_names: Optional[Any] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: + """ + Updates the cluster voting config exclusions by node ids or node names. - ``_ + ``_ - :arg body: The index, shard, and primary flag to explain. Empty - means 'explain a randomly-chosen unassigned shard' - :arg include_disk_info: Return information about disk usage and - shard sizes (default: false) - :arg include_yes_decisions: Return 'YES' decisions in - explanation (default: false) + :param node_ids: A comma-separated list of the persistent ids of the nodes to + exclude from the voting configuration. If specified, you may not also specify + node_names. + :param node_names: A comma-separated list of the names of the nodes to exclude + from the voting configuration. If specified, you may not also specify node_ids. + :param timeout: When adding a voting configuration exclusion, the API waits for + the specified nodes to be excluded from the voting configuration before returning. + If the timeout expires before the appropriate condition is satisfied, the + request fails and returns an error. """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "POST", - "/_cluster/allocation/explain", - params=params, - headers=headers, - body=body, - ) - - @query_params("master_timeout", "timeout") - def delete_component_template(self, name, params=None, headers=None): + __path = "/_cluster/voting_config_exclusions" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if node_ids is not None: + __query["node_ids"] = node_ids + if node_names is not None: + __query["node_names"] = node_names + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + parameter_aliases={"_meta": "meta"}, + ) + def put_component_template( + self, + *, + name: Any, + template: Any, + aliases: Optional[Dict[str, Any]] = None, + create: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + mappings: Optional[Any] = None, + master_timeout: Optional[Any] = None, + meta: Optional[Any] = None, + pretty: Optional[bool] = None, + settings: Optional[Any] = None, + version: Optional[Any] = None, + ) -> Any: """ - Deletes a component template + Creates or updates a component template ``_ - :arg name: The name of the template - :arg master_timeout: Specify timeout for connection to master - :arg timeout: Explicit operation timeout + :param name: The name of the template + :param template: + :param aliases: + :param create: Whether the index template should only be added if new or can + also replace an existing one + :param mappings: + :param master_timeout: Specify timeout for connection to master + :param meta: + :param settings: + :param version: """ - client, params = _deprecated_options(self, params) if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'name'.") - - return client._perform_request( - "DELETE", - _make_path("_component_template", name), - params=params, - headers=headers, - ) - - @query_params("local", "master_timeout") - def get_component_template(self, name=None, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'name'") + if template is None: + raise ValueError("Empty value passed for parameter 'template'") + __path = f"/_component_template/{_quote(name)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if template is not None: + __body["template"] = template + if aliases is not None: + __body["aliases"] = aliases + if create is not None: + __query["create"] = create + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if mappings is not None: + __body["mappings"] = mappings + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if meta is not None: + __body["_meta"] = meta + if pretty is not None: + __query["pretty"] = pretty + if settings is not None: + __body["settings"] = settings + if version is not None: + __body["version"] = version + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("PUT", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, + ) + def put_settings( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + flat_settings: Optional[bool] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + persistent: Optional[Dict[str, Any]] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + transient: Optional[Dict[str, Any]] = None, + ) -> Any: """ - Returns one or more component templates + Updates the cluster settings. - ``_ + ``_ - :arg name: The comma separated names of the component templates - :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 + :param flat_settings: Return settings in flat format (default: false) + :param master_timeout: Explicit operation timeout for connection to master node + :param persistent: + :param timeout: Explicit operation timeout + :param transient: """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", - _make_path("_component_template", name), - params=params, - headers=headers, - ) - - @query_params("create", "master_timeout", "timeout") - def put_component_template(self, name, body, params=None, headers=None): + __path = "/_cluster/settings" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if flat_settings is not None: + __query["flat_settings"] = flat_settings + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if persistent is not None: + __body["persistent"] = persistent + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if transient is not None: + __body["transient"] = transient + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("PUT", __target, headers=__headers, body=__body) + + @_rewrite_parameters() + def remote_info( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Creates or updates a component template - - ``_ + Returns the information about configured remote clusters. - :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 master_timeout: Specify timeout for connection to master - :arg timeout: Explicit operation timeout + ``_ """ - client, params = _deprecated_options(self, params) - for param in (name, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "PUT", - _make_path("_component_template", name), - params=params, - headers=headers, - body=body, - ) - - @query_params("local", "master_timeout") - def exists_component_template(self, name, params=None, headers=None): + __path = "/_remote/info" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + def reroute( + self, + *, + commands: Optional[List[Any]] = None, + dry_run: Optional[bool] = None, + error_trace: Optional[bool] = None, + explain: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + metric: Optional[Any] = None, + pretty: Optional[bool] = None, + retry_failed: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ - Returns information about whether a particular component template exist + Allows to manually change the allocation of individual shards in the cluster. - ``_ + ``_ - :arg name: The name of the template - :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 + :param commands: Defines the commands to perform. + :param dry_run: If true, then the request simulates the operation only and returns + the resulting state. + :param explain: If true, then the response contains an explanation of why the + commands can or cannot be executed. + :param master_timeout: Period to wait for a connection to the master node. If + no response is received before the timeout expires, the request fails and + returns an error. + :param metric: Limits the information returned to the specified metrics. + :param retry_failed: If true, then retries allocation of shards that are blocked + due to too many subsequent allocation failures. + :param timeout: Period to wait for a response. If no response is received before + the timeout expires, the request fails and returns an error. """ - client, params = _deprecated_options(self, params) - if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'name'.") - - return client._perform_request( - "HEAD", - _make_path("_component_template", name), - params=params, - headers=headers, - ) - - @query_params("wait_for_removal") - def delete_voting_config_exclusions(self, params=None, headers=None): + __path = "/_cluster/reroute" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if commands is not None: + __body["commands"] = commands + if dry_run is not None: + __query["dry_run"] = dry_run + if error_trace is not None: + __query["error_trace"] = error_trace + if explain is not None: + __query["explain"] = explain + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if metric is not None: + __query["metric"] = metric + if pretty is not None: + __query["pretty"] = pretty + if retry_failed is not None: + __query["retry_failed"] = retry_failed + if timeout is not None: + __query["timeout"] = timeout + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters() + def state( + self, + *, + metric: Optional[Any] = None, + index: Optional[Any] = None, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + flat_settings: Optional[bool] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + wait_for_metadata_version: Optional[Any] = None, + wait_for_timeout: Optional[Any] = None, + ) -> Any: """ - Clears cluster voting config exclusions. + Returns a comprehensive information about the state of the cluster. - ``_ + ``_ - :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 + :param metric: Limit the information returned to the specified metrics + :param index: A comma-separated list of index names; use `_all` or empty string + to perform the operation on all indices + :param 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) + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param flat_settings: Return settings in flat format (default: false) + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param local: Return local information, do not retrieve the state from master + node (default: false) + :param master_timeout: Specify timeout for connection to master + :param wait_for_metadata_version: Wait for the metadata version to be equal or + greater than the specified metadata version + :param wait_for_timeout: The maximum time to wait for wait_for_metadata_version + before timing out """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "DELETE", - "/_cluster/voting_config_exclusions", - params=params, - headers=headers, - ) - - @query_params("node_ids", "node_names", "timeout") - def post_voting_config_exclusions(self, params=None, headers=None): + if metric not in SKIP_IN_PATH and index not in SKIP_IN_PATH: + __path = f"/_cluster/state/{_quote(metric)}/{_quote(index)}" + elif metric not in SKIP_IN_PATH: + __path = f"/_cluster/state/{_quote(metric)}" + elif index not in SKIP_IN_PATH: + __path = f"/_cluster/state/_all/{_quote(index)}" + else: + __path = "/_cluster/state" + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if flat_settings is not None: + __query["flat_settings"] = flat_settings + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if wait_for_metadata_version is not None: + __query["wait_for_metadata_version"] = wait_for_metadata_version + if wait_for_timeout is not None: + __query["wait_for_timeout"] = wait_for_timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def stats( + self, + *, + node_id: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + flat_settings: Optional[bool] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ - Updates the cluster voting config exclusions by node ids or node names. + Returns high-level overview of cluster statistics. - ``_ + ``_ - :arg node_ids: A comma-separated list of the persistent ids of - the nodes to exclude from the voting configuration. If specified, you - may not also specify ?node_names. - :arg node_names: A comma-separated list of the names of the - nodes to exclude from the voting configuration. If specified, you may - not also specify ?node_ids. - :arg timeout: Explicit operation timeout Default: 30s + :param node_id: Comma-separated list of node filters used to limit returned information. + Defaults to all nodes in the cluster. + :param flat_settings: Return settings in flat format (default: false) + :param timeout: Period to wait for each node to respond. If a node does not respond + before its timeout expires, the response does not include its stats. However, + timed out nodes are included in the response’s _nodes.failed property. Defaults + to no timeout. """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "POST", "/_cluster/voting_config_exclusions", params=params, headers=headers - ) + if node_id not in SKIP_IN_PATH: + __path = f"/_cluster/stats/nodes/{_quote(node_id)}" + else: + __path = "/_cluster/stats" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if flat_settings is not None: + __query["flat_settings"] = flat_settings + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) diff --git a/elasticsearch/_sync/client/cluster.pyi b/elasticsearch/_sync/client/cluster.pyi deleted file mode 100644 index a1d4ec6da..000000000 --- a/elasticsearch/_sync/client/cluster.pyi +++ /dev/null @@ -1,328 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import HeadApiResponse, ObjectApiResponse - -from ._base import NamespacedClient - -class ClusterClient(NamespacedClient): - def health( - self, - *, - index: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - level: Optional[Any] = ..., - local: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - return_200_for_cluster_health_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - wait_for_active_shards: Optional[Any] = ..., - wait_for_events: Optional[Any] = ..., - wait_for_no_initializing_shards: Optional[Any] = ..., - wait_for_no_relocating_shards: Optional[Any] = ..., - wait_for_nodes: Optional[Any] = ..., - wait_for_status: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def pending_tasks( - self, - *, - local: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def state( - self, - *, - metric: Optional[Any] = ..., - index: Optional[Any] = ..., - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - flat_settings: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - local: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - wait_for_metadata_version: Optional[Any] = ..., - wait_for_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def stats( - self, - *, - node_id: Optional[Any] = ..., - flat_settings: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def reroute( - self, - *, - body: Optional[Any] = ..., - dry_run: Optional[Any] = ..., - explain: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - metric: Optional[Any] = ..., - retry_failed: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_settings( - self, - *, - flat_settings: Optional[Any] = ..., - include_defaults: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def put_settings( - self, - *, - body: Any, - flat_settings: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def remote_info( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def allocation_explain( - self, - *, - body: Optional[Any] = ..., - include_disk_info: Optional[Any] = ..., - include_yes_decisions: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def delete_component_template( - self, - name: Any, - *, - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_component_template( - self, - *, - name: Optional[Any] = ..., - local: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def put_component_template( - self, - name: Any, - *, - body: Any, - create: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def exists_component_template( - self, - name: Any, - *, - local: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> HeadApiResponse: ... - def delete_voting_config_exclusions( - self, - *, - wait_for_removal: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def post_voting_config_exclusions( - self, - *, - node_ids: Optional[Any] = ..., - node_names: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_sync/client/dangling_indices.py b/elasticsearch/_sync/client/dangling_indices.py index 3da24eeba..3a76d9323 100644 --- a/elasticsearch/_sync/client/dangling_indices.py +++ b/elasticsearch/_sync/client/dangling_indices.py @@ -15,64 +15,142 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params +from .utils import SKIP_IN_PATH, _quote, _quote_query, _rewrite_parameters class DanglingIndicesClient(NamespacedClient): - @query_params("accept_data_loss", "master_timeout", "timeout") - def delete_dangling_index(self, index_uuid, params=None, headers=None): + @_rewrite_parameters() + def delete_dangling_index( + self, + *, + index_uuid: Any, + accept_data_loss: bool, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ Deletes the specified dangling index ``_ - :arg index_uuid: The UUID of the dangling index - :arg accept_data_loss: Must be set to true in order to delete - the dangling index - :arg master_timeout: Specify timeout for connection to master - :arg timeout: Explicit operation timeout + :param index_uuid: The UUID of the dangling index + :param accept_data_loss: Must be set to true in order to delete the dangling + index + :param master_timeout: Specify timeout for connection to master + :param timeout: Explicit operation timeout """ - client, params = _deprecated_options(self, params) if index_uuid in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index_uuid'.") - - return client._perform_request( - "DELETE", - _make_path("_dangling", index_uuid), - params=params, - headers=headers, - ) + raise ValueError("Empty value passed for parameter 'index_uuid'") + if accept_data_loss is None: + raise ValueError("Empty value passed for parameter 'accept_data_loss'") + __path = f"/_dangling/{_quote(index_uuid)}" + __query: Dict[str, Any] = {} + if accept_data_loss is not None: + __query["accept_data_loss"] = accept_data_loss + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("DELETE", __target, headers=__headers) - @query_params("accept_data_loss", "master_timeout", "timeout") - def import_dangling_index(self, index_uuid, params=None, headers=None): + @_rewrite_parameters() + def import_dangling_index( + self, + *, + index_uuid: Any, + accept_data_loss: bool, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ Imports the specified dangling index ``_ - :arg index_uuid: The UUID of the dangling index - :arg accept_data_loss: Must be set to true in order to import - the dangling index - :arg master_timeout: Specify timeout for connection to master - :arg timeout: Explicit operation timeout + :param index_uuid: The UUID of the dangling index + :param accept_data_loss: Must be set to true in order to import the dangling + index + :param master_timeout: Specify timeout for connection to master + :param timeout: Explicit operation timeout """ - client, params = _deprecated_options(self, params) if index_uuid in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index_uuid'.") - - return client._perform_request( - "POST", _make_path("_dangling", index_uuid), params=params, headers=headers - ) + raise ValueError("Empty value passed for parameter 'index_uuid'") + if accept_data_loss is None: + raise ValueError("Empty value passed for parameter 'accept_data_loss'") + __path = f"/_dangling/{_quote(index_uuid)}" + __query: Dict[str, Any] = {} + if accept_data_loss is not None: + __query["accept_data_loss"] = accept_data_loss + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) - @query_params() - def list_dangling_indices(self, params=None, headers=None): + @_rewrite_parameters() + def list_dangling_indices( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Returns all dangling indices. ``_ """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", "/_dangling", params=params, headers=headers - ) + __path = "/_dangling" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) diff --git a/elasticsearch/_sync/client/dangling_indices.pyi b/elasticsearch/_sync/client/dangling_indices.pyi deleted file mode 100644 index a15da81cc..000000000 --- a/elasticsearch/_sync/client/dangling_indices.pyi +++ /dev/null @@ -1,80 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class DanglingIndicesClient(NamespacedClient): - def delete_dangling_index( - self, - index_uuid: Any, - *, - accept_data_loss: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def import_dangling_index( - self, - index_uuid: Any, - *, - accept_data_loss: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def list_dangling_indices( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_sync/client/enrich.py b/elasticsearch/_sync/client/enrich.py index 8d30bc1e8..80d95f06a 100644 --- a/elasticsearch/_sync/client/enrich.py +++ b/elasticsearch/_sync/client/enrich.py @@ -15,99 +15,202 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params +from .utils import SKIP_IN_PATH, _quote, _quote_query, _rewrite_parameters class EnrichClient(NamespacedClient): - @query_params() - def delete_policy(self, name, params=None, headers=None): + @_rewrite_parameters() + def delete_policy( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Deletes an existing enrich policy and its enrich index. - ``_ + ``_ - :arg name: The name of the enrich policy + :param name: The name of the enrich policy """ - client, params = _deprecated_options(self, params) if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'name'.") - - return client._perform_request( - "DELETE", - _make_path("_enrich", "policy", name), - params=params, - headers=headers, - ) - - @query_params("wait_for_completion") - def execute_policy(self, name, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_enrich/policy/{_quote(name)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + def execute_policy( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + wait_for_completion: Optional[bool] = None, + ) -> Any: """ 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 - the execution is complete. Default: True + :param name: The name of the enrich policy + :param wait_for_completion: Should the request should block until the execution + is complete. """ - client, params = _deprecated_options(self, params) if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'name'.") - - return client._perform_request( - "PUT", - _make_path("_enrich", "policy", name, "_execute"), - params=params, - headers=headers, - ) - - @query_params() - def get_policy(self, name=None, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_enrich/policy/{_quote(name)}/_execute" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if wait_for_completion is not None: + __query["wait_for_completion"] = wait_for_completion + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("PUT", __target, headers=__headers) + + @_rewrite_parameters() + def get_policy( + self, + *, + name: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Gets information about an enrich policy. - ``_ + ``_ - :arg name: A comma-separated list of enrich policy names + :param name: A comma-separated list of enrich policy names """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", _make_path("_enrich", "policy", name), params=params, headers=headers - ) - - @query_params() - def put_policy(self, name, body, params=None, headers=None): + if name not in SKIP_IN_PATH: + __path = f"/_enrich/policy/{_quote(name)}" + else: + __path = "/_enrich/policy" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + def put_policy( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + geo_match: Optional[Any] = None, + human: Optional[bool] = None, + match: Optional[Any] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Creates a new enrich policy. - ``_ + ``_ - :arg name: The name of the enrich policy - :arg body: The enrich policy to register + :param name: The name of the enrich policy + :param geo_match: + :param match: """ - client, params = _deprecated_options(self, params) - for param in (name, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "PUT", - _make_path("_enrich", "policy", name), - params=params, - headers=headers, - body=body, - ) - - @query_params() - def stats(self, params=None, headers=None): + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_enrich/policy/{_quote(name)}" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if geo_match is not None: + __body["geo_match"] = geo_match + if human is not None: + __query["human"] = human + if match is not None: + __body["match"] = match + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("PUT", __target, headers=__headers, body=__body) + + @_rewrite_parameters() + def stats( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Gets enrich coordinator statistics and information about enrich policies that are currently executing. - ``_ + ``_ """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", "/_enrich/_stats", params=params, headers=headers - ) + __path = "/_enrich/_stats" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) diff --git a/elasticsearch/_sync/client/enrich.pyi b/elasticsearch/_sync/client/enrich.pyi deleted file mode 100644 index 8376cf35c..000000000 --- a/elasticsearch/_sync/client/enrich.pyi +++ /dev/null @@ -1,110 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class EnrichClient(NamespacedClient): - def delete_policy( - self, - name: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def execute_policy( - self, - name: Any, - *, - wait_for_completion: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_policy( - self, - *, - name: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def put_policy( - self, - name: Any, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def stats( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_sync/client/eql.py b/elasticsearch/_sync/client/eql.py index 7f04ff4fa..64c3a01cc 100644 --- a/elasticsearch/_sync/client/eql.py +++ b/elasticsearch/_sync/client/eql.py @@ -15,99 +15,243 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params +from .utils import SKIP_IN_PATH, _quote, _quote_query, _rewrite_parameters class EqlClient(NamespacedClient): - @query_params("keep_alive", "keep_on_completion", "wait_for_completion_timeout") - def search(self, index, body, params=None, headers=None): + @_rewrite_parameters() + def delete( + self, + *, + id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Returns results matching a query expressed in Event Query Language (EQL) + Deletes an async EQL search by ID. If the search is still running, the search + request will be cancelled. Otherwise, the saved search results are deleted. - ``_ + ``_ - :arg index: The name of the index to scope the operation - :arg body: Eql request body. Use the `query` to limit the query - scope. - :arg keep_alive: Update the time interval in which the results - (partial or final) for this search will be available Default: 5d - :arg keep_on_completion: Control whether the response should be - stored in the cluster if it completed within the provided - [wait_for_completion] time (default: false) - :arg wait_for_completion_timeout: Specify the time that the - request should block waiting for the final response + :param id: Identifier for the search to delete. """ - client, params = _deprecated_options(self, params) - for param in (index, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "POST", - _make_path(index, "_eql", "search"), - params=params, - headers=headers, - body=body, - ) + if id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/_eql/search/{_quote(id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("DELETE", __target, headers=__headers) - @query_params() - def delete(self, id, params=None, headers=None): + @_rewrite_parameters() + def get( + self, + *, + id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + keep_alive: Optional[Any] = None, + pretty: Optional[bool] = None, + wait_for_completion_timeout: Optional[Any] = None, + ) -> Any: """ - Deletes an async EQL search by ID. If the search is still running, the search - request will be cancelled. Otherwise, the saved search results are deleted. + Returns async results from previously executed Event Query Language (EQL) search - ``_ + ``_ - :arg id: The async search ID + :param id: Identifier for the search. + :param keep_alive: Period for which the search and its results are stored on + the cluster. Defaults to the keep_alive value set by the search’s EQL search + API request. + :param wait_for_completion_timeout: Timeout duration to wait for the request + to finish. Defaults to no timeout, meaning the request waits for complete + search results. """ - client, params = _deprecated_options(self, params) if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'id'.") - - return client._perform_request( - "DELETE", _make_path("_eql", "search", id), params=params, headers=headers - ) + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/_eql/search/{_quote(id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if keep_alive is not None: + __query["keep_alive"] = keep_alive + if pretty is not None: + __query["pretty"] = pretty + if wait_for_completion_timeout is not None: + __query["wait_for_completion_timeout"] = wait_for_completion_timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) - @query_params("keep_alive", "wait_for_completion_timeout") - def get(self, id, params=None, headers=None): + @_rewrite_parameters() + def get_status( + self, + *, + id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Returns async results from previously executed Event Query Language (EQL) - search + Returns the status of a previously submitted async or stored Event Query Language + (EQL) search - ``_ + ``_ - :arg id: The async search ID - :arg keep_alive: Update the time interval in which the results - (partial or final) for this search will be available Default: 5d - :arg wait_for_completion_timeout: Specify the time that the - request should block waiting for the final response + :param id: Identifier for the search. """ - client, params = _deprecated_options(self, params) if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'id'.") - - return client._perform_request( - "GET", _make_path("_eql", "search", id), params=params, headers=headers - ) + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/_eql/search/status/{_quote(id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) - @query_params() - def get_status(self, id, params=None, headers=None): + @_rewrite_parameters( + body_fields=True, + ) + def search( + self, + *, + index: Any, + query: str, + allow_no_indices: Optional[bool] = None, + case_sensitive: Optional[bool] = None, + error_trace: Optional[bool] = None, + event_category_field: Optional[Any] = None, + expand_wildcards: Optional[Any] = None, + fetch_size: Optional[int] = None, + fields: Optional[List[Any]] = None, + filter: Optional[Union[Any, List[Any]]] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + keep_alive: Optional[Any] = None, + keep_on_completion: Optional[bool] = None, + pretty: Optional[bool] = None, + result_position: Optional[Any] = None, + size: Optional[Union[float, int]] = None, + tiebreaker_field: Optional[Any] = None, + timestamp_field: Optional[Any] = None, + wait_for_completion_timeout: Optional[Any] = None, + ) -> Any: """ - Returns the status of a previously submitted async or stored Event Query - Language (EQL) search + Returns results matching a query expressed in Event Query Language (EQL) - ``_ + ``_ - :arg id: The async search ID + :param index: The name of the index to scope the operation + :param query: EQL query you wish to run. + :param allow_no_indices: + :param case_sensitive: + :param event_category_field: Field containing the event classification, such + as process, file, or network. + :param expand_wildcards: + :param fetch_size: Maximum number of events to search at a time for sequence + queries. + :param fields: Array of wildcard (*) patterns. The response returns values for + field names matching these patterns in the fields property of each hit. + :param filter: Query, written in Query DSL, used to filter the events on which + the EQL query runs. + :param ignore_unavailable: If true, missing or closed indices are not included + in the response. + :param keep_alive: + :param keep_on_completion: + :param result_position: + :param size: For basic queries, the maximum number of matching events to return. + Defaults to 10 + :param tiebreaker_field: Field used to sort hits with the same timestamp in ascending + order + :param timestamp_field: Field containing event timestamp. Default "@timestamp" + :param wait_for_completion_timeout: """ - client, params = _deprecated_options(self, params) - if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'id'.") - - return client._perform_request( - "GET", - _make_path("_eql", "search", "status", id), - params=params, - headers=headers, - ) + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + if query is None: + raise ValueError("Empty value passed for parameter 'query'") + __path = f"/{_quote(index)}/_eql/search" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if query is not None: + __body["query"] = query + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if case_sensitive is not None: + __body["case_sensitive"] = case_sensitive + if error_trace is not None: + __query["error_trace"] = error_trace + if event_category_field is not None: + __body["event_category_field"] = event_category_field + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if fetch_size is not None: + __body["fetch_size"] = fetch_size + if fields is not None: + __body["fields"] = fields + if filter is not None: + __body["filter"] = filter + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if keep_alive is not None: + __body["keep_alive"] = keep_alive + if keep_on_completion is not None: + __body["keep_on_completion"] = keep_on_completion + if pretty is not None: + __query["pretty"] = pretty + if result_position is not None: + __body["result_position"] = result_position + if size is not None: + __body["size"] = size + if tiebreaker_field is not None: + __body["tiebreaker_field"] = tiebreaker_field + if timestamp_field is not None: + __body["timestamp_field"] = timestamp_field + if wait_for_completion_timeout is not None: + __body["wait_for_completion_timeout"] = wait_for_completion_timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("POST", __target, headers=__headers, body=__body) diff --git a/elasticsearch/_sync/client/eql.pyi b/elasticsearch/_sync/client/eql.pyi deleted file mode 100644 index ac3f9f991..000000000 --- a/elasticsearch/_sync/client/eql.pyi +++ /dev/null @@ -1,98 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class EqlClient(NamespacedClient): - def search( - self, - index: Any, - *, - body: Any, - keep_alive: Optional[Any] = ..., - keep_on_completion: Optional[Any] = ..., - wait_for_completion_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def delete( - self, - id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get( - self, - id: Any, - *, - keep_alive: Optional[Any] = ..., - wait_for_completion_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_status( - self, - id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_sync/client/features.py b/elasticsearch/_sync/client/features.py index 98736681e..e0664b3d8 100644 --- a/elasticsearch/_sync/client/features.py +++ b/elasticsearch/_sync/client/features.py @@ -15,40 +15,72 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import _deprecated_options, query_params +from .utils import _quote_query, _rewrite_parameters class FeaturesClient(NamespacedClient): - @query_params("master_timeout") - def get_features(self, params=None, headers=None): + @_rewrite_parameters() + def get_features( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Gets a list of features which can be included in snapshots using the - feature_states field when creating a snapshot + Gets a list of features which can be included in snapshots using the feature_states + field when creating a snapshot ``_ - - :arg master_timeout: Explicit operation timeout for connection - to master node """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", "/_features", params=params, headers=headers - ) + __path = "/_features" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) - @query_params() - def reset_features(self, params=None, headers=None): + @_rewrite_parameters() + def reset_features( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Resets the internal state of features, usually by deleting system indices ``_ - - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "POST", "/_features/_reset", params=params, headers=headers - ) + __path = "/_features/_reset" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) diff --git a/elasticsearch/_sync/client/features.pyi b/elasticsearch/_sync/client/features.pyi deleted file mode 100644 index acc9f0f27..000000000 --- a/elasticsearch/_sync/client/features.pyi +++ /dev/null @@ -1,57 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class FeaturesClient(NamespacedClient): - def get_features( - self, - *, - master_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def reset_features( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_sync/client/fleet.py b/elasticsearch/_sync/client/fleet.py deleted file mode 100644 index 3eed76116..000000000 --- a/elasticsearch/_sync/client/fleet.py +++ /dev/null @@ -1,116 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params - - -class FleetClient(NamespacedClient): - @query_params("checkpoints", "timeout", "wait_for_advance", "wait_for_index") - def global_checkpoints(self, index, params=None, headers=None): - """ - Returns the current global checkpoints for an index. This API is design for - internal use by the fleet server project. - - ``_ - - :arg index: The name of the index. - :arg checkpoints: Comma separated list of checkpoints - :arg timeout: Timeout to wait for global checkpoint to advance - Default: 30s - :arg wait_for_advance: Whether to wait for the global checkpoint - to advance past the specified current checkpoints Default: false - :arg wait_for_index: Whether to wait for the target index to - exist and all primary shards be active Default: false - """ - client, params = _deprecated_options(self, params) - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return client._perform_request( - "GET", - _make_path(index, "_fleet", "global_checkpoints"), - params=params, - headers=headers, - ) - - @query_params() - def msearch(self, body, index=None, params=None, headers=None): - """ - Multi Search API where the search will only be executed after specified - checkpoints are available due to a refresh. This API is designed for internal - use by the fleet server project. - - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - - :arg body: The request definitions (metadata-fleet search - request definition pairs), separated by newlines - :arg index: The index name to use as the default - """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - headers["content-type"] = "application/x-ndjson" - return client._perform_request( - "POST", - _make_path(index, "_fleet", "_fleet_msearch"), - params=params, - headers=headers, - body=body, - ) - - @query_params( - "allow_partial_search_results", - "wait_for_checkpoints", - "wait_for_checkpoints_timeout", - ) - def search(self, index, body=None, params=None, headers=None): - """ - Search API where the search will only be executed after specified checkpoints - are available due to a refresh. This API is designed for internal use by the - fleet server project. - - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - - :arg index: The index name to search. - :arg body: The search definition using the Query DSL - :arg allow_partial_search_results: Indicate if an error should - be returned if there is a partial search failure or timeout Default: - True - :arg wait_for_checkpoints: Comma separated list of checkpoints, - one per shard - :arg wait_for_checkpoints_timeout: Explicit wait_for_checkpoints - timeout - """ - client, params = _deprecated_options(self, params) - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return client._perform_request( - "POST", - _make_path(index, "_fleet", "_fleet_search"), - params=params, - headers=headers, - body=body, - ) diff --git a/elasticsearch/_sync/client/fleet.pyi b/elasticsearch/_sync/client/fleet.pyi deleted file mode 100644 index 93d3b8a72..000000000 --- a/elasticsearch/_sync/client/fleet.pyi +++ /dev/null @@ -1,84 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class FleetClient(NamespacedClient): - def global_checkpoints( - self, - index: Any, - *, - checkpoints: Optional[Any] = ..., - timeout: Optional[Any] = ..., - wait_for_advance: Optional[Any] = ..., - wait_for_index: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def msearch( - self, - *, - body: Any, - index: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def search( - self, - index: Any, - *, - body: Optional[Any] = ..., - allow_partial_search_results: Optional[Any] = ..., - wait_for_checkpoints: Optional[Any] = ..., - wait_for_checkpoints_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_sync/client/graph.py b/elasticsearch/_sync/client/graph.py index 9d82ad7e0..b78758d7b 100644 --- a/elasticsearch/_sync/client/graph.py +++ b/elasticsearch/_sync/client/graph.py @@ -15,33 +15,78 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params +from .utils import SKIP_IN_PATH, _quote, _quote_query, _rewrite_parameters class GraphClient(NamespacedClient): - @query_params("routing", "timeout") - def explore(self, index, body=None, params=None, headers=None): + @_rewrite_parameters( + body_fields=True, + ) + def explore( + self, + *, + index: Any, + connections: Optional[Any] = None, + controls: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + query: Optional[Any] = None, + routing: Optional[Any] = None, + timeout: Optional[Any] = None, + vertices: Optional[List[Any]] = None, + ) -> Any: """ 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 routing: Specific routing value - :arg timeout: Explicit operation timeout + :param index: A comma-separated list of index names to search; use `_all` or + empty string to perform the operation on all indices + :param connections: + :param controls: + :param query: + :param routing: Specific routing value + :param timeout: Explicit operation timeout + :param vertices: """ - client, params = _deprecated_options(self, params) if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return client._perform_request( - "POST", - _make_path(index, "_graph", "explore"), - params=params, - headers=headers, - body=body, - ) + raise ValueError("Empty value passed for parameter 'index'") + __path = f"/{_quote(index)}/_graph/explore" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if connections is not None: + __body["connections"] = connections + if controls is not None: + __body["controls"] = controls + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if query is not None: + __body["query"] = query + if routing is not None: + __query["routing"] = routing + if timeout is not None: + __query["timeout"] = timeout + if vertices is not None: + __body["vertices"] = vertices + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("POST", __target, headers=__headers, body=__body) diff --git a/elasticsearch/_sync/client/graph.pyi b/elasticsearch/_sync/client/graph.pyi deleted file mode 100644 index ec67ba386..000000000 --- a/elasticsearch/_sync/client/graph.pyi +++ /dev/null @@ -1,44 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class GraphClient(NamespacedClient): - def explore( - self, - index: Any, - *, - body: Optional[Any] = ..., - routing: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_sync/client/ilm.py b/elasticsearch/_sync/client/ilm.py index bed270add..5b74ca58a 100644 --- a/elasticsearch/_sync/client/ilm.py +++ b/elasticsearch/_sync/client/ilm.py @@ -15,206 +15,414 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params +from .utils import SKIP_IN_PATH, _quote, _quote_query, _rewrite_parameters class IlmClient(NamespacedClient): - @query_params() - def delete_lifecycle(self, policy, params=None, headers=None): + @_rewrite_parameters() + def delete_lifecycle( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Deletes the specified lifecycle policy definition. A currently used policy - cannot be deleted. + Deletes the specified lifecycle policy definition. A currently used policy cannot + be deleted. - ``_ + ``_ - :arg policy: The name of the index lifecycle policy + :param name: The name of the index lifecycle policy """ - client, params = _deprecated_options(self, params) - if policy in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'policy'.") - - return client._perform_request( - "DELETE", - _make_path("_ilm", "policy", policy), - params=params, - headers=headers, - ) - - @query_params("only_errors", "only_managed") - def explain_lifecycle(self, index, params=None, headers=None): + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_ilm/policy/{_quote(name)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + def explain_lifecycle( + self, + *, + index: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + only_errors: Optional[bool] = None, + only_managed: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ 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 - to ones in an ILM error state, implies only_managed - :arg only_managed: filters the indices included in the response - to ones managed by ILM + :param index: The name of the index to explain + :param only_errors: filters the indices included in the response to ones in an + ILM error state, implies only_managed + :param only_managed: filters the indices included in the response to ones managed + by ILM """ - client, params = _deprecated_options(self, params) if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return client._perform_request( - "GET", _make_path(index, "_ilm", "explain"), params=params, headers=headers - ) - - @query_params() - def get_lifecycle(self, policy=None, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'index'") + __path = f"/{_quote(index)}/_ilm/explain" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if only_errors is not None: + __query["only_errors"] = only_errors + if only_managed is not None: + __query["only_managed"] = only_managed + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def get_lifecycle( + self, + *, + name: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Returns the specified policy definition. Includes the policy version and last modified date. - ``_ + ``_ - :arg policy: The name of the index lifecycle policy + :param name: The name of the index lifecycle policy """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", _make_path("_ilm", "policy", policy), params=params, headers=headers - ) - - @query_params() - def get_status(self, params=None, headers=None): + if name not in SKIP_IN_PATH: + __path = f"/_ilm/policy/{_quote(name)}" + else: + __path = "/_ilm/policy" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def get_status( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Retrieves the current index lifecycle management (ILM) status. - ``_ + ``_ """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", "/_ilm/status", params=params, headers=headers - ) - - @query_params() - def move_to_step(self, index, body=None, params=None, headers=None): + __path = "/_ilm/status" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + def move_to_step( + self, + *, + index: Any, + current_step: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + next_step: Optional[Any] = None, + pretty: Optional[bool] = None, + ) -> Any: """ 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 - :arg body: The new lifecycle step to move to + :param index: The name of the index whose lifecycle step is to change + :param current_step: + :param next_step: """ - client, params = _deprecated_options(self, params) if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return client._perform_request( - "POST", - _make_path("_ilm", "move", index), - params=params, - headers=headers, - body=body, - ) - - @query_params() - def put_lifecycle(self, policy, body=None, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'index'") + __path = f"/_ilm/move/{_quote(index)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if current_step is not None: + __body["current_step"] = current_step + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if next_step is not None: + __body["next_step"] = next_step + if pretty is not None: + __query["pretty"] = pretty + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, + ) + def put_lifecycle( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + policy: Optional[Any] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Creates a lifecycle policy - ``_ + ``_ - :arg policy: The name of the index lifecycle policy - :arg body: The lifecycle policy definition to register + :param name: The name of the index lifecycle policy + :param policy: """ - client, params = _deprecated_options(self, params) - if policy in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'policy'.") - - return client._perform_request( - "PUT", - _make_path("_ilm", "policy", policy), - params=params, - headers=headers, - body=body, - ) - - @query_params() - def remove_policy(self, index, params=None, headers=None): + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_ilm/policy/{_quote(name)}" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if policy is not None: + __body["policy"] = policy + if pretty is not None: + __query["pretty"] = pretty + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("PUT", __target, headers=__headers, body=__body) + + @_rewrite_parameters() + def remove_policy( + self, + *, + index: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Removes the assigned lifecycle policy and stops managing the specified index - ``_ + ``_ - :arg index: The name of the index to remove policy on + :param index: The name of the index to remove policy on """ - client, params = _deprecated_options(self, params) if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return client._perform_request( - "POST", _make_path(index, "_ilm", "remove"), params=params, headers=headers - ) - - @query_params() - def retry(self, index, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'index'") + __path = f"/{_quote(index)}/_ilm/remove" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters() + def retry( + self, + *, + index: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ 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 + :param index: The name of the indices (comma-separated) whose failed lifecycle + step is to be retry """ - client, params = _deprecated_options(self, params) if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return client._perform_request( - "POST", _make_path(index, "_ilm", "retry"), params=params, headers=headers - ) - - @query_params() - def start(self, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'index'") + __path = f"/{_quote(index)}/_ilm/retry" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters() + def start( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ Start the index lifecycle management (ILM) plugin. - ``_ - """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "POST", "/_ilm/start", params=params, headers=headers - ) - - @query_params() - def stop(self, params=None, headers=None): - """ - Halts all lifecycle management operations and stops the index lifecycle - management (ILM) plugin + ``_ - ``_ + :param master_timeout: + :param timeout: """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "POST", "/_ilm/stop", params=params, headers=headers - ) - - @query_params("dry_run") - def migrate_to_data_tiers(self, body=None, params=None, headers=None): + __path = "/_ilm/start" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters() + def stop( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ - Migrates the indices and ILM policies away from custom node attribute - allocation routing to data tiers routing + Halts all lifecycle management operations and stops the index lifecycle management + (ILM) plugin - ``_ + ``_ - :arg body: Optionally specify a legacy index template name to - delete and optionally specify a node attribute name used for index shard - routing (defaults to "data") - :arg dry_run: If set to true it will simulate the migration, - providing a way to retrieve the ILM policies and indices that need to be - migrated. The default is false + :param master_timeout: + :param timeout: """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "POST", - "/_ilm/migrate_to_data_tiers", - params=params, - headers=headers, - body=body, - ) + __path = "/_ilm/stop" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) diff --git a/elasticsearch/_sync/client/ilm.pyi b/elasticsearch/_sync/client/ilm.pyi deleted file mode 100644 index eaac92274..000000000 --- a/elasticsearch/_sync/client/ilm.pyi +++ /dev/null @@ -1,213 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class IlmClient(NamespacedClient): - def delete_lifecycle( - self, - policy: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def explain_lifecycle( - self, - index: Any, - *, - only_errors: Optional[Any] = ..., - only_managed: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_lifecycle( - self, - *, - policy: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_status( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def move_to_step( - self, - index: Any, - *, - body: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def put_lifecycle( - self, - policy: Any, - *, - body: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def remove_policy( - self, - index: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def retry( - self, - index: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def start( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def stop( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def migrate_to_data_tiers( - self, - *, - body: Optional[Any] = ..., - dry_run: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_sync/client/indices.py b/elasticsearch/_sync/client/indices.py index d9f2b00e7..1f3a14ce1 100644 --- a/elasticsearch/_sync/client/indices.py +++ b/elasticsearch/_sync/client/indices.py @@ -15,1609 +15,3317 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params +from .utils import SKIP_IN_PATH, _quote, _quote_query, _rewrite_parameters class IndicesClient(NamespacedClient): - @query_params() - def analyze(self, body=None, index=None, params=None, headers=None): + @_rewrite_parameters() + def add_block( + self, + *, + index: Any, + block: Any, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ - Performs the analysis process on a text and return the tokens breakdown of the - text. - - ``_ + Adds a block to an index. - :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 - """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "POST", - _make_path(index, "_analyze"), - params=params, - headers=headers, - body=body, - ) + ``_ - @query_params("allow_no_indices", "expand_wildcards", "ignore_unavailable") - def refresh(self, index=None, params=None, headers=None): + :param index: A comma separated list of indices to add a block to + :param block: The block to add (one of read, write, read_only or metadata) + :param 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) + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param master_timeout: Specify timeout for connection to master + :param timeout: Explicit operation timeout """ - 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 - :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) - """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "POST", _make_path(index, "_refresh"), params=params, headers=headers - ) - - @query_params( - "allow_no_indices", - "expand_wildcards", - "force", - "ignore_unavailable", - "wait_if_ongoing", + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + if block in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'block'") + __path = f"/{_quote(index)}/_block/{_quote(block)}" + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("PUT", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, ) - def flush(self, index=None, params=None, headers=None): + def analyze( + self, + *, + index: Optional[Any] = None, + analyzer: Optional[str] = None, + attributes: Optional[List[str]] = None, + char_filter: Optional[List[Union[Any, str]]] = None, + error_trace: Optional[bool] = None, + explain: Optional[bool] = None, + field: Optional[Any] = None, + filter: Optional[List[Union[Any, str]]] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + normalizer: Optional[str] = None, + pretty: Optional[bool] = None, + text: Optional[Any] = None, + tokenizer: Optional[Union[Any, str]] = None, + ) -> Any: """ - 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 - :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 force: Whether a flush should be forced even if it is not - necessarily needed ie. if no changes will be committed to the index. - This is useful if transaction log IDs should be incremented even if no - uncommitted changes are present. (This setting can be considered as - internal) - :arg ignore_unavailable: Whether specified concrete indices - should be ignored when unavailable (missing or closed) - :arg wait_if_ongoing: If set to true the flush operation will - block until the flush can be executed if another flush operation is - already executing. The default is true. If set to false the flush will - be skipped iff if another flush operation is already running. - """ - client, params = _deprecated_options(self, params) - return client._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): - """ - Creates an index with optional settings and mappings. + Performs the analysis process on a text and return the tokens breakdown of the + text. - ``_ + ``_ - :arg index: The name of the index - :arg body: The configuration for the index (`settings` and - `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 before the operation returns. + :param index: The name of the index to scope the operation + :param analyzer: + :param attributes: + :param char_filter: + :param explain: + :param field: + :param filter: + :param normalizer: + :param text: + :param tokenizer: + """ + if index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_analyze" + else: + __path = "/_analyze" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if analyzer is not None: + __body["analyzer"] = analyzer + if attributes is not None: + __body["attributes"] = attributes + if char_filter is not None: + __body["char_filter"] = char_filter + if error_trace is not None: + __query["error_trace"] = error_trace + if explain is not None: + __body["explain"] = explain + if field is not None: + __body["field"] = field + if filter is not None: + __body["filter"] = filter + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if normalizer is not None: + __body["normalizer"] = normalizer + if pretty is not None: + __query["pretty"] = pretty + if text is not None: + __body["text"] = text + if tokenizer is not None: + __body["tokenizer"] = tokenizer + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters() + def clear_cache( + self, + *, + index: Optional[Any] = None, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + fielddata: Optional[bool] = None, + fields: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + pretty: Optional[bool] = None, + query: Optional[bool] = None, + request: Optional[bool] = None, + ) -> Any: """ - client, params = _deprecated_options(self, params) - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") + Clears all or specific caches for one or more indices. - return client._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): + :param index: A comma-separated list of index name to limit the operation + :param 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) + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param fielddata: Clear field data + :param fields: A comma-separated list of fields to clear when using the `fielddata` + parameter (default: all) + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param query: Clear query caches + :param request: Clear request cache + """ + if index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_cache/clear" + else: + __path = "/_cache/clear" + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if fielddata is not None: + __query["fielddata"] = fielddata + if fields is not None: + __query["fields"] = fields + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if pretty is not None: + __query["pretty"] = pretty + if query is not None: + __query["query"] = query + if request is not None: + __query["request"] = request + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + def clone( + self, + *, + index: Any, + target: Any, + aliases: Optional[Dict[Any, Any]] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + settings: Optional[Dict[str, Any]] = None, + timeout: Optional[Any] = None, + wait_for_active_shards: Optional[Any] = None, + ) -> Any: """ Clones an index ``_ - :arg index: The name of the source index to clone - :arg target: The name of the target index to clone 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 cloned index before the operation returns. - """ - client, params = _deprecated_options(self, params) - for param in (index, target): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "PUT", - _make_path(index, "_clone", target), - params=params, - headers=headers, - body=body, - ) - - @query_params( - "allow_no_indices", - "expand_wildcards", - "flat_settings", - "ignore_unavailable", - "include_defaults", - "local", - "master_timeout", - ) - def get(self, index, params=None, headers=None): + :param index: The name of the source index to clone + :param target: The name of the target index to clone into + :param aliases: + :param master_timeout: Specify timeout for connection to master + :param settings: + :param timeout: Explicit operation timeout + :param wait_for_active_shards: Set the number of active shards to wait for on + the cloned index before the operation returns. """ - 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 - to no concrete indices (default: false) - :arg expand_wildcards: Whether wildcard expressions should get - expanded to open or closed indices (default: open) Valid choices: open, - closed, hidden, none, all Default: open - :arg flat_settings: Return settings in flat format (default: - false) - :arg ignore_unavailable: Ignore unavailable indexes (default: - false) - :arg include_defaults: Whether to return all default setting for - each of the indices. - :arg local: Return local information, do not retrieve the state - from master node (default: false) - :arg master_timeout: Specify timeout for connection to master - """ - client, params = _deprecated_options(self, params) - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return client._perform_request( - "GET", _make_path(index), params=params, headers=headers - ) - - @query_params( - "allow_no_indices", - "expand_wildcards", - "ignore_unavailable", - "master_timeout", - "timeout", - "wait_for_active_shards", - ) - 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 - 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. - """ - client, params = _deprecated_options(self, params) if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return client._perform_request( - "POST", _make_path(index, "_open"), params=params, headers=headers - ) - - @query_params( - "allow_no_indices", - "expand_wildcards", - "ignore_unavailable", - "master_timeout", - "timeout", - "wait_for_active_shards", - ) - def close(self, index, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'index'") + if target in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'target'") + __path = f"/{_quote(index)}/_clone/{_quote(target)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if aliases is not None: + __body["aliases"] = aliases + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if settings is not None: + __body["settings"] = settings + if timeout is not None: + __query["timeout"] = timeout + if wait_for_active_shards is not None: + __query["wait_for_active_shards"] = wait_for_active_shards + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("PUT", __target, headers=__headers, body=__body) + + @_rewrite_parameters() + def close( + self, + *, + index: Any, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + wait_for_active_shards: Optional[Any] = None, + ) -> Any: """ Closes an index. ``_ - :arg index: A comma separated list of indices to close - :arg allow_no_indices: Whether to ignore if a wildcard indices - expression resolves into no concrete indices. (This includes `_all` - string or when no indices have been specified) - :arg expand_wildcards: Whether to expand wildcard expression to - concrete indices that are open, closed or both. Valid choices: open, - closed, hidden, none, all Default: open - :arg ignore_unavailable: Whether specified concrete indices - should be ignored when unavailable (missing or closed) - :arg master_timeout: Specify timeout for connection to master - :arg timeout: Explicit operation timeout - :arg wait_for_active_shards: Sets the number of active shards to - wait for before the operation returns. - """ - client, params = _deprecated_options(self, params) - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return client._perform_request( - "POST", _make_path(index, "_close"), params=params, headers=headers - ) - - @query_params( - "allow_no_indices", - "expand_wildcards", - "ignore_unavailable", - "master_timeout", - "timeout", - ) - def delete(self, index, params=None, headers=None): + :param index: A comma separated list of indices to close + :param 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) + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param master_timeout: Specify timeout for connection to master + :param timeout: Explicit operation timeout + :param wait_for_active_shards: Sets the number of active shards to wait for before + the operation returns. """ - Deletes an index. - - ``_ - - :arg index: A comma-separated list of indices to delete; use - `_all` or `*` string to delete all indices - :arg allow_no_indices: Ignore if a wildcard expression resolves - to no concrete indices (default: false) - :arg expand_wildcards: Whether wildcard expressions should get - expanded to open, closed, or hidden indices Valid choices: open, - closed, hidden, none, all Default: open,closed - :arg ignore_unavailable: Ignore unavailable indexes (default: - false) - :arg master_timeout: Specify timeout for connection to master - :arg timeout: Explicit operation timeout - """ - client, params = _deprecated_options(self, params) if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return client._perform_request( - "DELETE", _make_path(index), params=params, headers=headers - ) - - @query_params( - "allow_no_indices", - "expand_wildcards", - "flat_settings", - "ignore_unavailable", - "include_defaults", - "local", - ) - 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 - to no concrete indices (default: false) - :arg expand_wildcards: Whether wildcard expressions should get - expanded to open or closed indices (default: open) Valid choices: open, - closed, hidden, none, all Default: open - :arg flat_settings: Return settings in flat format (default: - false) - :arg ignore_unavailable: Ignore unavailable indexes (default: - false) - :arg include_defaults: Whether to return all default setting for - each of the indices. - :arg local: Return local information, do not retrieve the state - from master node (default: false) - """ - client, params = _deprecated_options(self, params) - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return client._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): - """ - 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 - :arg doc_type: A comma-separated list of document types to check - :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 local: Return local information, do not retrieve the state - from master node (default: false) - """ - client, params = _deprecated_options(self, params) - for param in (index, doc_type): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "HEAD", - _make_path(index, "_mapping", doc_type), - params=params, - headers=headers, - ) - - @query_params( - "allow_no_indices", - "expand_wildcards", - "ignore_unavailable", - "master_timeout", - "timeout", - "write_index_only", + raise ValueError("Empty value passed for parameter 'index'") + __path = f"/{_quote(index)}/_close" + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if wait_for_active_shards is not None: + __query["wait_for_active_shards"] = wait_for_active_shards + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, ) - def put_mapping(self, index, body, params=None, headers=None): + def create( + self, + *, + index: Any, + aliases: Optional[Dict[Any, Any]] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + include_type_name: Optional[bool] = None, + mappings: Optional[Any] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + settings: Optional[Any] = None, + timeout: Optional[Any] = None, + wait_for_active_shards: Optional[Any] = None, + ) -> Any: """ - Updates the index mappings. + Creates an index with optional settings and mappings. - ``_ + ``_ - :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 allow_no_indices: Whether to ignore if a wildcard indices - expression resolves into no concrete indices. (This includes `_all` - string or when no indices have been specified) - :arg expand_wildcards: Whether to expand wildcard expression to - concrete indices that are open, closed or both. Valid choices: open, - closed, hidden, none, all Default: open - :arg ignore_unavailable: Whether specified concrete indices - should be ignored when unavailable (missing or closed) - :arg master_timeout: Specify timeout for connection to master - :arg timeout: Explicit operation timeout - :arg write_index_only: When true, applies mappings only to the - write index of an alias or data stream - """ - client, params = _deprecated_options(self, params) - for param in (index, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "PUT", - _make_path(index, "_mapping"), - params=params, - headers=headers, - body=body, - ) - - @query_params( - "allow_no_indices", - "expand_wildcards", - "ignore_unavailable", - "local", - "master_timeout", - ) - def get_mapping(self, index=None, params=None, headers=None): + :param index: The name of the index + :param aliases: + :param include_type_name: + :param mappings: Mapping for fields in the index. If specified, this mapping + can include: - Field names - Field data types - Mapping parameters + :param master_timeout: Specify timeout for connection to master + :param settings: + :param timeout: Explicit operation timeout + :param wait_for_active_shards: Set the number of active shards to wait for before + the operation returns. """ - Returns mappings for one or more indices. - - ``_ - - :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 local: Return local information, do not retrieve the state - from master node (default: false) - :arg master_timeout: Specify timeout for connection to master - """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", _make_path(index, "_mapping"), params=params, headers=headers - ) - - @query_params("master_timeout", "timeout") - def put_alias(self, index, name, body=None, params=None, headers=None): + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + __path = f"/{_quote(index)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if aliases is not None: + __body["aliases"] = aliases + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if include_type_name is not None: + __query["include_type_name"] = include_type_name + if mappings is not None: + __body["mappings"] = mappings + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if settings is not None: + __body["settings"] = settings + if timeout is not None: + __query["timeout"] = timeout + if wait_for_active_shards is not None: + __query["wait_for_active_shards"] = wait_for_active_shards + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("PUT", __target, headers=__headers, body=__body) + + @_rewrite_parameters() + def create_data_stream( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Creates or updates an alias. + Creates a data stream - ``_ + ``_ - :arg index: A comma-separated list of index names the alias - should point to (supports wildcards); use `_all` to perform the - operation on all indices. - :arg name: The name of the alias to be created or updated - :arg body: The settings for the alias, such as `routing` or - `filter` - :arg master_timeout: Specify timeout for connection to master - :arg timeout: Explicit timestamp for the document - """ - client, params = _deprecated_options(self, params) - for param in (index, name): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "PUT", - _make_path(index, "_alias", name), - params=params, - headers=headers, - body=body, - ) - - @query_params("allow_no_indices", "expand_wildcards", "ignore_unavailable", "local") - def exists_alias(self, name, index=None, params=None, headers=None): + :param name: The name of the data stream """ - 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 - aliases - :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: all - :arg ignore_unavailable: Whether specified concrete indices - should be ignored when unavailable (missing or closed) - :arg local: Return local information, do not retrieve the state - from master node (default: false) - """ - client, params = _deprecated_options(self, params) if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'name'.") - - return client._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): + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_data_stream/{_quote(name)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("PUT", __target, headers=__headers) + + @_rewrite_parameters() + def data_streams_stats( + self, + *, + name: Optional[Any] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Returns an alias. + Provides statistics on operations happening in a data stream. - ``_ + ``_ - :arg index: A comma-separated list of index names to filter - aliases - :arg name: A comma-separated list of alias names to return - :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: all - :arg ignore_unavailable: Whether specified concrete indices - should be ignored when unavailable (missing or closed) - :arg local: Return local information, do not retrieve the state - from master node (default: false) - """ - client, params = _deprecated_options(self, params) - return client._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): + :param name: A comma-separated list of data stream names; use `_all` or empty + string to perform the operation on all data streams + :param expand_wildcards: + """ + if name not in SKIP_IN_PATH: + __path = f"/_data_stream/{_quote(name)}/_stats" + else: + __path = "/_data_stream/_stats" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def delete( + self, + *, + index: Any, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ - Updates index aliases. + Deletes an index. - ``_ + ``_ - :arg body: The definition of `actions` to perform - :arg master_timeout: Specify timeout for connection to master - :arg timeout: Request timeout + :param index: A comma-separated list of indices to delete; use `_all` or `*` + string to delete all indices + :param allow_no_indices: Ignore if a wildcard expression resolves to no concrete + indices (default: false) + :param expand_wildcards: Whether wildcard expressions should get expanded to + open, closed, or hidden indices + :param ignore_unavailable: Ignore unavailable indexes (default: false) + :param master_timeout: Specify timeout for connection to master + :param timeout: Explicit operation timeout """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return client._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): + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + __path = f"/{_quote(index)}" + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + def delete_alias( + self, + *, + index: Any, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ Deletes an alias. ``_ - :arg index: A comma-separated list of index names (supports - wildcards); use `_all` for all indices - :arg name: A comma-separated list of aliases to delete (supports - wildcards); use `_all` to delete all aliases for the specified indices. - :arg master_timeout: Specify timeout for connection to master - :arg timeout: Explicit timestamp for the document + :param index: A comma-separated list of index names (supports wildcards); use + `_all` for all indices + :param name: A comma-separated list of aliases to delete (supports wildcards); + use `_all` to delete all aliases for the specified indices. + :param master_timeout: Specify timeout for connection to master + :param timeout: Explicit timestamp for the document """ - client, params = _deprecated_options(self, params) - for param in (index, name): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._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): - """ - 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 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 - numbers) - """ - client, params = _deprecated_options(self, params) - for param in (name, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "PUT", - _make_path("_template", name), - params=params, - headers=headers, - body=body, - ) - - @query_params("flat_settings", "local", "master_timeout") - def exists_template(self, name, params=None, headers=None): + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/{_quote(index)}/_alias/{_quote(name)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + def delete_data_stream( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Returns information about whether a particular index template exists. + Deletes a data stream. - ``_ + ``_ - :arg name: The comma separated names of the index templates - :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 + :param name: A comma-separated list of data streams to delete; use `*` to delete + all data streams + :param expand_wildcards: Whether wildcard expressions should get expanded to + open or closed indices (default: open) """ - client, params = _deprecated_options(self, params) if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'name'.") - - return client._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): + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_data_stream/{_quote(name)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + def delete_index_template( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Returns an index template. + Deletes an index template. ``_ - :arg name: The comma separated names of the index templates - :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 + :param name: The name of the template """ - client, params = _deprecated_options(self, params) - return client._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): + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_index_template/{_quote(name)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + def delete_template( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ Deletes an index template. ``_ - :arg name: The name of the template - :arg master_timeout: Specify timeout for connection to master - :arg timeout: Explicit operation timeout + :param name: The name of the template + :param master_timeout: Specify timeout for connection to master + :param timeout: Explicit operation timeout """ - client, params = _deprecated_options(self, params) if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'name'.") - - return client._perform_request( - "DELETE", _make_path("_template", name), params=params, headers=headers - ) - - @query_params( - "allow_no_indices", - "expand_wildcards", - "flat_settings", - "ignore_unavailable", - "include_defaults", - "local", - "master_timeout", - ) - def get_settings(self, index=None, name=None, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_template/{_quote(name)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + def disk_usage( + self, + *, + index: Any, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + flush: Optional[bool] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + run_expensive_tasks: Optional[bool] = None, + timeout: Optional[Any] = None, + wait_for_active_shards: Optional[str] = None, + ) -> Any: """ - Returns settings for one or more indices. + Analyzes the disk usage of each field of an index or data stream - ``_ + ``_ - :arg index: A comma-separated list of index names; use `_all` or - empty string to perform the operation on all indices - :arg name: The name of the settings that should be included - :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: all - :arg flat_settings: Return settings in flat format (default: - false) - :arg ignore_unavailable: Whether specified concrete indices - should be ignored when unavailable (missing or closed) - :arg include_defaults: Whether to return all default setting for - each of the indices. - :arg local: Return local information, do not retrieve the state - from master node (default: false) - :arg master_timeout: Specify timeout for connection to master - """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", _make_path(index, "_settings", name), params=params, headers=headers - ) - - @query_params( - "allow_no_indices", - "expand_wildcards", - "flat_settings", - "ignore_unavailable", - "master_timeout", - "preserve_existing", - "timeout", - ) - def put_settings(self, body, index=None, params=None, headers=None): + :param index: Comma-separated list of data streams, indices, and aliases used + to limit the request. It’s recommended to execute this API with a single + index (or the latest backing index of a data stream) as the API consumes + resources significantly. + :param allow_no_indices: If false, the request returns an error if any wildcard + expression, index alias, or _all value targets only missing or closed indices. + This behavior applies even if the request targets other open indices. For + example, a request targeting foo*,bar* returns an error if an index starts + with foo but no index starts with bar. + :param expand_wildcards: Type of index that wildcard patterns can match. If the + request can target data streams, this argument determines whether wildcard + expressions match hidden data streams. Supports comma-separated values, such + as open,hidden. + :param flush: If true, the API performs a flush before analysis. If false, the + response may not include uncommitted data. + :param ignore_unavailable: If true, missing or closed indices are not included + in the response. + :param master_timeout: Period to wait for a connection to the master node. If + no response is received before the timeout expires, the request fails and + returns an error. + :param run_expensive_tasks: Analyzing field disk usage is resource-intensive. + To use the API, this parameter must be set to true. + :param timeout: Period to wait for a response. If no response is received before + the timeout expires, the request fails and returns an error. + :param wait_for_active_shards: The number of shard copies that must be active + before proceeding with the operation. Set to all or any positive integer + up to the total number of shards in the index (number_of_replicas+1). Default: + 1, the primary shard. """ - Updates the index settings. + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + __path = f"/{_quote(index)}/_disk_usage" + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if flush is not None: + __query["flush"] = flush + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if run_expensive_tasks is not None: + __query["run_expensive_tasks"] = run_expensive_tasks + if timeout is not None: + __query["timeout"] = timeout + if wait_for_active_shards is not None: + __query["wait_for_active_shards"] = wait_for_active_shards + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters() + def exists( + self, + *, + index: Any, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + flat_settings: Optional[bool] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + include_defaults: Optional[bool] = None, + local: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: + """ + Returns information about whether a particular index exists. - ``_ + ``_ - :arg body: The index settings to be updated - :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 flat_settings: Return settings in flat format (default: - false) - :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 preserve_existing: Whether to update existing settings. If - set to `true` existing settings on an index remain unchanged, the - default is `false` - :arg timeout: Explicit operation timeout - """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return client._perform_request( - "PUT", - _make_path(index, "_settings"), - params=params, - headers=headers, - body=body, - ) - - @query_params( - "completion_fields", - "expand_wildcards", - "fielddata_fields", - "fields", - "forbid_closed_indices", - "groups", - "include_segment_file_sizes", - "include_unloaded_segments", - "level", - "types", - ) - def stats(self, index=None, metric=None, params=None, headers=None): + :param index: A comma-separated list of index names + :param allow_no_indices: Ignore if a wildcard expression resolves to no concrete + indices (default: false) + :param expand_wildcards: Whether wildcard expressions should get expanded to + open or closed indices (default: open) + :param flat_settings: Return settings in flat format (default: false) + :param ignore_unavailable: Ignore unavailable indexes (default: false) + :param include_defaults: Whether to return all default setting for each of the + indices. + :param local: Return local information, do not retrieve the state from master + node (default: false) """ - Provides statistics on operations happening in an index. + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + __path = f"/{_quote(index)}" + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if flat_settings is not None: + __query["flat_settings"] = flat_settings + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if include_defaults is not None: + __query["include_defaults"] = include_defaults + if local is not None: + __query["local"] = local + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("HEAD", __target, headers=__headers) + + @_rewrite_parameters() + def exists_alias( + self, + *, + name: Any, + index: Optional[Any] = None, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + local: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: + """ + Returns information about whether a particular alias exists. - ``_ + ``_ - :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, bulk - :arg completion_fields: A comma-separated list of fields for the - `completion` index metric (supports wildcards) - :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_fields: A comma-separated list of fields for the - `fielddata` index metric (supports wildcards) - :arg fields: A comma-separated list of fields for `fielddata` - and `completion` index metric (supports wildcards) - :arg forbid_closed_indices: If set to false stats will also - collected from closed indices if explicitly specified or if - expand_wildcards expands to closed indices Default: True - :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 include_unloaded_segments: If set to true segment stats - will include stats for segments that are not currently loaded into - memory - :arg level: Return stats aggregated at cluster, index or shard - level Valid choices: cluster, indices, shards Default: indices - :arg types: A comma-separated list of document types for the - `indexing` index metric - """ - client, params = _deprecated_options(self, params) - return client._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): + :param name: A comma-separated list of alias names to return + :param index: A comma-separated list of index names to filter aliases + :param 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) + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param local: Return local information, do not retrieve the state from master + node (default: false) """ - Provides low-level information about segments in a Lucene index. + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + if index not in SKIP_IN_PATH and name not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_alias/{_quote(name)}" + elif name not in SKIP_IN_PATH: + __path = f"/_alias/{_quote(name)}" + else: + raise ValueError("Couldn't find a path for the given parameters") + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if local is not None: + __query["local"] = local + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("HEAD", __target, headers=__headers) + + @_rewrite_parameters() + def exists_index_template( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + ) -> Any: + """ + Returns information about whether a particular index template exists. - ``_ + ``_ - :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 verbose: Includes detailed memory usage by Lucene. - """ - client, params = _deprecated_options(self, params) - return client._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): + :param name: Comma-separated list of index template names used to limit the request. + Wildcard (*) expressions are supported. + :param master_timeout: Period to wait for a connection to the master node. If + no response is received before the timeout expires, the request fails and + returns an error. """ - Clears all or specific caches for one or more indices. + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_index_template/{_quote(name)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("HEAD", __target, headers=__headers) + + @_rewrite_parameters() + def exists_template( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + flat_settings: Optional[bool] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + ) -> Any: + """ + Returns information about whether a particular index template exists. - ``_ + ``_ - :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 - """ - client, params = _deprecated_options(self, params) - return client._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): + :param name: The comma separated names of the index templates + :param flat_settings: Return settings in flat format (default: false) + :param local: Return local information, do not retrieve the state from master + node (default: false) + :param master_timeout: Explicit operation timeout for connection to master node """ - Returns information about ongoing index shard recoveries. + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_template/{_quote(name)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if flat_settings is not None: + __query["flat_settings"] = flat_settings + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("HEAD", __target, headers=__headers) + + @_rewrite_parameters() + def exists_type( + self, + *, + index: Any, + type: Any, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + local: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: + """ + Returns information about whether a particular document type exists. (DEPRECATED) - ``_ + ``_ - :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 + :param index: A comma-separated list of index names; use `_all` to check the + types across all indices + :param type: A comma-separated list of document types to check + :param 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) + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param local: Return local information, do not retrieve the state from master + node (default: false) """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", _make_path(index, "_recovery"), params=params, headers=headers - ) - - @query_params( - "allow_no_indices", "expand_wildcards", "ignore_unavailable", "status" - ) - def shard_stores(self, index=None, params=None, headers=None): + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + if type in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'type'") + __path = f"/{_quote(index)}/_mapping/{_quote(type)}" + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if local is not None: + __query["local"] = local + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("HEAD", __target, headers=__headers) + + @_rewrite_parameters() + def flush( + self, + *, + index: Optional[Any] = None, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + force: Optional[bool] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + pretty: Optional[bool] = None, + wait_if_ongoing: Optional[bool] = None, + ) -> Any: """ - Provides store information for shard copies of indices. + Performs the flush 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 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 - """ - client, params = _deprecated_options(self, params) - return client._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): + :param index: A comma-separated list of index names; use `_all` or empty string + for all indices + :param 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) + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param force: Whether a flush should be forced even if it is not necessarily + needed ie. if no changes will be committed to the index. This is useful if + transaction log IDs should be incremented even if no uncommitted changes + are present. (This setting can be considered as internal) + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param wait_if_ongoing: If set to true the flush operation will block until the + flush can be executed if another flush operation is already executing. The + default is true. If set to false the flush will be skipped iff if another + flush operation is already running. + """ + if index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_flush" + else: + __path = "/_flush" + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if force is not None: + __query["force"] = force + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if pretty is not None: + __query["pretty"] = pretty + if wait_if_ongoing is not None: + __query["wait_if_ongoing"] = wait_if_ongoing + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters() + def forcemerge( + self, + *, + index: Optional[Any] = None, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + flush: Optional[bool] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + max_num_segments: Optional[int] = None, + only_expunge_deletes: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ 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 - """ - client, params = _deprecated_options(self, params) - return client._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. - """ - client, params = _deprecated_options(self, params) - for param in (index, target): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._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. - """ - client, params = _deprecated_options(self, params) - for param in (index, target): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._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): + :param index: A comma-separated list of index names; use `_all` or empty string + to perform the operation on all indices + :param 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) + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param flush: Specify whether the index should be flushed after performing the + operation (default: true) + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param max_num_segments: The number of segments the index should be merged into + (default: dynamic) + :param only_expunge_deletes: Specify whether the operation should only expunge + deleted documents + """ + if index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_forcemerge" + else: + __path = "/_forcemerge" + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if flush is not None: + __query["flush"] = flush + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if max_num_segments is not None: + __query["max_num_segments"] = max_num_segments + if only_expunge_deletes is not None: + __query["only_expunge_deletes"] = only_expunge_deletes + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters() + def get( + self, + *, + index: Any, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + flat_settings: Optional[bool] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + include_defaults: Optional[bool] = None, + include_type_name: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Updates an alias to point to a new index when the existing index is considered - to be too large or too old. + Returns information about one or more indices. - ``_ + ``_ - :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. - """ - client, params = _deprecated_options(self, params) - if alias in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'alias'.") - - return client._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 unfreeze(self, index, params=None, headers=None): + :param index: Comma-separated list of data streams, indices, and index aliases + used to limit the request. Wildcard expressions (*) are supported. + :param allow_no_indices: Ignore if a wildcard expression resolves to no concrete + indices (default: false) + :param expand_wildcards: Type of index that wildcard expressions can match. If + the request can target data streams, this argument determines whether wildcard + expressions match hidden data streams. Supports comma-separated values, such + as open,hidden. + :param flat_settings: If true, returns settings in flat format. + :param ignore_unavailable: If false, requests that target a missing index return + an error. + :param include_defaults: If true, return all default settings in the response. + :param include_type_name: If true, a mapping type is expected in the body of + mappings. + :param local: If true, the request retrieves information from the local node + only. Defaults to false, which means information is retrieved from the master + node. + :param master_timeout: Period to wait for a connection to the master node. If + no response is received before the timeout expires, the request fails and + returns an error. """ - 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. - """ - client, params = _deprecated_options(self, params) if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") + raise ValueError("Empty value passed for parameter 'index'") + __path = f"/{_quote(index)}" + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if flat_settings is not None: + __query["flat_settings"] = flat_settings + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if include_defaults is not None: + __query["include_defaults"] = include_defaults + if include_type_name is not None: + __query["include_type_name"] = include_type_name + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def get_alias( + self, + *, + index: Optional[Any] = None, + name: Optional[Any] = None, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + local: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: + """ + Returns an alias. - return client._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): + :param index: A comma-separated list of index names to filter aliases + :param name: A comma-separated list of alias names to return + :param 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) + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param local: Return local information, do not retrieve the state from master + node (default: false) + """ + if index not in SKIP_IN_PATH and name not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_alias/{_quote(name)}" + elif index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_alias" + elif name not in SKIP_IN_PATH: + __path = f"/_alias/{_quote(name)}" + else: + __path = "/_alias" + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if local is not None: + __query["local"] = local + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def get_data_stream( + self, + *, + name: Optional[Any] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Reloads an index's search analyzers and their resources. + Returns data streams. - ``_ + ``_ - :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) - """ - client, params = _deprecated_options(self, params) - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return client._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): + :param name: A comma-separated list of data streams to get; use `*` to get all + data streams + :param expand_wildcards: Whether wildcard expressions should get expanded to + open or closed indices (default: open) + """ + if name not in SKIP_IN_PATH: + __path = f"/_data_stream/{_quote(name)}" + else: + __path = "/_data_stream" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def get_field_mapping( + self, + *, + fields: Any, + index: Optional[Any] = None, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + include_defaults: Optional[bool] = None, + include_type_name: Optional[bool] = None, + local: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ 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) - """ - client, params = _deprecated_options(self, params) + :param fields: A comma-separated list of fields + :param index: A comma-separated list of index names + :param 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) + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param include_defaults: Whether the default mapping values should be returned + as well + :param include_type_name: + :param 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 client._perform_request( - "GET", - _make_path(index, "_mapping", "field", fields), - params=params, - headers=headers, - ) - - @query_params( - "all_shards", - "allow_no_indices", - "analyze_wildcard", - "analyzer", - "default_operator", - "df", - "expand_wildcards", - "explain", - "ignore_unavailable", - "lenient", - "q", - "rewrite", - ) - def validate_query( - self, body=None, index=None, doc_type=None, params=None, headers=None - ): + raise ValueError("Empty value passed for parameter 'fields'") + if index not in SKIP_IN_PATH and fields not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_mapping/field/{_quote(fields)}" + elif fields not in SKIP_IN_PATH: + __path = f"/_mapping/field/{_quote(fields)}" + else: + raise ValueError("Couldn't find a path for the given parameters") + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if include_defaults is not None: + __query["include_defaults"] = include_defaults + if include_type_name is not None: + __query["include_type_name"] = include_type_name + if local is not None: + __query["local"] = local + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def get_index_template( + self, + *, + name: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + flat_settings: Optional[bool] = None, + human: Optional[bool] = None, + include_type_name: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Allows a user to validate a potentially expensive query without executing it. + Returns an index template. - ``_ + ``_ - :arg body: The query definition specified with the Query DSL - :arg index: A comma-separated list of index names to restrict - the operation; use `_all` or empty string to perform the operation on - all indices - :arg doc_type: A comma-separated list of document types to - restrict the operation; leave empty to perform the operation on all - types - :arg all_shards: Execute validation on all shards instead of one - random shard per index - :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 analyze_wildcard: Specify whether wildcard and prefix - queries should be analyzed (default: false) - :arg analyzer: The analyzer to use for the query string - :arg default_operator: The default operator for query string - query (AND or OR) Valid choices: AND, OR Default: OR - :arg df: The field to use as default where no field prefix is - given in the query string - :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: Return detailed information about the error - :arg ignore_unavailable: Whether specified concrete indices - should be ignored when unavailable (missing or closed) - :arg lenient: Specify whether format-based query failures (such - as providing text to a numeric field) should be ignored - :arg q: Query in the Lucene query string syntax - :arg rewrite: Provide a more detailed explanation showing the - actual Lucene query that will be executed. - """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "POST", - _make_path(index, doc_type, "_validate", "query"), - params=params, - headers=headers, - body=body, - ) - - @query_params() - def create_data_stream(self, name, params=None, headers=None): + :param name: Comma-separated list of index template names used to limit the request. + Wildcard (*) expressions are supported. + :param flat_settings: If true, returns settings in flat format. + :param include_type_name: If true, a mapping type is expected in the body of + mappings. + :param local: If true, the request retrieves information from the local node + only. Defaults to false, which means information is retrieved from the master + node. + :param master_timeout: Period to wait for a connection to the master node. If + no response is received before the timeout expires, the request fails and + returns an error. + """ + if name not in SKIP_IN_PATH: + __path = f"/_index_template/{_quote(name)}" + else: + __path = "/_index_template" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if flat_settings is not None: + __query["flat_settings"] = flat_settings + if human is not None: + __query["human"] = human + if include_type_name is not None: + __query["include_type_name"] = include_type_name + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def get_mapping( + self, + *, + index: Optional[Any] = None, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + include_type_name: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Creates a data stream + Returns mappings for one or more indices. - ``_ + ``_ - :arg name: The name of the data stream + :param index: A comma-separated list of index names + :param 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) + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param include_type_name: + :param local: Return local information, do not retrieve the state from master + node (default: false) + :param master_timeout: Specify timeout for connection to master + """ + if index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_mapping" + else: + __path = "/_mapping" + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if include_type_name is not None: + __query["include_type_name"] = include_type_name + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def get_settings( + self, + *, + index: Optional[Any] = None, + name: Optional[Any] = None, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + flat_settings: Optional[bool] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + include_defaults: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - client, params = _deprecated_options(self, params) - if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'name'.") + Returns settings for one or more indices. - return client._perform_request( - "PUT", _make_path("_data_stream", name), params=params, headers=headers - ) + ``_ - @query_params("expand_wildcards") - def delete_data_stream(self, name, params=None, headers=None): + :param index: A comma-separated list of index names; use `_all` or empty string + to perform the operation on all indices + :param name: The name of the settings that should be included + :param 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) + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param flat_settings: Return settings in flat format (default: false) + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param include_defaults: Whether to return all default setting for each of the + indices. + :param local: Return local information, do not retrieve the state from master + node (default: false) + :param master_timeout: Specify timeout for connection to master + """ + if index not in SKIP_IN_PATH and name not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_settings/{_quote(name)}" + elif index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_settings" + elif name not in SKIP_IN_PATH: + __path = f"/_settings/{_quote(name)}" + else: + __path = "/_settings" + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if flat_settings is not None: + __query["flat_settings"] = flat_settings + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if include_defaults is not None: + __query["include_defaults"] = include_defaults + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def get_template( + self, + *, + name: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + flat_settings: Optional[bool] = None, + human: Optional[bool] = None, + include_type_name: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Deletes a data stream. + Returns an index template. + + ``_ + + :param name: The comma separated names of the index templates + :param flat_settings: Return settings in flat format (default: false) + :param include_type_name: + :param local: Return local information, do not retrieve the state from master + node (default: false) + :param master_timeout: Explicit operation timeout for connection to master node + """ + if name not in SKIP_IN_PATH: + __path = f"/_template/{_quote(name)}" + else: + __path = "/_template" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if flat_settings is not None: + __query["flat_settings"] = flat_settings + if human is not None: + __query["human"] = human + if include_type_name is not None: + __query["include_type_name"] = include_type_name + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def migrate_to_data_stream( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: + """ + Migrates an alias to a data stream ``_ - :arg name: A comma-separated list of data streams to delete; use - `*` to delete all data streams - :arg expand_wildcards: Whether wildcard expressions should get - expanded to open or closed indices (default: open) Valid choices: open, - closed, hidden, none, all Default: open + :param name: The name of the alias to migrate """ - client, params = _deprecated_options(self, params) if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'name'.") + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_data_stream/_migrate/{_quote(name)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters() + def open( + self, + *, + index: Any, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + wait_for_active_shards: Optional[Any] = None, + ) -> Any: + """ + Opens an index. - return client._perform_request( - "DELETE", _make_path("_data_stream", name), params=params, headers=headers - ) + ``_ - @query_params("master_timeout", "timeout") - def delete_index_template(self, name, params=None, headers=None): + :param index: A comma separated list of indices to open + :param 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) + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param master_timeout: Specify timeout for connection to master + :param timeout: Explicit operation timeout + :param wait_for_active_shards: Sets the number of active shards to wait for before + the operation returns. """ - Deletes an index template. + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + __path = f"/{_quote(index)}/_open" + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if wait_for_active_shards is not None: + __query["wait_for_active_shards"] = wait_for_active_shards + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters() + def promote_data_stream( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: + """ + Promotes a data stream from a replicated data stream managed by CCR to a regular + data stream - ``_ + ``_ - :arg name: The name of the template - :arg master_timeout: Specify timeout for connection to master - :arg timeout: Explicit operation timeout + :param name: The name of the data stream """ - client, params = _deprecated_options(self, params) if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'name'.") - - return client._perform_request( - "DELETE", - _make_path("_index_template", name), - params=params, - headers=headers, - ) - - @query_params("flat_settings", "local", "master_timeout") - def get_index_template(self, name=None, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_data_stream/_promote/{_quote(name)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + def put_alias( + self, + *, + index: Any, + name: Any, + error_trace: Optional[bool] = None, + filter: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + index_routing: Optional[Any] = None, + is_write_index: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + routing: Optional[Any] = None, + search_routing: Optional[Any] = None, + timeout: Optional[Any] = None, + ) -> Any: """ - Returns an index template. + Creates or updates an alias. - ``_ + ``_ - :arg name: A pattern that returned template names must match - :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 + :param index: A comma-separated list of index names the alias should point to + (supports wildcards); use `_all` to perform the operation on all indices. + :param name: The name of the alias to be created or updated + :param filter: + :param index_routing: + :param is_write_index: + :param master_timeout: Specify timeout for connection to master + :param routing: + :param search_routing: + :param timeout: Explicit timestamp for the document """ - client, params = _deprecated_options(self, params) - return client._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): + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/{_quote(index)}/_alias/{_quote(name)}" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter is not None: + __body["filter"] = filter + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if index_routing is not None: + __body["index_routing"] = index_routing + if is_write_index is not None: + __body["is_write_index"] = is_write_index + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if routing is not None: + __body["routing"] = routing + if search_routing is not None: + __body["search_routing"] = search_routing + if timeout is not None: + __query["timeout"] = timeout + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("PUT", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, + parameter_aliases={"_meta": "meta"}, + ) + def put_index_template( + self, + *, + name: Any, + composed_of: Optional[List[Any]] = None, + data_stream: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + index_patterns: Optional[Any] = None, + meta: Optional[Any] = None, + pretty: Optional[bool] = None, + priority: Optional[int] = None, + template: Optional[Any] = None, + version: Optional[Any] = None, + ) -> Any: """ Creates or updates an index template. ``_ - :arg name: The name of the template - :arg body: The template definition - :arg cause: User defined reason for creating/updating the index - template - :arg create: Whether the index template should only be added if - new or can also replace an existing one - :arg master_timeout: Specify timeout for connection to master - """ - client, params = _deprecated_options(self, params) - for param in (name, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "PUT", - _make_path("_index_template", name), - params=params, - headers=headers, - body=body, - ) - - @query_params("flat_settings", "local", "master_timeout") - def exists_index_template(self, name, params=None, headers=None): + :param name: Index or template name + :param composed_of: + :param data_stream: + :param index_patterns: + :param meta: + :param priority: + :param template: + :param version: """ - Returns information about whether a particular index template exists. + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_index_template/{_quote(name)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if composed_of is not None: + __body["composed_of"] = composed_of + if data_stream is not None: + __body["data_stream"] = data_stream + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if index_patterns is not None: + __body["index_patterns"] = index_patterns + if meta is not None: + __body["_meta"] = meta + if pretty is not None: + __query["pretty"] = pretty + if priority is not None: + __body["priority"] = priority + if template is not None: + __body["template"] = template + if version is not None: + __body["version"] = version + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("PUT", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, + parameter_aliases={ + "_field_names": "field_names", + "_meta": "meta", + "_routing": "routing", + "_source": "source", + }, + ) + def put_mapping( + self, + *, + index: Any, + allow_no_indices: Optional[bool] = None, + date_detection: Optional[bool] = None, + dynamic: Optional[Union[Any, bool]] = None, + dynamic_date_formats: Optional[List[str]] = None, + dynamic_templates: Optional[Union[Dict[str, Any], List[Dict[str, Any]]]] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + field_names: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + include_type_name: Optional[bool] = None, + master_timeout: Optional[Any] = None, + meta: Optional[Dict[str, Any]] = None, + numeric_detection: Optional[bool] = None, + pretty: Optional[bool] = None, + properties: Optional[Dict[Any, Any]] = None, + routing: Optional[Any] = None, + runtime: Optional[Any] = None, + source: Optional[Any] = None, + timeout: Optional[Any] = None, + write_index_only: Optional[bool] = None, + ) -> Any: + """ + Updates the index mappings. - ``_ + ``_ - :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 + :param 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. + :param 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) + :param date_detection: Controls whether dynamic date detection is enabled. + :param dynamic: Controls whether new fields are added dynamically. + :param dynamic_date_formats: If date detection is enabled then new string fields + are checked against 'dynamic_date_formats' and if the value matches then + a new date field is added instead of string. + :param dynamic_templates: Specify dynamic templates for the mapping. + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param field_names: Control whether field names are enabled for the index. + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param include_type_name: + :param master_timeout: Specify timeout for connection to master + :param meta: A mapping type can have custom meta data associated with it. These + are not used at all by Elasticsearch, but can be used to store application-specific + metadata. + :param numeric_detection: Automatically map strings into numeric data types for + all fields. + :param properties: Mapping for a field. For new fields, this mapping can include: + - Field name - Field data type - Mapping parameters + :param routing: Enable making a routing value required on indexed documents. + :param runtime: Mapping of runtime fields for the index. + :param source: Control whether the _source field is enabled on the index. + :param timeout: Explicit operation timeout + :param write_index_only: When true, applies mappings only to the write index + of an alias or data stream """ - client, params = _deprecated_options(self, params) - if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'name'.") + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + __path = f"/{_quote(index)}/_mapping" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if date_detection is not None: + __body["date_detection"] = date_detection + if dynamic is not None: + __body["dynamic"] = dynamic + if dynamic_date_formats is not None: + __body["dynamic_date_formats"] = dynamic_date_formats + if dynamic_templates is not None: + __body["dynamic_templates"] = dynamic_templates + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if field_names is not None: + __body["_field_names"] = field_names + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if include_type_name is not None: + __query["include_type_name"] = include_type_name + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if meta is not None: + __body["_meta"] = meta + if numeric_detection is not None: + __body["numeric_detection"] = numeric_detection + if pretty is not None: + __query["pretty"] = pretty + if properties is not None: + __body["properties"] = properties + if routing is not None: + __body["_routing"] = routing + if runtime is not None: + __body["runtime"] = runtime + if source is not None: + __body["_source"] = source + if timeout is not None: + __query["timeout"] = timeout + if write_index_only is not None: + __query["write_index_only"] = write_index_only + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("PUT", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_name="settings", + ) + def put_settings( + self, + *, + settings: Any, + index: Optional[Any] = None, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + flat_settings: Optional[bool] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + master_timeout: Optional[Any] = None, + preserve_existing: Optional[bool] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: + """ + Updates the index settings. - return client._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): + :param settings: + :param index: A comma-separated list of index names; use `_all` or empty string + to perform the operation on all indices + :param 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) + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param flat_settings: Return settings in flat format (default: false) + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param master_timeout: Specify timeout for connection to master + :param preserve_existing: Whether to update existing settings. If set to `true` + existing settings on an index remain unchanged, the default is `false` + :param timeout: Explicit operation timeout + """ + if settings is None: + raise ValueError("Empty value passed for parameter 'settings'") + if index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_settings" + else: + __path = "/_settings" + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if flat_settings is not None: + __query["flat_settings"] = flat_settings + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if preserve_existing is not None: + __query["preserve_existing"] = preserve_existing + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + __body = settings + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("PUT", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, + ) + def put_template( + self, + *, + name: Any, + aliases: Optional[Dict[Any, Any]] = None, + create: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + flat_settings: Optional[bool] = None, + human: Optional[bool] = None, + include_type_name: Optional[bool] = None, + index_patterns: Optional[Union[List[str], str]] = None, + mappings: Optional[Any] = None, + master_timeout: Optional[Any] = None, + order: Optional[int] = None, + pretty: Optional[bool] = None, + settings: Optional[Dict[str, Any]] = None, + timeout: Optional[Any] = None, + version: Optional[Any] = None, + ) -> Any: """ - Simulate matching the given index name against the index templates in the - system + Creates or updates an index template. ``_ - :arg name: The name of the index (it must be a concrete index - name) - :arg body: New index template definition, which will be included - in the simulation, as if it already exists in the system - :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 - """ - client, params = _deprecated_options(self, params) + :param name: The name of the template + :param aliases: Aliases for the index. + :param create: If true, this request cannot replace or update existing index + templates. + :param flat_settings: + :param include_type_name: + :param index_patterns: Array of wildcard expressions used to match the names + of indices during creation. + :param mappings: Mapping for fields in the index. + :param master_timeout: Period to wait for a connection to the master node. If + no response is received before the timeout expires, the request fails and + returns an error. + :param order: Order in which Elasticsearch applies this template if index matches + multiple templates. Templates with lower 'order' values are merged first. + Templates with higher 'order' values are merged later, overriding templates + with lower values. + :param settings: Configuration options for the index. + :param timeout: + :param version: Version number used to manage index templates externally. This + number is not automatically generated by Elasticsearch. + """ if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'name'.") - - return client._perform_request( - "POST", - _make_path("_index_template", "_simulate_index", name), - params=params, - headers=headers, - body=body, - ) - - @query_params("expand_wildcards") - def get_data_stream(self, name=None, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_template/{_quote(name)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if aliases is not None: + __body["aliases"] = aliases + if create is not None: + __query["create"] = create + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if flat_settings is not None: + __query["flat_settings"] = flat_settings + if human is not None: + __query["human"] = human + if include_type_name is not None: + __query["include_type_name"] = include_type_name + if index_patterns is not None: + __body["index_patterns"] = index_patterns + if mappings is not None: + __body["mappings"] = mappings + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if order is not None: + __body["order"] = order + if pretty is not None: + __query["pretty"] = pretty + if settings is not None: + __body["settings"] = settings + if timeout is not None: + __query["timeout"] = timeout + if version is not None: + __body["version"] = version + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("PUT", __target, headers=__headers, body=__body) + + @_rewrite_parameters() + def recovery( + self, + *, + index: Optional[Any] = None, + active_only: Optional[bool] = None, + detailed: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Returns data streams. + Returns information about ongoing index shard recoveries. - ``_ + ``_ - :arg name: A comma-separated list of data streams to get; use - `*` to get all data streams - :arg expand_wildcards: Whether wildcard expressions should get - expanded to open or closed indices (default: open) Valid choices: open, - closed, hidden, none, all Default: open + :param index: A comma-separated list of index names; use `_all` or empty string + to perform the operation on all indices + :param active_only: Display only those recoveries that are currently on-going + :param detailed: Whether to display detailed information about shard recovery + """ + if index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_recovery" + else: + __path = "/_recovery" + __query: Dict[str, Any] = {} + if active_only is not None: + __query["active_only"] = active_only + if detailed is not None: + __query["detailed"] = detailed + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def refresh( + self, + *, + index: Optional[Any] = None, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", _make_path("_data_stream", name), params=params, headers=headers - ) + Performs the refresh operation in one or more indices. - @query_params("cause", "create", "master_timeout") - def simulate_template(self, body=None, name=None, params=None, headers=None): + ``_ + + :param index: A comma-separated list of index names; use `_all` or empty string + to perform the operation on all indices + :param 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) + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + """ + if index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_refresh" + else: + __path = "/_refresh" + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters() + def reload_search_analyzers( + self, + *, + index: Any, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Simulate resolving the given template name or body + Reloads an index's search analyzers and their resources. - ``_ + ``_ - :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 - """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "POST", - _make_path("_index_template", "_simulate", name), - params=params, - headers=headers, - body=body, - ) - - @query_params("expand_wildcards") - def resolve_index(self, name, params=None, headers=None): + :param index: A comma-separated list of index names to reload analyzers for + :param 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) + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param 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 parameter 'index'") + __path = f"/{_quote(index)}/_reload_search_analyzers" + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters() + def resolve_index( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Returns information about any matching indices, aliases, and data streams ``_ - :arg name: A comma-separated list of names or wildcard - expressions - :arg expand_wildcards: Whether wildcard expressions should get - expanded to open or closed indices (default: open) Valid choices: open, - closed, hidden, none, all Default: open + :param name: A comma-separated list of names or wildcard expressions + :param expand_wildcards: Whether wildcard expressions should get expanded to + open or closed indices (default: open) """ - client, params = _deprecated_options(self, params) if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'name'.") - - return client._perform_request( - "GET", _make_path("_resolve", "index", name), params=params, headers=headers - ) - - @query_params( - "allow_no_indices", - "expand_wildcards", - "ignore_unavailable", - "master_timeout", - "timeout", + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_resolve/index/{_quote(name)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, ) - def add_block(self, index, block, params=None, headers=None): + def rollover( + self, + *, + alias: Any, + new_index: Optional[Any] = None, + aliases: Optional[Dict[Any, Any]] = None, + conditions: Optional[Any] = None, + dry_run: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + include_type_name: Optional[bool] = None, + mappings: Optional[Union[Any, Dict[str, Any]]] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + settings: Optional[Dict[str, Any]] = None, + timeout: Optional[Any] = None, + wait_for_active_shards: Optional[Any] = None, + ) -> Any: """ - Adds a block to an index. + Updates an alias to point to a new index when the existing index is considered + to be too large or too old. - ``_ + ``_ - :arg index: A comma separated list of indices to add a block to - :arg block: The block to add (one of read, write, read_only or - metadata) - :arg allow_no_indices: Whether to ignore if a wildcard indices - expression resolves into no concrete indices. (This includes `_all` - string or when no indices have been specified) - :arg expand_wildcards: Whether to expand wildcard expression to - concrete indices that are open, closed or both. Valid choices: open, - closed, hidden, none, all Default: open - :arg ignore_unavailable: Whether specified concrete indices - should be ignored when unavailable (missing or closed) - :arg master_timeout: Specify timeout for connection to master - :arg timeout: Explicit operation timeout - """ - client, params = _deprecated_options(self, params) - for param in (index, block): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "PUT", _make_path(index, "_block", block), params=params, headers=headers - ) - - @query_params() - def data_streams_stats(self, name=None, params=None, headers=None): + :param alias: The name of the alias to rollover + :param new_index: The name of the rollover index + :param aliases: + :param conditions: + :param 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 + :param include_type_name: + :param mappings: + :param master_timeout: Specify timeout for connection to master + :param settings: + :param timeout: Explicit operation timeout + :param wait_for_active_shards: Set the number of active shards to wait for on + the newly created rollover index before the operation returns. """ - Provides statistics on operations happening in a data stream. - - ``_ - - :arg name: A comma-separated list of data stream names; use - `_all` or empty string to perform the operation on all data streams + if alias in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'alias'") + if alias not in SKIP_IN_PATH and new_index not in SKIP_IN_PATH: + __path = f"/{_quote(alias)}/_rollover/{_quote(new_index)}" + elif alias not in SKIP_IN_PATH: + __path = f"/{_quote(alias)}/_rollover" + else: + raise ValueError("Couldn't find a path for the given parameters") + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if aliases is not None: + __body["aliases"] = aliases + if conditions is not None: + __body["conditions"] = conditions + if dry_run is not None: + __query["dry_run"] = dry_run + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if include_type_name is not None: + __query["include_type_name"] = include_type_name + if mappings is not None: + __body["mappings"] = mappings + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if settings is not None: + __body["settings"] = settings + if timeout is not None: + __query["timeout"] = timeout + if wait_for_active_shards is not None: + __query["wait_for_active_shards"] = wait_for_active_shards + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters() + def segments( + self, + *, + index: Optional[Any] = None, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + pretty: Optional[bool] = None, + verbose: Optional[bool] = None, + ) -> Any: """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", - _make_path("_data_stream", name, "_stats"), - params=params, - headers=headers, - ) + Provides low-level information about segments in a Lucene index. - @query_params() - def migrate_to_data_stream(self, name, params=None, headers=None): + ``_ + + :param index: A comma-separated list of index names; use `_all` or empty string + to perform the operation on all indices + :param 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) + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param verbose: Includes detailed memory usage by Lucene. + """ + if index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_segments" + else: + __path = "/_segments" + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if pretty is not None: + __query["pretty"] = pretty + if verbose is not None: + __query["verbose"] = verbose + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def shard_stores( + self, + *, + index: Optional[Any] = None, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + pretty: Optional[bool] = None, + status: Optional[Union[Any, List[Any]]] = None, + ) -> Any: """ - Migrates an alias to a data stream + Provides store information for shard copies of indices. - ``_ + ``_ - :arg name: The name of the alias to migrate + :param index: List of data streams, indices, and aliases used to limit the request. + :param allow_no_indices: If false, the request returns an error if any wildcard + expression, index alias, or _all value targets only missing or closed indices. + This behavior applies even if the request targets other open indices. + :param expand_wildcards: Type of index that wildcard patterns can match. If the + request can target data streams, this argument determines whether wildcard + expressions match hidden data streams. + :param ignore_unavailable: If true, missing or closed indices are not included + in the response. + :param status: List of shard health statuses used to limit the request. + """ + if index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_shard_stores" + else: + __path = "/_shard_stores" + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if pretty is not None: + __query["pretty"] = pretty + if status is not None: + __query["status"] = status + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + def shrink( + self, + *, + index: Any, + target: Any, + aliases: Optional[Dict[Any, Any]] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + settings: Optional[Dict[str, Any]] = None, + timeout: Optional[Any] = None, + wait_for_active_shards: Optional[Any] = None, + ) -> Any: """ - client, params = _deprecated_options(self, params) - if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'name'.") + Allow to shrink an existing index into a new index with fewer primary shards. - return client._perform_request( - "POST", - _make_path("_data_stream", "_migrate", name), - params=params, - headers=headers, - ) + ``_ - @query_params() - def promote_data_stream(self, name, params=None, headers=None): + :param index: The name of the source index to shrink + :param target: The name of the target index to shrink into + :param aliases: + :param master_timeout: Specify timeout for connection to master + :param settings: + :param timeout: Explicit operation timeout + :param wait_for_active_shards: Set the number of active shards to wait for on + the shrunken index before the operation returns. """ - Promotes a data stream from a replicated data stream managed by CCR to a - regular data stream + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + if target in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'target'") + __path = f"/{_quote(index)}/_shrink/{_quote(target)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if aliases is not None: + __body["aliases"] = aliases + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if settings is not None: + __body["settings"] = settings + if timeout is not None: + __query["timeout"] = timeout + if wait_for_active_shards is not None: + __query["wait_for_active_shards"] = wait_for_active_shards + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("PUT", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, + ) + def simulate_index_template( + self, + *, + name: Any, + composed_of: Optional[List[Any]] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + index_patterns: Optional[List[Any]] = None, + overlapping: Optional[List[Any]] = None, + pretty: Optional[bool] = None, + template: Optional[Any] = None, + ) -> Any: + """ + Simulate matching the given index name against the index templates in the system - ``_ + ``_ - :arg name: The name of the data stream + :param name: Index or template name to simulate + :param composed_of: + :param index_patterns: + :param overlapping: Any overlapping templates that would have matched, but have + lower priority + :param template: """ - client, params = _deprecated_options(self, params) if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'name'.") - - return client._perform_request( - "POST", - _make_path("_data_stream", "_promote", name), - params=params, - headers=headers, - ) - - @query_params( - "allow_no_indices", - "expand_wildcards", - "flush", - "ignore_unavailable", - "run_expensive_tasks", + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_index_template/_simulate_index/{_quote(name)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if composed_of is not None: + __body["composed_of"] = composed_of + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if index_patterns is not None: + __body["index_patterns"] = index_patterns + if overlapping is not None: + __body["overlapping"] = overlapping + if pretty is not None: + __query["pretty"] = pretty + if template is not None: + __body["template"] = template + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_name="template", ) - def disk_usage(self, index, params=None, headers=None): + def simulate_template( + self, + *, + template: Any, + name: Optional[Any] = None, + create: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Analyzes the disk usage of each field of an index or data stream + Simulate resolving the given template name or body - ``_ + ``_ - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - - :arg index: Comma-separated list of indices or data streams to - analyze the disk usage - :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: Whether flush or not before analyzing the index disk - usage. Defaults to true - :arg ignore_unavailable: Whether specified concrete indices - should be ignored when unavailable (missing or closed) - :arg run_expensive_tasks: Must be set to [true] in order for the - task to be performed. Defaults to false. - """ - client, params = _deprecated_options(self, params) - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") + :param template: + :param name: Name of the index template to simulate. To test a template configuration + before you add it to the cluster, omit this parameter and specify the template + configuration in the request body. + :param create: If true, the template passed in the body is only used if no existing + templates match the same index patterns. If false, the simulation uses the + template with the highest priority. Note that the template is not permanently + added or updated in either case; it is only used for the simulation. + :param master_timeout: Period to wait for a connection to the master node. If + no response is received before the timeout expires, the request fails and + returns an error. + """ + if template is None: + raise ValueError("Empty value passed for parameter 'template'") + if name not in SKIP_IN_PATH: + __path = f"/_index_template/_simulate/{_quote(name)}" + else: + __path = "/_index_template/_simulate" + __query: Dict[str, Any] = {} + if create is not None: + __query["create"] = create + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + __body = template + if not __body: + __body = None + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, + ) + def split( + self, + *, + index: Any, + target: Any, + aliases: Optional[Dict[Any, Any]] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + settings: Optional[Dict[str, Any]] = None, + timeout: Optional[Any] = None, + wait_for_active_shards: Optional[Any] = None, + ) -> Any: + """ + Allows you to split an existing index into a new index with more primary shards. - return client._perform_request( - "POST", _make_path(index, "_disk_usage"), params=params, headers=headers - ) + ``_ - @query_params( - "allow_no_indices", "expand_wildcards", "fields", "ignore_unavailable" - ) - def field_usage_stats(self, index, params=None, headers=None): + :param index: The name of the source index to split + :param target: The name of the target index to split into + :param aliases: + :param master_timeout: Specify timeout for connection to master + :param settings: + :param timeout: Explicit operation timeout + :param wait_for_active_shards: Set the number of active shards to wait for on + the shrunken index before the operation returns. """ - Returns the field usage stats for each field of an index - - ``_ + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + if target in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'target'") + __path = f"/{_quote(index)}/_split/{_quote(target)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if aliases is not None: + __body["aliases"] = aliases + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if settings is not None: + __body["settings"] = settings + if timeout is not None: + __query["timeout"] = timeout + if wait_for_active_shards is not None: + __query["wait_for_active_shards"] = wait_for_active_shards + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("PUT", __target, headers=__headers, body=__body) + + @_rewrite_parameters() + def stats( + self, + *, + index: Optional[Any] = None, + metric: Optional[Any] = None, + completion_fields: Optional[Any] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + fielddata_fields: Optional[Any] = None, + fields: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + forbid_closed_indices: Optional[bool] = None, + groups: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + include_segment_file_sizes: Optional[bool] = None, + include_unloaded_segments: Optional[bool] = None, + level: Optional[Any] = None, + pretty: Optional[bool] = None, + types: Optional[Any] = None, + ) -> Any: + """ + Provides statistics on operations happening in an index. - .. warning:: + ``_ - This API is **experimental** so may include breaking changes - or be removed in a future version + :param index: A comma-separated list of index names; use `_all` or empty string + to perform the operation on all indices + :param metric: Limit the information returned the specific metrics. + :param completion_fields: A comma-separated list of fields for the `completion` + index metric (supports wildcards) + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param fielddata_fields: A comma-separated list of fields for the `fielddata` + index metric (supports wildcards) + :param fields: A comma-separated list of fields for `fielddata` and `completion` + index metric (supports wildcards) + :param forbid_closed_indices: If set to false stats will also collected from + closed indices if explicitly specified or if expand_wildcards expands to + closed indices + :param groups: A comma-separated list of search groups for `search` index metric + :param 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) + :param include_unloaded_segments: If set to true segment stats will include stats + for segments that are not currently loaded into memory + :param level: Return stats aggregated at cluster, index or shard level + :param types: A comma-separated list of document types for the `indexing` index + metric + """ + if index not in SKIP_IN_PATH and metric not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_stats/{_quote(metric)}" + elif index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_stats" + elif metric not in SKIP_IN_PATH: + __path = f"/_stats/{_quote(metric)}" + else: + __path = "/_stats" + __query: Dict[str, Any] = {} + if completion_fields is not None: + __query["completion_fields"] = completion_fields + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if fielddata_fields is not None: + __query["fielddata_fields"] = fielddata_fields + if fields is not None: + __query["fields"] = fields + if filter_path is not None: + __query["filter_path"] = filter_path + if forbid_closed_indices is not None: + __query["forbid_closed_indices"] = forbid_closed_indices + if groups is not None: + __query["groups"] = groups + if human is not None: + __query["human"] = human + if include_segment_file_sizes is not None: + __query["include_segment_file_sizes"] = include_segment_file_sizes + if include_unloaded_segments is not None: + __query["include_unloaded_segments"] = include_unloaded_segments + if level is not None: + __query["level"] = level + if pretty is not None: + __query["pretty"] = pretty + if types is not None: + __query["types"] = types + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def unfreeze( + self, + *, + index: Any, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + wait_for_active_shards: Optional[str] = None, + ) -> Any: + """ + Unfreezes an index. When a frozen index is unfrozen, the index goes through the + normal recovery process and becomes writeable again. - :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 fields: A comma-separated list of fields to include in the - stats if only a subset of fields should be returned (supports wildcards) - :arg ignore_unavailable: Whether specified concrete indices - should be ignored when unavailable (missing or closed) + ``_ + + :param index: The name of the index to unfreeze + :param 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) + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param master_timeout: Specify timeout for connection to master + :param timeout: Explicit operation timeout + :param wait_for_active_shards: Sets the number of active shards to wait for before + the operation returns. """ - client, params = _deprecated_options(self, params) if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return client._perform_request( - "GET", - _make_path(index, "_field_usage_stats"), - params=params, - headers=headers, - ) - - @query_params() - def modify_data_stream(self, body, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'index'") + __path = f"/{_quote(index)}/_unfreeze" + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if wait_for_active_shards is not None: + __query["wait_for_active_shards"] = wait_for_active_shards + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + def update_aliases( + self, + *, + actions: Optional[List[Any]] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ - Modifies a data stream + Updates index aliases. - ``_ + ``_ - :arg body: The data stream modifications + :param actions: + :param master_timeout: Specify timeout for connection to master + :param timeout: Request timeout + """ + __path = "/_aliases" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if actions is not None: + __body["actions"] = actions + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, + ) + def validate_query( + self, + *, + index: Optional[Any] = None, + type: Optional[Any] = None, + all_shards: Optional[bool] = None, + allow_no_indices: Optional[bool] = None, + analyze_wildcard: Optional[bool] = None, + analyzer: Optional[str] = None, + default_operator: Optional[Any] = None, + df: Optional[str] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + explain: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + lenient: Optional[bool] = None, + pretty: Optional[bool] = None, + q: Optional[str] = None, + query: Optional[Any] = None, + rewrite: Optional[bool] = None, + ) -> Any: """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") + Allows a user to validate a potentially expensive query without executing it. + + ``_ - return client._perform_request( - "POST", "/_data_stream/_modify", params=params, headers=headers, body=body - ) + :param index: A comma-separated list of index names to restrict the operation; + use `_all` or empty string to perform the operation on all indices + :param type: A comma-separated list of document types to restrict the operation; + leave empty to perform the operation on all types + :param all_shards: Execute validation on all shards instead of one random shard + per index + :param 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) + :param analyze_wildcard: Specify whether wildcard and prefix queries should be + analyzed (default: false) + :param analyzer: The analyzer to use for the query string + :param default_operator: The default operator for query string query (AND or + OR) + :param df: The field to use as default where no field prefix is given in the + query string + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param explain: Return detailed information about the error + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) + :param lenient: Specify whether format-based query failures (such as providing + text to a numeric field) should be ignored + :param q: Query in the Lucene query string syntax + :param query: + :param rewrite: Provide a more detailed explanation showing the actual Lucene + query that will be executed. + """ + if index not in SKIP_IN_PATH and type not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/{_quote(type)}/_validate/query" + elif index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_validate/query" + else: + __path = "/_validate/query" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if all_shards is not None: + __query["all_shards"] = all_shards + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if analyze_wildcard is not None: + __query["analyze_wildcard"] = analyze_wildcard + if analyzer is not None: + __query["analyzer"] = analyzer + if default_operator is not None: + __query["default_operator"] = default_operator + if df is not None: + __query["df"] = df + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if explain is not None: + __query["explain"] = explain + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if lenient is not None: + __query["lenient"] = lenient + if pretty is not None: + __query["pretty"] = pretty + if q is not None: + __query["q"] = q + if query is not None: + __body["query"] = query + if rewrite is not None: + __query["rewrite"] = rewrite + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("POST", __target, headers=__headers, body=__body) diff --git a/elasticsearch/_sync/client/indices.pyi b/elasticsearch/_sync/client/indices.pyi deleted file mode 100644 index be945f0af..000000000 --- a/elasticsearch/_sync/client/indices.pyi +++ /dev/null @@ -1,1171 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import HeadApiResponse, ObjectApiResponse - -from ._base import NamespacedClient - -class IndicesClient(NamespacedClient): - def analyze( - self, - *, - body: Optional[Any] = ..., - index: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def refresh( - self, - *, - index: Optional[Any] = ..., - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def flush( - self, - *, - index: Optional[Any] = ..., - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - force: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - wait_if_ongoing: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def create( - self, - index: Any, - *, - body: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - wait_for_active_shards: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def clone( - self, - index: Any, - target: Any, - *, - body: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - wait_for_active_shards: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get( - self, - index: Any, - *, - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - flat_settings: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - include_defaults: Optional[Any] = ..., - local: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def open( - self, - index: Any, - *, - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - wait_for_active_shards: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def close( - self, - index: Any, - *, - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - wait_for_active_shards: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def delete( - self, - index: Any, - *, - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def exists( - self, - index: Any, - *, - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - flat_settings: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - include_defaults: Optional[Any] = ..., - local: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> HeadApiResponse: ... - def exists_type( - self, - index: Any, - doc_type: Any, - *, - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - local: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> HeadApiResponse: ... - def put_mapping( - self, - index: Any, - *, - body: Any, - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - write_index_only: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_mapping( - self, - *, - index: Optional[Any] = ..., - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - local: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def put_alias( - self, - index: Any, - name: Any, - *, - body: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def exists_alias( - self, - name: Any, - *, - index: Optional[Any] = ..., - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - local: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> HeadApiResponse: ... - def get_alias( - self, - *, - index: Optional[Any] = ..., - name: Optional[Any] = ..., - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - local: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def update_aliases( - self, - *, - body: Any, - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def delete_alias( - self, - index: Any, - name: Any, - *, - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def put_template( - self, - name: Any, - *, - body: Any, - create: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - order: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def exists_template( - self, - name: Any, - *, - flat_settings: Optional[Any] = ..., - local: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> HeadApiResponse: ... - def get_template( - self, - *, - name: Optional[Any] = ..., - flat_settings: Optional[Any] = ..., - local: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def delete_template( - self, - name: Any, - *, - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_settings( - self, - *, - index: Optional[Any] = ..., - name: Optional[Any] = ..., - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - flat_settings: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - include_defaults: Optional[Any] = ..., - local: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def put_settings( - self, - *, - body: Any, - index: Optional[Any] = ..., - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - flat_settings: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - preserve_existing: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def stats( - self, - *, - index: Optional[Any] = ..., - metric: Optional[Any] = ..., - completion_fields: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - fielddata_fields: Optional[Any] = ..., - fields: Optional[Any] = ..., - forbid_closed_indices: Optional[Any] = ..., - groups: Optional[Any] = ..., - include_segment_file_sizes: Optional[Any] = ..., - include_unloaded_segments: Optional[Any] = ..., - level: Optional[Any] = ..., - types: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def segments( - self, - *, - index: Optional[Any] = ..., - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - verbose: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def clear_cache( - self, - *, - index: Optional[Any] = ..., - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - fielddata: Optional[Any] = ..., - fields: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - query: Optional[Any] = ..., - request: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def recovery( - self, - *, - index: Optional[Any] = ..., - active_only: Optional[Any] = ..., - detailed: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def shard_stores( - self, - *, - index: Optional[Any] = ..., - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - status: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def forcemerge( - self, - *, - index: Optional[Any] = ..., - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - flush: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - max_num_segments: Optional[Any] = ..., - only_expunge_deletes: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def shrink( - self, - index: Any, - target: Any, - *, - body: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - wait_for_active_shards: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def split( - self, - index: Any, - target: Any, - *, - body: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - wait_for_active_shards: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def rollover( - self, - alias: Any, - *, - body: Optional[Any] = ..., - new_index: Optional[Any] = ..., - dry_run: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - wait_for_active_shards: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def unfreeze( - self, - index: Any, - *, - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - wait_for_active_shards: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def reload_search_analyzers( - self, - index: Any, - *, - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_field_mapping( - self, - fields: Any, - *, - index: Optional[Any] = ..., - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - include_defaults: Optional[Any] = ..., - local: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def validate_query( - self, - *, - body: Optional[Any] = ..., - index: Optional[Any] = ..., - doc_type: Optional[Any] = ..., - all_shards: Optional[Any] = ..., - allow_no_indices: Optional[Any] = ..., - analyze_wildcard: Optional[Any] = ..., - analyzer: Optional[Any] = ..., - default_operator: Optional[Any] = ..., - df: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - explain: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - lenient: Optional[Any] = ..., - q: Optional[Any] = ..., - rewrite: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def create_data_stream( - self, - name: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def delete_data_stream( - self, - name: Any, - *, - expand_wildcards: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def delete_index_template( - self, - name: Any, - *, - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_index_template( - self, - *, - name: Optional[Any] = ..., - flat_settings: Optional[Any] = ..., - local: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def put_index_template( - self, - name: Any, - *, - body: Any, - cause: Optional[Any] = ..., - create: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def exists_index_template( - self, - name: Any, - *, - flat_settings: Optional[Any] = ..., - local: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> HeadApiResponse: ... - def simulate_index_template( - self, - name: Any, - *, - body: Optional[Any] = ..., - cause: Optional[Any] = ..., - create: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_data_stream( - self, - *, - name: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def simulate_template( - self, - *, - body: Optional[Any] = ..., - name: Optional[Any] = ..., - cause: Optional[Any] = ..., - create: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def resolve_index( - self, - name: Any, - *, - expand_wildcards: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def add_block( - self, - index: Any, - block: Any, - *, - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def data_streams_stats( - self, - *, - name: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def migrate_to_data_stream( - self, - name: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def promote_data_stream( - self, - name: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def disk_usage( - self, - index: Any, - *, - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - flush: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - run_expensive_tasks: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def field_usage_stats( - self, - index: Any, - *, - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - fields: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def modify_data_stream( - self, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_sync/client/ingest.py b/elasticsearch/_sync/client/ingest.py index ca0d51449..068fd8b8f 100644 --- a/elasticsearch/_sync/client/ingest.py +++ b/elasticsearch/_sync/client/ingest.py @@ -15,125 +15,293 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params +from .utils import SKIP_IN_PATH, _quote, _quote_query, _rewrite_parameters class IngestClient(NamespacedClient): - @query_params("master_timeout", "summary") - def get_pipeline(self, id=None, params=None, headers=None): + @_rewrite_parameters() + def delete_pipeline( + self, + *, + id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ - Returns a pipeline. + Deletes a pipeline. - ``_ + ``_ - :arg id: Comma separated list of pipeline ids. Wildcards - supported - :arg master_timeout: Explicit operation timeout for connection - to master node - :arg summary: Return pipelines without their definitions - (default: false) + :param id: Pipeline ID + :param master_timeout: Explicit operation timeout for connection to master node + :param timeout: Explicit operation timeout """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", _make_path("_ingest", "pipeline", id), params=params, headers=headers - ) + if id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/_ingest/pipeline/{_quote(id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("DELETE", __target, headers=__headers) - @query_params("if_version", "master_timeout", "timeout") - def put_pipeline(self, id, body, params=None, headers=None): + @_rewrite_parameters() + def geo_ip_stats( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Creates or updates a pipeline. - - ``_ + Returns statistical information about geoip databases - :arg id: Pipeline ID - :arg body: The ingest definition - :arg if_version: Required version for optimistic concurrency - control for pipeline updates - :arg master_timeout: Explicit operation timeout for connection - to master node - :arg timeout: Explicit operation timeout - """ - client, params = _deprecated_options(self, params) - for param in (id, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "PUT", - _make_path("_ingest", "pipeline", id), - params=params, - headers=headers, - body=body, - ) - - @query_params("master_timeout", "timeout") - def delete_pipeline(self, id, params=None, headers=None): + ``_ """ - Deletes a pipeline. + __path = "/_ingest/geoip/stats" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) - ``_ - - :arg id: Pipeline ID - :arg master_timeout: Explicit operation timeout for connection - to master node - :arg timeout: Explicit operation timeout + @_rewrite_parameters() + def get_pipeline( + self, + *, + id: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + summary: Optional[bool] = None, + ) -> Any: """ - client, params = _deprecated_options(self, params) - if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'id'.") + Returns a pipeline. - return client._perform_request( - "DELETE", - _make_path("_ingest", "pipeline", id), - params=params, - headers=headers, - ) + ``_ - @query_params("verbose") - def simulate(self, body, id=None, params=None, headers=None): + :param id: Comma separated list of pipeline ids. Wildcards supported + :param master_timeout: Explicit operation timeout for connection to master node + :param summary: Return pipelines without their definitions (default: false) """ - Allows to simulate a pipeline with example documents. - - ``_ + if id not in SKIP_IN_PATH: + __path = f"/_ingest/pipeline/{_quote(id)}" + else: + __path = "/_ingest/pipeline" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if summary is not None: + __query["summary"] = summary + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) - :arg body: The simulate definition - :arg id: Pipeline ID - :arg verbose: Verbose mode. Display data output for each - processor in executed pipeline - """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return client._perform_request( - "POST", - _make_path("_ingest", "pipeline", id, "_simulate"), - params=params, - headers=headers, - body=body, - ) - - @query_params() - def processor_grok(self, params=None, headers=None): + @_rewrite_parameters() + def processor_grok( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Returns a list of the built-in patterns. ``_ """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", "/_ingest/processor/grok", params=params, headers=headers - ) + __path = "/_ingest/processor/grok" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) - @query_params() - def geo_ip_stats(self, params=None, headers=None): + @_rewrite_parameters( + body_fields=True, + parameter_aliases={"_meta": "meta"}, + ) + def put_pipeline( + self, + *, + id: Any, + description: Optional[str] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + meta: Optional[Any] = None, + on_failure: Optional[List[Any]] = None, + pretty: Optional[bool] = None, + processors: Optional[List[Any]] = None, + timeout: Optional[Any] = None, + version: Optional[Any] = None, + ) -> Any: """ - Returns statistical information about geoip databases + Creates or updates a pipeline. - ``_ + ``_ + + :param id: ID of the ingest pipeline to create or update. + :param description: Description of the ingest pipeline. + :param master_timeout: Period to wait for a connection to the master node. If + no response is received before the timeout expires, the request fails and + returns an error. + :param meta: Optional metadata about the ingest pipeline. May have any contents. + This map is not automatically generated by Elasticsearch. + :param on_failure: Processors to run immediately after a processor failure. Each + processor supports a processor-level `on_failure` value. If a processor without + an `on_failure` value fails, Elasticsearch uses this pipeline-level parameter + as a fallback. The processors in this parameter run sequentially in the order + specified. Elasticsearch will not attempt to run the pipeline's remaining + processors. + :param processors: Processors used to perform transformations on documents before + indexing. Processors run sequentially in the order specified. + :param timeout: Period to wait for a response. If no response is received before + the timeout expires, the request fails and returns an error. + :param version: Version number used by external systems to track ingest pipelines. + This parameter is intended for external systems only. Elasticsearch does + not use or validate pipeline version numbers. + """ + if id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/_ingest/pipeline/{_quote(id)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if description is not None: + __body["description"] = description + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if meta is not None: + __body["_meta"] = meta + if on_failure is not None: + __body["on_failure"] = on_failure + if pretty is not None: + __query["pretty"] = pretty + if processors is not None: + __body["processors"] = processors + if timeout is not None: + __query["timeout"] = timeout + if version is not None: + __body["version"] = version + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("PUT", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, + ) + def simulate( + self, + *, + id: Optional[Any] = None, + docs: Optional[List[Any]] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pipeline: Optional[Any] = None, + pretty: Optional[bool] = None, + verbose: Optional[bool] = None, + ) -> Any: + """ + Allows to simulate a pipeline with example documents. + + ``_ + + :param id: Pipeline ID + :param docs: + :param pipeline: + :param verbose: Verbose mode. Display data output for each processor in executed + pipeline """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", "/_ingest/geoip/stats", params=params, headers=headers - ) + if id not in SKIP_IN_PATH: + __path = f"/_ingest/pipeline/{_quote(id)}/_simulate" + else: + __path = "/_ingest/pipeline/_simulate" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if docs is not None: + __body["docs"] = docs + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pipeline is not None: + __body["pipeline"] = pipeline + if pretty is not None: + __query["pretty"] = pretty + if verbose is not None: + __query["verbose"] = verbose + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("POST", __target, headers=__headers, body=__body) diff --git a/elasticsearch/_sync/client/ingest.pyi b/elasticsearch/_sync/client/ingest.pyi deleted file mode 100644 index 0c8a67990..000000000 --- a/elasticsearch/_sync/client/ingest.pyi +++ /dev/null @@ -1,134 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class IngestClient(NamespacedClient): - def get_pipeline( - self, - *, - id: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - summary: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def put_pipeline( - self, - id: Any, - *, - body: Any, - if_version: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def delete_pipeline( - self, - id: Any, - *, - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def simulate( - self, - *, - body: Any, - id: Optional[Any] = ..., - verbose: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def processor_grok( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def geo_ip_stats( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_sync/client/license.py b/elasticsearch/_sync/client/license.py index 9c538f05b..ad0c5e1c8 100644 --- a/elasticsearch/_sync/client/license.py +++ b/elasticsearch/_sync/client/license.py @@ -15,111 +15,274 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import _deprecated_options, query_params +from .utils import _quote_query, _rewrite_parameters class LicenseClient(NamespacedClient): - @query_params() - def delete(self, params=None, headers=None): + @_rewrite_parameters() + def delete( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Deletes licensing information for the cluster ``_ """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "DELETE", "/_license", params=params, headers=headers - ) + __path = "/_license" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("DELETE", __target, headers=__headers) - @query_params("accept_enterprise", "local") - def get(self, params=None, headers=None): + @_rewrite_parameters() + def get( + self, + *, + accept_enterprise: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ 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 local: Return local information, do not retrieve the state - from master node (default: false) + :param accept_enterprise: Supported for backwards compatibility with 7.x. If + this param is used it must be set to true + :param local: Return local information, do not retrieve the state from master + node (default: false) """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", "/_license", params=params, headers=headers - ) + __path = "/_license" + __query: Dict[str, Any] = {} + if accept_enterprise is not None: + __query["accept_enterprise"] = accept_enterprise + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) - @query_params() - def get_basic_status(self, params=None, headers=None): + @_rewrite_parameters() + def get_basic_status( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Retrieves information about the status of the basic license. ``_ """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", "/_license/basic_status", params=params, headers=headers - ) + __path = "/_license/basic_status" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) - @query_params() - def get_trial_status(self, params=None, headers=None): + @_rewrite_parameters() + def get_trial_status( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Retrieves information about the status of the trial license. ``_ """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", "/_license/trial_status", params=params, headers=headers - ) + __path = "/_license/trial_status" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) - @query_params("acknowledge") - def post(self, body=None, params=None, headers=None): + @_rewrite_parameters( + body_fields=True, + ) + def post( + self, + *, + acknowledge: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + license: Optional[Any] = None, + licenses: Optional[List[Any]] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Updates the license for the cluster. ``_ - :arg body: licenses to be installed - :arg acknowledge: whether the user has acknowledged acknowledge - messages (default: false) + :param acknowledge: whether the user has acknowledged acknowledge messages (default: + false) + :param license: + :param licenses: """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "PUT", "/_license", params=params, headers=headers, body=body - ) + __path = "/_license" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if acknowledge is not None: + __query["acknowledge"] = acknowledge + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if license is not None: + __body["license"] = license + if licenses is not None: + __body["licenses"] = licenses + if pretty is not None: + __query["pretty"] = pretty + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("PUT", __target, headers=__headers, body=__body) - @query_params("acknowledge") - def post_start_basic(self, params=None, headers=None): + @_rewrite_parameters() + def post_start_basic( + self, + *, + acknowledge: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Starts an indefinite basic license. ``_ - :arg acknowledge: whether the user has acknowledged acknowledge - messages (default: false) + :param acknowledge: whether the user has acknowledged acknowledge messages (default: + false) """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "POST", "/_license/start_basic", params=params, headers=headers - ) + __path = "/_license/start_basic" + __query: Dict[str, Any] = {} + if acknowledge is not None: + __query["acknowledge"] = acknowledge + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) - @query_params("acknowledge", "doc_type") - def post_start_trial(self, params=None, headers=None): + @_rewrite_parameters() + def post_start_trial( + self, + *, + acknowledge: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + type_query_string: Optional[str] = None, + ) -> Any: """ starts a limited time trial license. ``_ - :arg acknowledge: whether the user has acknowledged acknowledge - messages (default: false) - :arg doc_type: The type of trial license to generate (default: - "trial") + :param acknowledge: whether the user has acknowledged acknowledge messages (default: + false) + :param type_query_string: """ - client, params = _deprecated_options(self, params) - if params and "doc_type" in params: - params["type"] = params.pop("doc_type") - - return client._perform_request( - "POST", "/_license/start_trial", params=params, headers=headers - ) + __path = "/_license/start_trial" + __query: Dict[str, Any] = {} + if acknowledge is not None: + __query["acknowledge"] = acknowledge + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if type_query_string is not None: + __query["type_query_string"] = type_query_string + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) diff --git a/elasticsearch/_sync/client/license.pyi b/elasticsearch/_sync/client/license.pyi deleted file mode 100644 index d2f2ea3bc..000000000 --- a/elasticsearch/_sync/client/license.pyi +++ /dev/null @@ -1,143 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class LicenseClient(NamespacedClient): - def delete( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get( - self, - *, - accept_enterprise: Optional[Any] = ..., - local: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_basic_status( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_trial_status( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def post( - self, - *, - body: Optional[Any] = ..., - acknowledge: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def post_start_basic( - self, - *, - acknowledge: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def post_start_trial( - self, - *, - acknowledge: Optional[Any] = ..., - doc_type: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_sync/client/logstash.py b/elasticsearch/_sync/client/logstash.py index 93382f522..4678ef6ac 100644 --- a/elasticsearch/_sync/client/logstash.py +++ b/elasticsearch/_sync/client/logstash.py @@ -15,70 +15,124 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params +from .utils import SKIP_IN_PATH, _quote, _quote_query, _rewrite_parameters class LogstashClient(NamespacedClient): - @query_params() - def delete_pipeline(self, id, params=None, headers=None): + @_rewrite_parameters() + def delete_pipeline( + self, + *, + id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Deletes Logstash Pipelines used by Central Management - ``_ + ``_ - :arg id: The ID of the Pipeline + :param id: The ID of the Pipeline """ - client, params = _deprecated_options(self, params) if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'id'.") - - return client._perform_request( - "DELETE", - _make_path("_logstash", "pipeline", id), - params=params, - headers=headers, - ) + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/_logstash/pipeline/{_quote(id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("DELETE", __target, headers=__headers) - @query_params() - def get_pipeline(self, id, params=None, headers=None): + @_rewrite_parameters() + def get_pipeline( + self, + *, + id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Retrieves Logstash Pipelines used by Central Management - ``_ + ``_ - :arg id: A comma-separated list of Pipeline IDs + :param id: A comma-separated list of Pipeline IDs """ - client, params = _deprecated_options(self, params) if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'id'.") - - return client._perform_request( - "GET", - _make_path("_logstash", "pipeline", id), - params=params, - headers=headers, - ) + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/_logstash/pipeline/{_quote(id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) - @query_params() - def put_pipeline(self, id, body, params=None, headers=None): + @_rewrite_parameters( + body_name="pipeline", + ) + def put_pipeline( + self, + *, + id: Any, + pipeline: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Adds and updates Logstash Pipelines used for Central Management - ``_ + ``_ - :arg id: The ID of the Pipeline - :arg body: The Pipeline to add or update + :param id: The ID of the Pipeline + :param pipeline: """ - client, params = _deprecated_options(self, params) - for param in (id, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "PUT", - _make_path("_logstash", "pipeline", id), - params=params, - headers=headers, - body=body, - ) + if id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'id'") + if pipeline is None: + raise ValueError("Empty value passed for parameter 'pipeline'") + __path = f"/_logstash/pipeline/{_quote(id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + __body = pipeline + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("PUT", __target, headers=__headers, body=__body) diff --git a/elasticsearch/_sync/client/logstash.pyi b/elasticsearch/_sync/client/logstash.pyi deleted file mode 100644 index 24b36a46e..000000000 --- a/elasticsearch/_sync/client/logstash.pyi +++ /dev/null @@ -1,76 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class LogstashClient(NamespacedClient): - def delete_pipeline( - self, - id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_pipeline( - self, - id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def put_pipeline( - self, - id: Any, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_sync/client/migration.py b/elasticsearch/_sync/client/migration.py index ebd78073b..e875ae562 100644 --- a/elasticsearch/_sync/client/migration.py +++ b/elasticsearch/_sync/client/migration.py @@ -15,50 +15,49 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import _deprecated_options, _make_path, query_params +from .utils import SKIP_IN_PATH, _quote, _quote_query, _rewrite_parameters class MigrationClient(NamespacedClient): - @query_params() - def deprecations(self, index=None, params=None, headers=None): + @_rewrite_parameters() + def deprecations( + self, + *, + index: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ 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 - """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", - _make_path(index, "_migration", "deprecations"), - params=params, - headers=headers, - ) - - @query_params() - def get_feature_upgrade_status(self, params=None, headers=None): - """ - Find out whether system features need to be upgraded or not - - ``_ - """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", "/_migration/system_features", params=params, headers=headers - ) - - @query_params() - def post_feature_upgrade(self, params=None, headers=None): - """ - Begin upgrades for system features + ``_ - ``_ + :param index: Comma-separate list of data streams or indices to check. Wildcard + (*) expressions are supported. """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "POST", "/_migration/system_features", params=params, headers=headers - ) + if index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_migration/deprecations" + else: + __path = "/_migration/deprecations" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) diff --git a/elasticsearch/_sync/client/migration.pyi b/elasticsearch/_sync/client/migration.pyi deleted file mode 100644 index c487345f6..000000000 --- a/elasticsearch/_sync/client/migration.pyi +++ /dev/null @@ -1,73 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class MigrationClient(NamespacedClient): - def deprecations( - self, - *, - index: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_feature_upgrade_status( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def post_feature_upgrade( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_sync/client/ml.py b/elasticsearch/_sync/client/ml.py index 5e1120565..b37fbd6bb 100644 --- a/elasticsearch/_sync/client/ml.py +++ b/elasticsearch/_sync/client/ml.py @@ -15,1907 +15,3846 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params +from .utils import SKIP_IN_PATH, _quote, _quote_query, _rewrite_parameters class MlClient(NamespacedClient): - @query_params("allow_no_jobs", "allow_no_match", "force", "timeout") - 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 - :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) - :arg allow_no_match: Whether to ignore if a wildcard expression - matches no jobs. (This includes `_all` string or when no jobs have been - specified) - :arg force: True if the job should be forcefully closed - :arg timeout: Controls the time to wait until a job has closed. - Default to 30 minutes - """ - client, params = _deprecated_options(self, params) + @_rewrite_parameters() + def close_job( + self, + *, + job_id: Any, + allow_no_match: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + force: Optional[bool] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: + """ + Closes one or more anomaly detection jobs. A job can be opened and closed multiple + times throughout its lifecycle. + + ``_ + + :param job_id: Identifier for the anomaly detection job. It can be a job identifier, + a group name, or a wildcard expression. You can close multiple anomaly detection + jobs in a single API request by using a group name, a comma-separated list + of jobs, or a wildcard expression. You can close all jobs by using `_all` + or by specifying `*` as the job identifier. + :param allow_no_match: Specifies what to do when the request: contains wildcard + expressions and there are no jobs that match; contains the `_all` string + or no identifiers and there are no matches; or contains wildcard expressions + and there are only partial matches. By default, it returns an empty jobs + array when there are no matches and the subset of results when there are + partial matches. If `false`, the request returns a 404 status code when there + are no matches or only partial matches. + :param force: Use to close a failed job, or to forcefully close a job which has + not responded to its initial close request; the request returns without performing + the associated actions such as flushing buffers and persisting the model + snapshots. If you want the job to be in a consistent state after the close + job API returns, do not set to `true`. This parameter should be used only + in situations where the job has already failed or where you are not interested + in results the job might have recently produced or might produce in the future. + :param timeout: Controls the time to wait until a job has closed. + """ if job_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'job_id'.") - - return client._perform_request( - "POST", - _make_path("_ml", "anomaly_detectors", job_id, "_close"), - params=params, - headers=headers, - body=body, - ) - - @query_params() - def delete_calendar(self, calendar_id, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'job_id'") + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}/_close" + __query: Dict[str, Any] = {} + if allow_no_match is not None: + __query["allow_no_match"] = allow_no_match + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if force is not None: + __query["force"] = force + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters() + def delete_calendar( + self, + *, + calendar_id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Deletes a calendar. - ``_ + ``_ - :arg calendar_id: The ID of the calendar to delete + :param calendar_id: A string that uniquely identifies a calendar. """ - client, params = _deprecated_options(self, params) if calendar_id in SKIP_IN_PATH: - raise ValueError( - "Empty value passed for a required argument 'calendar_id'." - ) - - return client._perform_request( - "DELETE", - _make_path("_ml", "calendars", calendar_id), - params=params, - headers=headers, - ) - - @query_params() - def delete_calendar_event(self, calendar_id, event_id, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'calendar_id'") + __path = f"/_ml/calendars/{_quote(calendar_id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + def delete_calendar_event( + self, + *, + calendar_id: Any, + event_id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ 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 + :param calendar_id: The ID of the calendar to modify + :param event_id: The ID of the event to remove from the calendar """ - client, params = _deprecated_options(self, params) - for param in (calendar_id, event_id): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "DELETE", - _make_path("_ml", "calendars", calendar_id, "events", event_id), - params=params, - headers=headers, - ) - - @query_params() - def delete_calendar_job(self, calendar_id, job_id, params=None, headers=None): + if calendar_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'calendar_id'") + if event_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'event_id'") + __path = f"/_ml/calendars/{_quote(calendar_id)}/events/{_quote(event_id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + def delete_calendar_job( + self, + *, + calendar_id: Any, + job_id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ 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 + :param calendar_id: A string that uniquely identifies a calendar. + :param job_id: An identifier for the anomaly detection jobs. It can be a job + identifier, a group name, or a comma-separated list of jobs or groups. """ - client, params = _deprecated_options(self, params) - for param in (calendar_id, job_id): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") + if calendar_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'calendar_id'") + if job_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'job_id'") + __path = f"/_ml/calendars/{_quote(calendar_id)}/jobs/{_quote(job_id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + def delete_data_frame_analytics( + self, + *, + id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + force: Optional[bool] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: + """ + Deletes an existing data frame analytics job. - return client._perform_request( - "DELETE", - _make_path("_ml", "calendars", calendar_id, "jobs", job_id), - params=params, - headers=headers, - ) + ``_ - @query_params("force") - def delete_datafeed(self, datafeed_id, params=None, headers=None): + :param id: Identifier for the data frame analytics job. + :param force: If `true`, it deletes a job that is not stopped; this method is + quicker than stopping and deleting the job. + :param timeout: The time to wait for the job to be deleted. + """ + if id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/_ml/data_frame/analytics/{_quote(id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if force is not None: + __query["force"] = force + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + def delete_datafeed( + self, + *, + datafeed_id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + force: Optional[bool] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Deletes an existing datafeed. - ``_ + ``_ - :arg datafeed_id: The ID of the datafeed to delete - :arg force: True if the datafeed should be forcefully deleted + :param datafeed_id: A numerical character string that uniquely identifies the + datafeed. This identifier can contain lowercase alphanumeric characters (a-z + and 0-9), hyphens, and underscores. It must start and end with alphanumeric + characters. + :param force: Use to forcefully delete a started datafeed; this method is quicker + than stopping and deleting the datafeed. """ - client, params = _deprecated_options(self, params) if datafeed_id in SKIP_IN_PATH: - raise ValueError( - "Empty value passed for a required argument 'datafeed_id'." - ) - - return client._perform_request( - "DELETE", - _make_path("_ml", "datafeeds", datafeed_id), - params=params, - headers=headers, - ) - - @query_params("requests_per_second", "timeout") - def delete_expired_data(self, body=None, job_id=None, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'datafeed_id'") + __path = f"/_ml/datafeeds/{_quote(datafeed_id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if force is not None: + __query["force"] = force + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + def delete_expired_data( + self, + *, + job_id: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + requests_per_second: Optional[float] = None, + timeout: Optional[Any] = None, + ) -> Any: """ Deletes expired and unused machine learning data. - ``_ - - :arg body: deleting expired data parameters - :arg job_id: The ID of the job(s) to perform expired data - hygiene for - :arg requests_per_second: The desired requests per second for - the deletion processes. - :arg timeout: How long can the underlying delete processes run - until they are canceled - """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "DELETE", - _make_path("_ml", "_delete_expired_data", job_id), - params=params, - headers=headers, - body=body, - ) - - @query_params() - def delete_filter(self, filter_id, params=None, headers=None): + ``_ + + :param job_id: Identifier for an anomaly detection job. It can be a job identifier, + a group name, or a wildcard expression. + :param requests_per_second: The desired requests per second for the deletion + processes. The default behavior is no throttling. + :param timeout: How long can the underlying delete processes run until they are + canceled. + """ + if job_id not in SKIP_IN_PATH: + __path = f"/_ml/_delete_expired_data/{_quote(job_id)}" + else: + __path = "/_ml/_delete_expired_data" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if requests_per_second is not None: + __body["requests_per_second"] = requests_per_second + if timeout is not None: + __body["timeout"] = timeout + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("DELETE", __target, headers=__headers, body=__body) + + @_rewrite_parameters() + def delete_filter( + self, + *, + filter_id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Deletes a filter. - ``_ + ``_ - :arg filter_id: The ID of the filter to delete + :param filter_id: A string that uniquely identifies a filter. """ - client, params = _deprecated_options(self, params) if filter_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'filter_id'.") - - return client._perform_request( - "DELETE", - _make_path("_ml", "filters", filter_id), - params=params, - headers=headers, - ) - - @query_params("allow_no_forecasts", "timeout") - def delete_forecast(self, job_id, forecast_id=None, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'filter_id'") + __path = f"/_ml/filters/{_quote(filter_id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + def delete_forecast( + self, + *, + job_id: Any, + forecast_id: Optional[Any] = None, + allow_no_forecasts: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ 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 - delimited list. Leaving blank implies `_all` - :arg allow_no_forecasts: Whether to ignore if `_all` matches no - forecasts - :arg timeout: Controls the time to wait until the forecast(s) - are deleted. Default to 30 seconds + :param job_id: Identifier for the anomaly detection job. + :param forecast_id: A comma-separated list of forecast identifiers. If you do + not specify this optional parameter or if you specify `_all` or `*` the API + deletes all forecasts from the job. + :param allow_no_forecasts: Specifies whether an error occurs when there are no + forecasts. In particular, if this parameter is set to `false` and there are + no forecasts associated with the job, attempts to delete all forecasts return + an error. + :param timeout: Specifies the period of time to wait for the completion of the + delete operation. When this period of time elapses, the API fails and returns + an error. """ - client, params = _deprecated_options(self, params) if job_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'job_id'.") - - return client._perform_request( - "DELETE", - _make_path("_ml", "anomaly_detectors", job_id, "_forecast", forecast_id), - params=params, - headers=headers, - ) - - @query_params("force", "wait_for_completion") - def delete_job(self, job_id, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'job_id'") + if job_id not in SKIP_IN_PATH and forecast_id not in SKIP_IN_PATH: + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}/_forecast/{_quote(forecast_id)}" + elif job_id not in SKIP_IN_PATH: + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}/_forecast" + else: + raise ValueError("Couldn't find a path for the given parameters") + __query: Dict[str, Any] = {} + if allow_no_forecasts is not None: + __query["allow_no_forecasts"] = allow_no_forecasts + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + def delete_job( + self, + *, + job_id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + force: Optional[bool] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + wait_for_completion: Optional[bool] = None, + ) -> Any: """ 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 - :arg wait_for_completion: Should this request wait until the - operation has completed before returning Default: True + :param job_id: Identifier for the anomaly detection job. + :param force: Use to forcefully delete an opened job; this method is quicker + than closing and deleting the job. + :param wait_for_completion: Specifies whether the request should return immediately + or wait until the job deletion completes. """ - client, params = _deprecated_options(self, params) if job_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'job_id'.") + raise ValueError("Empty value passed for parameter 'job_id'") + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if force is not None: + __query["force"] = force + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if wait_for_completion is not None: + __query["wait_for_completion"] = wait_for_completion + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + def delete_model_snapshot( + self, + *, + job_id: Any, + snapshot_id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: + """ + Deletes an existing model snapshot. - return client._perform_request( - "DELETE", - _make_path("_ml", "anomaly_detectors", job_id), - params=params, - headers=headers, - ) + ``_ - @query_params() - def delete_model_snapshot(self, job_id, snapshot_id, params=None, headers=None): + :param job_id: Identifier for the anomaly detection job. + :param snapshot_id: Identifier for the model snapshot. """ - Deletes an existing model snapshot. + if job_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'job_id'") + if snapshot_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'snapshot_id'") + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}/model_snapshots/{_quote(snapshot_id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + def delete_trained_model( + self, + *, + model_id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: + """ + Deletes an existing trained inference model that is currently not referenced + by an ingest pipeline. + + ``_ + + :param model_id: The unique identifier of the trained model. + """ + if model_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'model_id'") + __path = f"/_ml/trained_models/{_quote(model_id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + def delete_trained_model_alias( + self, + *, + model_id: Any, + model_alias: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: + """ + Deletes a model alias that refers to the trained model - ``_ + ``_ - :arg job_id: The ID of the job to fetch - :arg snapshot_id: The ID of the snapshot to delete + :param model_id: The trained model ID to which the model alias refers. + :param model_alias: The model alias to delete. + """ + if model_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'model_id'") + if model_alias in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'model_alias'") + __path = f"/_ml/trained_models/{_quote(model_id)}/model_aliases/{_quote(model_alias)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + def estimate_model_memory( + self, + *, + analysis_config: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + max_bucket_cardinality: Optional[Dict[Any, int]] = None, + overall_cardinality: Optional[Dict[Any, int]] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - client, params = _deprecated_options(self, params) - for param in (job_id, snapshot_id): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") + Estimates the model memory + + ``_ + + :param analysis_config: For a list of the properties that you can specify in + the `analysis_config` component of the body of this API. + :param max_bucket_cardinality: Estimates of the highest cardinality in a single + bucket that is observed for influencer fields over the time period that the + job analyzes data. To produce a good answer, values must be provided for + all influencer fields. Providing values for fields that are not listed as + `influencers` has no effect on the estimation. + :param overall_cardinality: Estimates of the cardinality that is observed for + fields over the whole time period that the job analyzes data. To produce + a good answer, values must be provided for fields referenced in the `by_field_name`, + `over_field_name` and `partition_field_name` of any detectors. Providing + values for other fields has no effect on the estimation. It can be omitted + from the request if no detectors have a `by_field_name`, `over_field_name` + or `partition_field_name`. + """ + __path = "/_ml/anomaly_detectors/_estimate_model_memory" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if analysis_config is not None: + __body["analysis_config"] = analysis_config + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if max_bucket_cardinality is not None: + __body["max_bucket_cardinality"] = max_bucket_cardinality + if overall_cardinality is not None: + __body["overall_cardinality"] = overall_cardinality + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, + ) + def evaluate_data_frame( + self, + *, + evaluation: Any, + index: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + query: Optional[Any] = None, + ) -> Any: + """ + Evaluates the data frame analytics for an annotated index. - return client._perform_request( - "DELETE", - _make_path( - "_ml", "anomaly_detectors", job_id, "model_snapshots", snapshot_id - ), - params=params, - headers=headers, - ) + ``_ + + :param evaluation: Defines the type of evaluation you want to perform. + :param index: Defines the index in which the evaluation will be performed. + :param query: A query clause that retrieves a subset of data from the source + index. + """ + if evaluation is None: + raise ValueError("Empty value passed for parameter 'evaluation'") + if index is None: + raise ValueError("Empty value passed for parameter 'index'") + __path = "/_ml/data_frame/_evaluate" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if evaluation is not None: + __body["evaluation"] = evaluation + if index is not None: + __body["index"] = index + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if query is not None: + __body["query"] = query + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, + ) + def explain_data_frame_analytics( + self, + *, + analysis: Any, + id: Optional[Any] = None, + allow_lazy_start: Optional[bool] = None, + analyzed_fields: Optional[Any] = None, + description: Optional[str] = None, + dest: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + max_num_threads: Optional[int] = None, + model_memory_limit: Optional[str] = None, + pretty: Optional[bool] = None, + source: Optional[Any] = None, + ) -> Any: + """ + Explains a data frame analytics config. - @query_params("advance_time", "calc_interim", "end", "skip_time", "start") - def flush_job(self, job_id, body=None, params=None, headers=None): + ``_ + + :param analysis: The analysis configuration, which contains the information necessary + to perform one of the following types of analysis: classification, outlier + detection, or regression. + :param id: Identifier for the data frame analytics job. This identifier can contain + lowercase alphanumeric characters (a-z and 0-9), hyphens, and underscores. + It must start and end with alphanumeric characters. + :param allow_lazy_start: Specifies whether this job can start when there is insufficient + machine learning node capacity for it to be immediately assigned to a node. + :param analyzed_fields: Specify includes and/or excludes patterns to select which + fields will be included in the analysis. The patterns specified in excludes + are applied last, therefore excludes takes precedence. In other words, if + the same field is specified in both includes and excludes, then the field + will not be included in the analysis. + :param description: A description of the job. + :param dest: The destination configuration, consisting of index and optionally + results_field (ml by default). + :param max_num_threads: The maximum number of threads to be used by the analysis. + The default value is 1. Using more threads may decrease the time necessary + to complete the analysis at the cost of using more CPU. Note that the process + may use additional threads for operational functionality other than the analysis + itself. + :param model_memory_limit: The approximate maximum amount of memory resources + that are permitted for analytical processing. The default value for data + frame analytics jobs is 1gb. If your elasticsearch.yml file contains an xpack.ml.max_model_memory_limit + setting, an error occurs when you try to create data frame analytics jobs + that have model_memory_limit values greater than that setting. + :param source: The configuration of how to source the analysis data. It requires + an index. Optionally, query and _source may be specified. + """ + if analysis is None: + raise ValueError("Empty value passed for parameter 'analysis'") + if id not in SKIP_IN_PATH: + __path = f"/_ml/data_frame/analytics/{_quote(id)}/_explain" + else: + __path = "/_ml/data_frame/analytics/_explain" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if analysis is not None: + __body["analysis"] = analysis + if allow_lazy_start is not None: + __body["allow_lazy_start"] = allow_lazy_start + if analyzed_fields is not None: + __body["analyzed_fields"] = analyzed_fields + if description is not None: + __body["description"] = description + if dest is not None: + __body["dest"] = dest + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if max_num_threads is not None: + __body["max_num_threads"] = max_num_threads + if model_memory_limit is not None: + __body["model_memory_limit"] = model_memory_limit + if pretty is not None: + __query["pretty"] = pretty + if source is not None: + __body["source"] = source + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, + ) + def flush_job( + self, + *, + job_id: Any, + advance_time: Optional[Any] = None, + calc_interim: Optional[bool] = None, + end: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + skip_time: Optional[str] = None, + start: Optional[Any] = None, + ) -> Any: """ Forces any buffered data to be processed by the job. - ``_ - - :arg job_id: The name of the job to flush - :arg body: Flush parameters - :arg advance_time: Advances time to the given value generating - results and updating the model for the advanced interval - :arg calc_interim: Calculates interim results for the most - recent bucket or all buckets within the latency period - :arg end: When used in conjunction with calc_interim, specifies - the range of buckets on which to calculate interim results - :arg skip_time: Skips time to the given value without generating - results or updating the model for the skipped interval - :arg start: When used in conjunction with calc_interim, - specifies the range of buckets on which to calculate interim results - """ - client, params = _deprecated_options(self, params) - if job_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'job_id'.") - - return client._perform_request( - "POST", - _make_path("_ml", "anomaly_detectors", job_id, "_flush"), - params=params, - headers=headers, - body=body, - ) + ``_ - @query_params("duration", "expires_in", "max_model_memory") - def forecast(self, job_id, params=None, headers=None): + :param job_id: Identifier for the anomaly detection job. + :param advance_time: Refer to the description for the `advance_time` query parameter. + :param calc_interim: Refer to the description for the `calc_interim` query parameter. + :param end: Refer to the description for the `end` query parameter. + :param skip_time: Refer to the description for the `skip_time` query parameter. + :param start: Refer to the description for the `start` query parameter. + """ + if job_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'job_id'") + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}/_flush" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if advance_time is not None: + __body["advance_time"] = advance_time + if calc_interim is not None: + __body["calc_interim"] = calc_interim + if end is not None: + __body["end"] = end + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if skip_time is not None: + __body["skip_time"] = skip_time + if start is not None: + __body["start"] = start + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, + ) + def forecast( + self, + *, + job_id: Any, + duration: Optional[Any] = None, + error_trace: Optional[bool] = None, + expires_in: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + max_model_memory: Optional[str] = None, + pretty: Optional[bool] = None, + ) -> Any: """ 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 - :arg expires_in: The time interval after which the forecast - expires. Expired forecasts will be deleted at the first opportunity. - :arg max_model_memory: The max memory able to be used by the - forecast. Default is 20mb. + :param job_id: Identifier for the anomaly detection job. The job must be open + when you create a forecast; otherwise, an error occurs. + :param duration: Refer to the description for the `duration` query parameter. + :param expires_in: Refer to the description for the `expires_in` query parameter. + :param max_model_memory: Refer to the description for the `max_model_memory` + query parameter. """ - client, params = _deprecated_options(self, params) if job_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'job_id'.") - - return client._perform_request( - "POST", - _make_path("_ml", "anomaly_detectors", job_id, "_forecast"), - params=params, - headers=headers, - ) - - @query_params( - "anomaly_score", - "desc", - "end", - "exclude_interim", - "expand", - "from_", - "size", - "sort", - "start", + raise ValueError("Empty value passed for parameter 'job_id'") + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}/_forecast" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if duration is not None: + __body["duration"] = duration + if error_trace is not None: + __query["error_trace"] = error_trace + if expires_in is not None: + __body["expires_in"] = expires_in + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if max_model_memory is not None: + __body["max_model_memory"] = max_model_memory + if pretty is not None: + __query["pretty"] = pretty + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, + parameter_aliases={"from": "from_"}, ) - def get_buckets(self, job_id, body=None, timestamp=None, params=None, headers=None): + def get_buckets( + self, + *, + job_id: Any, + timestamp: Optional[Any] = None, + anomaly_score: Optional[float] = None, + desc: Optional[bool] = None, + end: Optional[Any] = None, + error_trace: Optional[bool] = None, + exclude_interim: Optional[bool] = None, + expand: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + from_: Optional[int] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + size: Optional[int] = None, + sort: Optional[Any] = None, + start: Optional[Any] = None, + ) -> Any: """ 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 - :arg timestamp: The timestamp of the desired single bucket - result - :arg anomaly_score: Filter for the most anomalous buckets - :arg desc: Set the sort direction - :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 size: specifies a max number of buckets to get - :arg sort: Sort buckets by a particular field - :arg start: Start time filter for buckets - """ - client, params = _deprecated_options(self, params) - if params and "from_" in params: - params["from"] = params.pop("from_") - + ``_ + + :param job_id: Identifier for the anomaly detection job. + :param timestamp: The timestamp of a single bucket result. If you do not specify + this parameter, the API returns information about all buckets. + :param anomaly_score: Returns buckets with anomaly scores greater or equal than + this value. + :param desc: If `true`, the buckets are sorted in descending order. + :param end: Returns buckets with timestamps earlier than this time. `-1` means + it is unset and results are not limited to specific timestamps. + :param exclude_interim: If `true`, the output excludes interim results. + :param expand: If true, the output includes anomaly records. + :param from_: Skips the specified number of buckets. + :param size: Specifies the maximum number of buckets to obtain. + :param sort: Specifies the sort field for the requested buckets. + :param start: Returns buckets with timestamps after this time. `-1` means it + is unset and results are not limited to specific timestamps. + """ if job_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'job_id'.") - - return client._perform_request( - "POST", - _make_path( - "_ml", "anomaly_detectors", job_id, "results", "buckets", timestamp - ), - params=params, - headers=headers, - body=body, - ) - - @query_params("end", "from_", "job_id", "size", "start") - def get_calendar_events(self, calendar_id, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'job_id'") + if job_id not in SKIP_IN_PATH and timestamp not in SKIP_IN_PATH: + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}/results/buckets/{_quote(timestamp)}" + elif job_id not in SKIP_IN_PATH: + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}/results/buckets" + else: + raise ValueError("Couldn't find a path for the given parameters") + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if anomaly_score is not None: + __body["anomaly_score"] = anomaly_score + if desc is not None: + __body["desc"] = desc + if end is not None: + __body["end"] = end + if error_trace is not None: + __query["error_trace"] = error_trace + if exclude_interim is not None: + __body["exclude_interim"] = exclude_interim + if expand is not None: + __body["expand"] = expand + if filter_path is not None: + __query["filter_path"] = filter_path + if from_ is not None: + __query["from"] = from_ + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if size is not None: + __query["size"] = size + if sort is not None: + __body["sort"] = sort + if start is not None: + __body["start"] = start + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + parameter_aliases={"from": "from_"}, + ) + def get_calendar_events( + self, + *, + calendar_id: Any, + end: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + from_: Optional[int] = None, + human: Optional[bool] = None, + job_id: Optional[Any] = None, + pretty: Optional[bool] = None, + size: Optional[int] = None, + start: Optional[str] = None, + ) -> Any: """ 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 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 - :arg start: Get events after this time + :param calendar_id: A string that uniquely identifies a calendar. You can get + information for multiple calendars by using a comma-separated list of ids + or a wildcard expression. You can get information for all calendars by using + `_all` or `*` or by omitting the calendar identifier. + :param end: Specifies to get events with timestamps earlier than this time. + :param from_: Skips the specified number of events. + :param job_id: Specifies to get events for a specific anomaly detection job identifier + or job group. It must be used with a calendar identifier of `_all` or `*`. + :param size: Specifies the maximum number of events to obtain. + :param start: Specifies to get events with timestamps after this time. """ - client, params = _deprecated_options(self, params) - if params and "from_" in params: - params["from"] = params.pop("from_") - if calendar_id in SKIP_IN_PATH: - raise ValueError( - "Empty value passed for a required argument 'calendar_id'." - ) - - return client._perform_request( - "GET", - _make_path("_ml", "calendars", calendar_id, "events"), - params=params, - headers=headers, - ) - - @query_params("from_", "size") - def get_calendars(self, body=None, calendar_id=None, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'calendar_id'") + __path = f"/_ml/calendars/{_quote(calendar_id)}/events" + __query: Dict[str, Any] = {} + if end is not None: + __query["end"] = end + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if from_ is not None: + __query["from"] = from_ + if human is not None: + __query["human"] = human + if job_id is not None: + __query["job_id"] = job_id + if pretty is not None: + __query["pretty"] = pretty + if size is not None: + __query["size"] = size + if start is not None: + __query["start"] = start + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + parameter_aliases={"from": "from_"}, + ) + def get_calendars( + self, + *, + calendar_id: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + from_: Optional[int] = None, + human: Optional[bool] = None, + page: Optional[Any] = None, + pretty: Optional[bool] = None, + size: Optional[int] = None, + ) -> Any: """ 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 size: specifies a max number of calendars to get + ``_ + + :param calendar_id: A string that uniquely identifies a calendar. You can get + information for multiple calendars by using a comma-separated list of ids + or a wildcard expression. You can get information for all calendars by using + `_all` or `*` or by omitting the calendar identifier. + :param from_: Skips the specified number of calendars. This parameter is supported + only when you omit the calendar identifier. + :param page: This object is supported only when you omit the calendar identifier. + :param size: Specifies the maximum number of calendars to obtain. This parameter + is supported only when you omit the calendar identifier. + """ + if calendar_id not in SKIP_IN_PATH: + __path = f"/_ml/calendars/{_quote(calendar_id)}" + else: + __path = "/_ml/calendars" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if from_ is not None: + __query["from"] = from_ + if human is not None: + __query["human"] = human + if page is not None: + __body["page"] = page + if pretty is not None: + __query["pretty"] = pretty + if size is not None: + __query["size"] = size + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, + parameter_aliases={"from": "from_"}, + ) + def get_categories( + self, + *, + job_id: Any, + category_id: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + from_: Optional[int] = None, + human: Optional[bool] = None, + page: Optional[Any] = None, + partition_field_value: Optional[str] = None, + pretty: Optional[bool] = None, + size: Optional[int] = None, + ) -> Any: """ - client, params = _deprecated_options(self, params) - if params and "from_" in params: - params["from"] = params.pop("from_") + Retrieves anomaly detection job results for one or more categories. - return client._perform_request( - "POST", - _make_path("_ml", "calendars", calendar_id), - params=params, - headers=headers, - body=body, - ) + ``_ - @query_params("allow_no_datafeeds", "allow_no_match") - def get_datafeed_stats(self, datafeed_id=None, params=None, headers=None): + :param job_id: Identifier for the anomaly detection job. + :param category_id: Identifier for the category, which is unique in the job. + If you specify neither the category ID nor the partition_field_value, the + API returns information about all categories. If you specify only the partition_field_value, + it returns information about all categories for the specified partition. + :param from_: Skips the specified number of categories. + :param page: + :param partition_field_value: Only return categories for the specified partition. + :param size: Specifies the maximum number of categories to obtain. """ - Retrieves usage information for datafeeds. + if job_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'job_id'") + if job_id not in SKIP_IN_PATH and category_id not in SKIP_IN_PATH: + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}/results/categories/{_quote(category_id)}" + elif job_id not in SKIP_IN_PATH: + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}/results/categories" + else: + raise ValueError("Couldn't find a path for the given parameters") + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if from_ is not None: + __query["from"] = from_ + if human is not None: + __query["human"] = human + if page is not None: + __body["page"] = page + if partition_field_value is not None: + __query["partition_field_value"] = partition_field_value + if pretty is not None: + __query["pretty"] = pretty + if size is not None: + __query["size"] = size + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + parameter_aliases={"from": "from_"}, + ) + def get_data_frame_analytics( + self, + *, + id: Optional[Any] = None, + allow_no_match: Optional[bool] = None, + error_trace: Optional[bool] = None, + exclude_generated: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + from_: Optional[int] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + size: Optional[int] = None, + ) -> Any: + """ + Retrieves configuration information for data frame analytics jobs. - ``_ + ``_ + + :param id: Identifier for the data frame analytics job. If you do not specify + this option, the API returns information for the first hundred data frame + analytics jobs. + :param allow_no_match: Specifies what to do when the request: 1. Contains wildcard + expressions and there are no data frame analytics jobs that match. 2. Contains + the `_all` string or no identifiers and there are no matches. 3. Contains + wildcard expressions and there are only partial matches. The default value + returns an empty data_frame_analytics array when there are no matches and + the subset of results when there are partial matches. If this parameter is + `false`, the request returns a 404 status code when there are no matches + or only partial matches. + :param exclude_generated: Indicates if certain fields should be removed from + the configuration on retrieval. This allows the configuration to be in an + acceptable format to be retrieved and then added to another cluster. + :param from_: Skips the specified number of data frame analytics jobs. + :param size: Specifies the maximum number of data frame analytics jobs to obtain. + """ + if id not in SKIP_IN_PATH: + __path = f"/_ml/data_frame/analytics/{_quote(id)}" + else: + __path = "/_ml/data_frame/analytics" + __query: Dict[str, Any] = {} + if allow_no_match is not None: + __query["allow_no_match"] = allow_no_match + if error_trace is not None: + __query["error_trace"] = error_trace + if exclude_generated is not None: + __query["exclude_generated"] = exclude_generated + if filter_path is not None: + __query["filter_path"] = filter_path + if from_ is not None: + __query["from"] = from_ + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if size is not None: + __query["size"] = size + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + parameter_aliases={"from": "from_"}, + ) + def get_data_frame_analytics_stats( + self, + *, + id: Optional[Any] = None, + allow_no_match: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + from_: Optional[int] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + size: Optional[int] = None, + verbose: Optional[bool] = None, + ) -> Any: + """ + Retrieves usage information for data frame analytics jobs. - :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) - :arg allow_no_match: Whether to ignore if a wildcard expression - matches no datafeeds. (This includes `_all` string or when no datafeeds - have been specified) + ``_ + + :param id: Identifier for the data frame analytics job. If you do not specify + this option, the API returns information for the first hundred data frame + analytics jobs. + :param allow_no_match: Specifies what to do when the request: 1. Contains wildcard + expressions and there are no data frame analytics jobs that match. 2. Contains + the `_all` string or no identifiers and there are no matches. 3. Contains + wildcard expressions and there are only partial matches. The default value + returns an empty data_frame_analytics array when there are no matches and + the subset of results when there are partial matches. If this parameter is + `false`, the request returns a 404 status code when there are no matches + or only partial matches. + :param from_: Skips the specified number of data frame analytics jobs. + :param size: Specifies the maximum number of data frame analytics jobs to obtain. + :param verbose: Defines whether the stats response should be verbose. + """ + if id not in SKIP_IN_PATH: + __path = f"/_ml/data_frame/analytics/{_quote(id)}/_stats" + else: + __path = "/_ml/data_frame/analytics/_stats" + __query: Dict[str, Any] = {} + if allow_no_match is not None: + __query["allow_no_match"] = allow_no_match + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if from_ is not None: + __query["from"] = from_ + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if size is not None: + __query["size"] = size + if verbose is not None: + __query["verbose"] = verbose + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def get_datafeed_stats( + self, + *, + datafeed_id: Optional[Any] = None, + allow_no_match: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", - _make_path("_ml", "datafeeds", datafeed_id, "_stats"), - params=params, - headers=headers, - ) + Retrieves usage information for datafeeds. - @query_params("allow_no_datafeeds", "allow_no_match", "exclude_generated") - def get_datafeeds(self, datafeed_id=None, params=None, headers=None): + ``_ + + :param datafeed_id: Identifier for the datafeed. It can be a datafeed identifier + or a wildcard expression. If you do not specify one of these options, the + API returns information about all datafeeds. + :param allow_no_match: Specifies what to do when the request: 1. Contains wildcard + expressions and there are no datafeeds that match. 2. Contains the `_all` + string or no identifiers and there are no matches. 3. Contains wildcard expressions + and there are only partial matches. The default value is `true`, which returns + an empty `datafeeds` array when there are no matches and the subset of results + when there are partial matches. If this parameter is `false`, the request + returns a `404` status code when there are no matches or only partial matches. + """ + if datafeed_id not in SKIP_IN_PATH: + __path = f"/_ml/datafeeds/{_quote(datafeed_id)}/_stats" + else: + __path = "/_ml/datafeeds/_stats" + __query: Dict[str, Any] = {} + if allow_no_match is not None: + __query["allow_no_match"] = allow_no_match + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def get_datafeeds( + self, + *, + datafeed_id: Optional[Any] = None, + allow_no_match: Optional[bool] = None, + error_trace: Optional[bool] = None, + exclude_generated: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ 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) - :arg allow_no_match: Whether to ignore if a wildcard expression - matches no datafeeds. (This includes `_all` string or when no datafeeds - have been specified) - :arg exclude_generated: Omits fields that are illegal to set on - datafeed PUT - """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", - _make_path("_ml", "datafeeds", datafeed_id), - params=params, - headers=headers, - ) - - @query_params("from_", "size") - def get_filters(self, filter_id=None, params=None, headers=None): + ``_ + + :param datafeed_id: Identifier for the datafeed. It can be a datafeed identifier + or a wildcard expression. If you do not specify one of these options, the + API returns information about all datafeeds. + :param allow_no_match: Specifies what to do when the request: 1. Contains wildcard + expressions and there are no datafeeds that match. 2. Contains the `_all` + string or no identifiers and there are no matches. 3. Contains wildcard expressions + and there are only partial matches. The default value is `true`, which returns + an empty `datafeeds` array when there are no matches and the subset of results + when there are partial matches. If this parameter is `false`, the request + returns a `404` status code when there are no matches or only partial matches. + :param exclude_generated: Indicates if certain fields should be removed from + the configuration on retrieval. This allows the configuration to be in an + acceptable format to be retrieved and then added to another cluster. + """ + if datafeed_id not in SKIP_IN_PATH: + __path = f"/_ml/datafeeds/{_quote(datafeed_id)}" + else: + __path = "/_ml/datafeeds" + __query: Dict[str, Any] = {} + if allow_no_match is not None: + __query["allow_no_match"] = allow_no_match + if error_trace is not None: + __query["error_trace"] = error_trace + if exclude_generated is not None: + __query["exclude_generated"] = exclude_generated + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + parameter_aliases={"from": "from_"}, + ) + def get_filters( + self, + *, + filter_id: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + from_: Optional[int] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + size: Optional[int] = None, + ) -> Any: """ Retrieves filters. - ``_ - - :arg filter_id: The ID of the filter to fetch - :arg from\\_: skips a number of filters - :arg size: specifies a max number of filters to get - """ - client, params = _deprecated_options(self, params) - if params and "from_" in params: - params["from"] = params.pop("from_") - - return client._perform_request( - "GET", - _make_path("_ml", "filters", filter_id), - params=params, - headers=headers, - ) - - @query_params( - "desc", - "end", - "exclude_interim", - "from_", - "influencer_score", - "size", - "sort", - "start", + ``_ + + :param filter_id: A string that uniquely identifies a filter. + :param from_: Skips the specified number of filters. + :param size: Specifies the maximum number of filters to obtain. + """ + if filter_id not in SKIP_IN_PATH: + __path = f"/_ml/filters/{_quote(filter_id)}" + else: + __path = "/_ml/filters" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if from_ is not None: + __query["from"] = from_ + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if size is not None: + __query["size"] = size + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + parameter_aliases={"from": "from_"}, ) - def get_influencers(self, job_id, body=None, params=None, headers=None): + def get_influencers( + self, + *, + job_id: Any, + desc: Optional[bool] = None, + end: Optional[Any] = None, + error_trace: Optional[bool] = None, + exclude_interim: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + from_: Optional[int] = None, + human: Optional[bool] = None, + influencer_score: Optional[float] = None, + page: Optional[Any] = None, + pretty: Optional[bool] = None, + size: Optional[int] = None, + sort: Optional[Any] = None, + start: Optional[Any] = None, + ) -> Any: """ Retrieves anomaly detection job results for one or more influencers. - ``_ - - :arg job_id: Identifier for the anomaly detection job - :arg body: Influencer selection criteria - :arg desc: whether the results should be sorted in decending - order - :arg end: end timestamp for the requested influencers - :arg exclude_interim: Exclude interim results - :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 - :arg sort: sort field for the requested influencers - :arg start: start timestamp for the requested influencers - """ - client, params = _deprecated_options(self, params) - if params and "from_" in params: - params["from"] = params.pop("from_") - + ``_ + + :param job_id: Identifier for the anomaly detection job. + :param desc: If true, the results are sorted in descending order. + :param end: Returns influencers with timestamps earlier than this time. The default + value means it is unset and results are not limited to specific timestamps. + :param exclude_interim: If true, the output excludes interim results. By default, + interim results are included. + :param from_: Skips the specified number of influencers. + :param influencer_score: Returns influencers with anomaly scores greater than + or equal to this value. + :param page: + :param size: Specifies the maximum number of influencers to obtain. + :param sort: Specifies the sort field for the requested influencers. By default, + the influencers are sorted by the `influencer_score` value. + :param start: Returns influencers with timestamps after this time. The default + value means it is unset and results are not limited to specific timestamps. + """ if job_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'job_id'.") - - return client._perform_request( - "POST", - _make_path("_ml", "anomaly_detectors", job_id, "results", "influencers"), - params=params, - headers=headers, - body=body, - ) - - @query_params("allow_no_jobs", "allow_no_match") - def get_job_stats(self, job_id=None, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'job_id'") + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}/results/influencers" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if desc is not None: + __query["desc"] = desc + if end is not None: + __query["end"] = end + if error_trace is not None: + __query["error_trace"] = error_trace + if exclude_interim is not None: + __query["exclude_interim"] = exclude_interim + if filter_path is not None: + __query["filter_path"] = filter_path + if from_ is not None: + __query["from"] = from_ + if human is not None: + __query["human"] = human + if influencer_score is not None: + __query["influencer_score"] = influencer_score + if page is not None: + __body["page"] = page + if pretty is not None: + __query["pretty"] = pretty + if size is not None: + __query["size"] = size + if sort is not None: + __query["sort"] = sort + if start is not None: + __query["start"] = start + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters() + def get_job_stats( + self, + *, + job_id: Optional[Any] = None, + allow_no_match: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ 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) - :arg allow_no_match: Whether to ignore if a wildcard expression - matches no jobs. (This includes `_all` string or when no jobs have been - specified) - """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", - _make_path("_ml", "anomaly_detectors", job_id, "_stats"), - params=params, - headers=headers, - ) - - @query_params("allow_no_jobs", "allow_no_match", "exclude_generated") - def get_jobs(self, job_id=None, params=None, headers=None): + ``_ + + :param job_id: Identifier for the anomaly detection job. It can be a job identifier, + a group name, a comma-separated list of jobs, or a wildcard expression. If + you do not specify one of these options, the API returns information for + all anomaly detection jobs. + :param allow_no_match: Specifies what to do when the request: 1. Contains wildcard + expressions and there are no jobs that match. 2. Contains the _all string + or no identifiers and there are no matches. 3. Contains wildcard expressions + and there are only partial matches. If `true`, the API returns an empty `jobs` + array when there are no matches and the subset of results when there are + partial matches. If `false`, the API returns a `404` status code when there + are no matches or only partial matches. + """ + if job_id not in SKIP_IN_PATH: + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}/_stats" + else: + __path = "/_ml/anomaly_detectors/_stats" + __query: Dict[str, Any] = {} + if allow_no_match is not None: + __query["allow_no_match"] = allow_no_match + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def get_jobs( + self, + *, + job_id: Optional[Any] = None, + allow_no_match: Optional[bool] = None, + error_trace: Optional[bool] = None, + exclude_generated: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ 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) - :arg allow_no_match: Whether to ignore if a wildcard expression - matches no jobs. (This includes `_all` string or when no jobs have been - specified) - :arg exclude_generated: Omits fields that are illegal to set on - job PUT - """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", - _make_path("_ml", "anomaly_detectors", job_id), - params=params, - headers=headers, - ) - - @query_params( - "allow_no_jobs", - "allow_no_match", - "bucket_span", - "end", - "exclude_interim", - "overall_score", - "start", - "top_n", + ``_ + + :param job_id: Identifier for the anomaly detection job. It can be a job identifier, + a group name, or a wildcard expression. If you do not specify one of these + options, the API returns information for all anomaly detection jobs. + :param allow_no_match: Specifies what to do when the request: 1. Contains wildcard + expressions and there are no jobs that match. 2. Contains the _all string + or no identifiers and there are no matches. 3. Contains wildcard expressions + and there are only partial matches. The default value is `true`, which returns + an empty `jobs` array when there are no matches and the subset of results + when there are partial matches. If this parameter is `false`, the request + returns a `404` status code when there are no matches or only partial matches. + :param exclude_generated: Indicates if certain fields should be removed from + the configuration on retrieval. This allows the configuration to be in an + acceptable format to be retrieved and then added to another cluster. + """ + if job_id not in SKIP_IN_PATH: + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}" + else: + __path = "/_ml/anomaly_detectors" + __query: Dict[str, Any] = {} + if allow_no_match is not None: + __query["allow_no_match"] = allow_no_match + if error_trace is not None: + __query["error_trace"] = error_trace + if exclude_generated is not None: + __query["exclude_generated"] = exclude_generated + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + parameter_aliases={"from": "from_"}, ) - def get_overall_buckets(self, job_id, body=None, params=None, headers=None): + def get_model_snapshots( + self, + *, + job_id: Any, + snapshot_id: Optional[Any] = None, + desc: Optional[bool] = None, + end: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + from_: Optional[int] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + size: Optional[int] = None, + sort: Optional[Any] = None, + start: Optional[Any] = None, + ) -> Any: + """ + Retrieves information about model snapshots. + + ``_ + + :param job_id: Identifier for the anomaly detection job. + :param snapshot_id: A numerical character string that uniquely identifies the + model snapshot. + :param desc: If true, the results are sorted in descending order. + :param end: Returns snapshots with timestamps earlier than this time. Defaults + to unset, which means results are not limited to specific timestamps. + :param from_: Skips the specified number of snapshots. + :param size: Specifies the maximum number of snapshots to obtain. + :param sort: Specifies the sort field for the requested snapshots. By default, + the snapshots are sorted by their timestamp. + :param start: Returns snapshots with timestamps after this time. Defaults to + unset, which means results are not limited to specific timestamps. + """ + if job_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'job_id'") + if job_id not in SKIP_IN_PATH and snapshot_id not in SKIP_IN_PATH: + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}/model_snapshots/{_quote(snapshot_id)}" + elif job_id not in SKIP_IN_PATH: + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}/model_snapshots" + else: + raise ValueError("Couldn't find a path for the given parameters") + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if desc is not None: + __query["desc"] = desc + if end is not None: + __body["end"] = end + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if from_ is not None: + __query["from"] = from_ + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if size is not None: + __query["size"] = size + if sort is not None: + __query["sort"] = sort + if start is not None: + __body["start"] = start + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters() + def get_overall_buckets( + self, + *, + job_id: Any, + allow_no_match: Optional[bool] = None, + bucket_span: Optional[Any] = None, + end: Optional[Any] = None, + error_trace: Optional[bool] = None, + exclude_interim: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + overall_score: Optional[Union[float, str]] = None, + pretty: Optional[bool] = None, + start: Optional[Any] = None, + top_n: Optional[int] = None, + ) -> Any: """ 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 - :arg body: Overall bucket selection details if not provided in - URI - :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) - :arg allow_no_match: Whether to ignore if a wildcard expression - matches no jobs. (This includes `_all` string or when no jobs have been - specified) - :arg bucket_span: The span of the overall buckets. Defaults to - the longest job bucket_span - :arg end: Returns overall buckets with timestamps earlier than - this time - :arg exclude_interim: If true overall buckets that include - interim buckets will be excluded - :arg overall_score: Returns overall buckets with overall scores - higher than this value - :arg start: Returns overall buckets with timestamps after this - time - :arg top_n: The number of top job bucket scores to be used in - the overall_score calculation - """ - client, params = _deprecated_options(self, params) + ``_ + + :param job_id: Identifier for the anomaly detection job. It can be a job identifier, + a group name, a comma-separated list of jobs or groups, or a wildcard expression. + You can summarize the bucket results for all anomaly detection jobs by using + `_all` or by specifying `*` as the ``. + :param allow_no_match: Specifies what to do when the request: 1. Contains wildcard + expressions and there are no jobs that match. 2. Contains the `_all` string + or no identifiers and there are no matches. 3. Contains wildcard expressions + and there are only partial matches. If `true`, the request returns an empty + `jobs` array when there are no matches and the subset of results when there + are partial matches. If this parameter is `false`, the request returns a + `404` status code when there are no matches or only partial matches. + :param bucket_span: The span of the overall buckets. Must be greater or equal + to the largest bucket span of the specified anomaly detection jobs, which + is the default value. By default, an overall bucket has a span equal to the + largest bucket span of the specified anomaly detection jobs. To override + that behavior, use the optional `bucket_span` parameter. + :param end: Returns overall buckets with timestamps earlier than this time. + :param exclude_interim: If `true`, the output excludes interim results. + :param overall_score: Returns overall buckets with overall scores greater than + or equal to this value. + :param start: Returns overall buckets with timestamps after this time. + :param top_n: The number of top anomaly detection job bucket scores to be used + in the `overall_score` calculation. + """ if job_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'job_id'.") - - return client._perform_request( - "POST", - _make_path( - "_ml", "anomaly_detectors", job_id, "results", "overall_buckets" - ), - params=params, - headers=headers, - body=body, - ) - - @query_params( - "desc", - "end", - "exclude_interim", - "from_", - "record_score", - "size", - "sort", - "start", + raise ValueError("Empty value passed for parameter 'job_id'") + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}/results/overall_buckets" + __query: Dict[str, Any] = {} + if allow_no_match is not None: + __query["allow_no_match"] = allow_no_match + if bucket_span is not None: + __query["bucket_span"] = bucket_span + if end is not None: + __query["end"] = end + if error_trace is not None: + __query["error_trace"] = error_trace + if exclude_interim is not None: + __query["exclude_interim"] = exclude_interim + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if overall_score is not None: + __query["overall_score"] = overall_score + if pretty is not None: + __query["pretty"] = pretty + if start is not None: + __query["start"] = start + if top_n is not None: + __query["top_n"] = top_n + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + parameter_aliases={"from": "from_"}, ) - def get_records(self, job_id, body=None, params=None, headers=None): + def get_records( + self, + *, + job_id: Any, + desc: Optional[bool] = None, + end: Optional[Any] = None, + error_trace: Optional[bool] = None, + exclude_interim: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + from_: Optional[int] = None, + human: Optional[bool] = None, + page: Optional[Any] = None, + pretty: Optional[bool] = None, + record_score: Optional[float] = None, + size: Optional[int] = None, + sort: Optional[Any] = None, + start: Optional[Any] = None, + ) -> Any: """ 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 record_score: Returns records with anomaly scores greater - or equal than this value - :arg size: specifies a max number of records to get - :arg sort: Sort records by a particular field - :arg start: Start time filter for records + ``_ + + :param job_id: Identifier for the anomaly detection job. + :param desc: If true, the results are sorted in descending order. + :param end: Returns records with timestamps earlier than this time. The default + value means results are not limited to specific timestamps. + :param exclude_interim: If true, the output excludes interim results. + :param from_: Skips the specified number of records. + :param page: + :param record_score: Returns records with anomaly scores greater or equal than + this value. + :param size: Specifies the maximum number of records to obtain. + :param sort: Specifies the sort field for the requested records. + :param start: Returns records with timestamps earlier than this time. The default + value means results are not limited to specific timestamps. """ - client, params = _deprecated_options(self, params) - if params and "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 client._perform_request( - "POST", - _make_path("_ml", "anomaly_detectors", job_id, "results", "records"), - params=params, - headers=headers, - body=body, - ) + raise ValueError("Empty value passed for parameter 'job_id'") + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}/results/records" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if desc is not None: + __body["desc"] = desc + if end is not None: + __body["end"] = end + if error_trace is not None: + __query["error_trace"] = error_trace + if exclude_interim is not None: + __body["exclude_interim"] = exclude_interim + if filter_path is not None: + __query["filter_path"] = filter_path + if from_ is not None: + __query["from"] = from_ + if human is not None: + __query["human"] = human + if page is not None: + __body["page"] = page + if pretty is not None: + __query["pretty"] = pretty + if record_score is not None: + __body["record_score"] = record_score + if size is not None: + __query["size"] = size + if sort is not None: + __body["sort"] = sort + if start is not None: + __body["start"] = start + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + parameter_aliases={"from": "from_"}, + ) + def get_trained_models( + self, + *, + model_id: Optional[Any] = None, + allow_no_match: Optional[bool] = None, + decompress_definition: Optional[bool] = None, + error_trace: Optional[bool] = None, + exclude_generated: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + from_: Optional[int] = None, + human: Optional[bool] = None, + include: Optional[Any] = None, + pretty: Optional[bool] = None, + size: Optional[int] = None, + tags: Optional[str] = None, + ) -> Any: + """ + Retrieves configuration information for a trained inference model. - @query_params() - def info(self, params=None, headers=None): + ``_ + + :param model_id: The unique identifier of the trained model. + :param allow_no_match: Specifies what to do when the request: - Contains wildcard + expressions and there are no models that match. - Contains the _all string + or no identifiers and there are no matches. - Contains wildcard expressions + and there are only partial matches. If true, it returns an empty array when + there are no matches and the subset of results when there are partial matches. + :param decompress_definition: Specifies whether the included model definition + should be returned as a JSON map (true) or in a custom compressed format + (false). + :param exclude_generated: Indicates if certain fields should be removed from + the configuration on retrieval. This allows the configuration to be in an + acceptable format to be retrieved and then added to another cluster. + :param from_: Skips the specified number of models. + :param include: A comma delimited string of optional fields to include in the + response body. + :param size: Specifies the maximum number of models to obtain. + :param tags: A comma delimited string of tags. A trained model can have many + tags, or none. When supplied, only trained models that contain all the supplied + tags are returned. + """ + if model_id not in SKIP_IN_PATH: + __path = f"/_ml/trained_models/{_quote(model_id)}" + else: + __path = "/_ml/trained_models" + __query: Dict[str, Any] = {} + if allow_no_match is not None: + __query["allow_no_match"] = allow_no_match + if decompress_definition is not None: + __query["decompress_definition"] = decompress_definition + if error_trace is not None: + __query["error_trace"] = error_trace + if exclude_generated is not None: + __query["exclude_generated"] = exclude_generated + if filter_path is not None: + __query["filter_path"] = filter_path + if from_ is not None: + __query["from"] = from_ + if human is not None: + __query["human"] = human + if include is not None: + __query["include"] = include + if pretty is not None: + __query["pretty"] = pretty + if size is not None: + __query["size"] = size + if tags is not None: + __query["tags"] = tags + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + parameter_aliases={"from": "from_"}, + ) + def get_trained_models_stats( + self, + *, + model_id: Optional[Any] = None, + allow_no_match: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + from_: Optional[int] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + size: Optional[int] = None, + ) -> Any: """ - Returns defaults and limits used by machine learning. + Retrieves usage information for trained inference models. - ``_ + ``_ + + :param model_id: The unique identifier of the trained model or a model alias. + :param allow_no_match: Specifies what to do when the request: - Contains wildcard + expressions and there are no models that match. - Contains the _all string + or no identifiers and there are no matches. - Contains wildcard expressions + and there are only partial matches. If true, it returns an empty array when + there are no matches and the subset of results when there are partial matches. + :param from_: Skips the specified number of models. + :param size: Specifies the maximum number of models to obtain. + """ + if model_id not in SKIP_IN_PATH: + __path = f"/_ml/trained_models/{_quote(model_id)}/_stats" + else: + __path = "/_ml/trained_models/_stats" + __query: Dict[str, Any] = {} + if allow_no_match is not None: + __query["allow_no_match"] = allow_no_match + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if from_ is not None: + __query["from"] = from_ + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if size is not None: + __query["size"] = size + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def info( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", "/_ml/info", params=params, headers=headers - ) + Returns defaults and limits used by machine learning. - @query_params() - def open_job(self, job_id, params=None, headers=None): + ``_ + """ + __path = "/_ml/info" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + def open_job( + self, + *, + job_id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ Opens one or more anomaly detection jobs. - ``_ + ``_ - :arg job_id: The ID of the job to open + :param job_id: Identifier for the anomaly detection job. + :param timeout: Controls the time to wait until a job has opened. """ - client, params = _deprecated_options(self, params) if job_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'job_id'.") - - return client._perform_request( - "POST", - _make_path("_ml", "anomaly_detectors", job_id, "_open"), - params=params, - headers=headers, - ) - - @query_params() - def post_calendar_events(self, calendar_id, body, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'job_id'") + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}/_open" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __body["timeout"] = timeout + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, + ) + def post_calendar_events( + self, + *, + calendar_id: Any, + events: List[Any], + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Posts scheduled events in a calendar. - ``_ + ``_ - :arg calendar_id: The ID of the calendar to modify - :arg body: A list of events + :param calendar_id: A string that uniquely identifies a calendar. + :param events: A list of one of more scheduled events. The event’s start and + end times can be specified as integer milliseconds since the epoch or as + a string in ISO 8601 format. """ - client, params = _deprecated_options(self, params) - for param in (calendar_id, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "POST", - _make_path("_ml", "calendars", calendar_id, "events"), - params=params, - headers=headers, - body=body, - ) - - @query_params("reset_end", "reset_start") - def post_data(self, job_id, body, params=None, headers=None): + if calendar_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'calendar_id'") + if events is None: + raise ValueError("Empty value passed for parameter 'events'") + __path = f"/_ml/calendars/{_quote(calendar_id)}/events" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if events is not None: + __body["events"] = events + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_name="data", + ) + def post_data( + self, + *, + job_id: Any, + data: List[Any], + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + reset_end: Optional[Any] = None, + reset_start: Optional[Any] = None, + ) -> Any: """ 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 - :arg reset_end: Optional parameter to specify the end of the - bucket resetting range - :arg reset_start: Optional parameter to specify the start of the - bucket resetting range + :param job_id: Identifier for the anomaly detection job. The job must have a + state of open to receive and process the data. + :param data: + :param reset_end: Specifies the end of the bucket resetting range. + :param reset_start: Specifies the start of the bucket resetting range. """ - client, params = _deprecated_options(self, params) - for param in (job_id, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - headers["content-type"] = "application/x-ndjson" - return client._perform_request( - "POST", - _make_path("_ml", "anomaly_detectors", job_id, "_data"), - params=params, - headers=headers, - body=body, - ) - - @query_params() - def preview_datafeed(self, body=None, datafeed_id=None, params=None, headers=None): + if job_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'job_id'") + if data is None: + raise ValueError("Empty value passed for parameter 'data'") + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}/_data" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if reset_end is not None: + __query["reset_end"] = reset_end + if reset_start is not None: + __query["reset_start"] = reset_start + __body = data + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = { + "accept": "application/json", + "content-type": "application/x-ndjson", + } + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, + ) + def preview_data_frame_analytics( + self, + *, + id: Optional[Any] = None, + config: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Previews a datafeed. - - ``_ + Previews that will be analyzed given a data frame analytics config. - :arg body: The datafeed config and job config with which to - execute the preview - :arg datafeed_id: The ID of the datafeed to preview + ``_ + + :param id: Identifier for the data frame analytics job. + :param config: A data frame analytics config as described in Create data frame + analytics jobs. Note that id and dest don’t need to be provided in the context + of this API. + """ + if id not in SKIP_IN_PATH: + __path = f"/_ml/data_frame/analytics/{_quote(id)}/_preview" + else: + __path = "/_ml/data_frame/analytics/_preview" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if config is not None: + __body["config"] = config + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, + ) + def preview_datafeed( + self, + *, + datafeed_id: Optional[Any] = None, + datafeed_config: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + job_config: Optional[Any] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "POST", - _make_path("_ml", "datafeeds", datafeed_id, "_preview"), - params=params, - headers=headers, - body=body, - ) + Previews a datafeed. - @query_params() - def put_calendar(self, calendar_id, body=None, params=None, headers=None): + ``_ + + :param datafeed_id: A numerical character string that uniquely identifies the + datafeed. This identifier can contain lowercase alphanumeric characters (a-z + and 0-9), hyphens, and underscores. It must start and end with alphanumeric + characters. NOTE: If you use this path parameter, you cannot provide datafeed + or anomaly detection job configuration details in the request body. + :param datafeed_config: The datafeed definition to preview. + :param job_config: The configuration details for the anomaly detection job that + is associated with the datafeed. If the `datafeed_config` object does not + include a `job_id` that references an existing anomaly detection job, you + must supply this `job_config` object. If you include both a `job_id` and + a `job_config`, the latter information is used. You cannot specify a `job_config` + object unless you also supply a `datafeed_config` object. + """ + if datafeed_id not in SKIP_IN_PATH: + __path = f"/_ml/datafeeds/{_quote(datafeed_id)}/_preview" + else: + __path = "/_ml/datafeeds/_preview" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if datafeed_config is not None: + __body["datafeed_config"] = datafeed_config + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if job_config is not None: + __body["job_config"] = job_config + if pretty is not None: + __query["pretty"] = pretty + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, + ) + def put_calendar( + self, + *, + calendar_id: Any, + description: Optional[str] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Instantiates a calendar. - ``_ + ``_ - :arg calendar_id: The ID of the calendar to create - :arg body: The calendar details + :param calendar_id: A string that uniquely identifies a calendar. + :param description: A description of the calendar. """ - client, params = _deprecated_options(self, params) if calendar_id in SKIP_IN_PATH: - raise ValueError( - "Empty value passed for a required argument 'calendar_id'." - ) - - return client._perform_request( - "PUT", - _make_path("_ml", "calendars", calendar_id), - params=params, - headers=headers, - body=body, - ) - - @query_params() - def put_calendar_job(self, calendar_id, job_id, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'calendar_id'") + __path = f"/_ml/calendars/{_quote(calendar_id)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if description is not None: + __body["description"] = description + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("PUT", __target, headers=__headers, body=__body) + + @_rewrite_parameters() + def put_calendar_job( + self, + *, + calendar_id: Any, + job_id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ 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 + :param calendar_id: A string that uniquely identifies a calendar. + :param job_id: An identifier for the anomaly detection jobs. It can be a job + identifier, a group name, or a comma-separated list of jobs or groups. """ - client, params = _deprecated_options(self, params) - for param in (calendar_id, job_id): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "PUT", - _make_path("_ml", "calendars", calendar_id, "jobs", job_id), - params=params, - headers=headers, - ) + if calendar_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'calendar_id'") + if job_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'job_id'") + __path = f"/_ml/calendars/{_quote(calendar_id)}/jobs/{_quote(job_id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("PUT", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + def put_data_frame_analytics( + self, + *, + id: Any, + analysis: Any, + dest: Any, + source: Any, + allow_lazy_start: Optional[bool] = None, + analyzed_fields: Optional[Any] = None, + description: Optional[str] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + max_num_threads: Optional[int] = None, + model_memory_limit: Optional[str] = None, + pretty: Optional[bool] = None, + ) -> Any: + """ + Instantiates a data frame analytics job. - @query_params( - "allow_no_indices", "expand_wildcards", "ignore_throttled", "ignore_unavailable" + ``_ + + :param id: Identifier for the data frame analytics job. This identifier can contain + lowercase alphanumeric characters (a-z and 0-9), hyphens, and underscores. + It must start and end with alphanumeric characters. + :param analysis: The analysis configuration, which contains the information necessary + to perform one of the following types of analysis: classification, outlier + detection, or regression. + :param dest: The destination configuration. + :param source: The configuration of how to source the analysis data. + :param allow_lazy_start: Specifies whether this job can start when there is insufficient + machine learning node capacity for it to be immediately assigned to a node. + If set to false and a machine learning node with capacity to run the job + cannot be immediately found, the API returns an error. If set to true, the + API does not return an error; the job waits in the `starting` state until + sufficient machine learning node capacity is available. This behavior is + also affected by the cluster-wide `xpack.ml.max_lazy_ml_nodes` setting. + :param analyzed_fields: Specifies `includes` and/or `excludes` patterns to select + which fields will be included in the analysis. The patterns specified in + `excludes` are applied last, therefore `excludes` takes precedence. In other + words, if the same field is specified in both `includes` and `excludes`, + then the field will not be included in the analysis. If `analyzed_fields` + is not set, only the relevant fields will be included. For example, all the + numeric fields for outlier detection. The supported fields vary for each + type of analysis. Outlier detection requires numeric or `boolean` data to + analyze. The algorithms don’t support missing values therefore fields that + have data types other than numeric or boolean are ignored. Documents where + included fields contain missing values, null values, or an array are also + ignored. Therefore the `dest` index may contain documents that don’t have + an outlier score. Regression supports fields that are numeric, `boolean`, + `text`, `keyword`, and `ip` data types. It is also tolerant of missing values. + Fields that are supported are included in the analysis, other fields are + ignored. Documents where included fields contain an array with two or more + values are also ignored. Documents in the `dest` index that don’t contain + a results field are not included in the regression analysis. Classification + supports fields that are numeric, `boolean`, `text`, `keyword`, and `ip` + data types. It is also tolerant of missing values. Fields that are supported + are included in the analysis, other fields are ignored. Documents where included + fields contain an array with two or more values are also ignored. Documents + in the `dest` index that don’t contain a results field are not included in + the classification analysis. Classification analysis can be improved by mapping + ordinal variable values to a single number. For example, in case of age ranges, + you can model the values as `0-14 = 0`, `15-24 = 1`, `25-34 = 2`, and so + on. + :param description: A description of the job. + :param max_num_threads: The maximum number of threads to be used by the analysis. + Using more threads may decrease the time necessary to complete the analysis + at the cost of using more CPU. Note that the process may use additional threads + for operational functionality other than the analysis itself. + :param model_memory_limit: The approximate maximum amount of memory resources + that are permitted for analytical processing. If your `elasticsearch.yml` + file contains an `xpack.ml.max_model_memory_limit` setting, an error occurs + when you try to create data frame analytics jobs that have `model_memory_limit` + values greater than that setting. + """ + if id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'id'") + if analysis is None: + raise ValueError("Empty value passed for parameter 'analysis'") + if dest is None: + raise ValueError("Empty value passed for parameter 'dest'") + if source is None: + raise ValueError("Empty value passed for parameter 'source'") + __path = f"/_ml/data_frame/analytics/{_quote(id)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if analysis is not None: + __body["analysis"] = analysis + if dest is not None: + __body["dest"] = dest + if source is not None: + __body["source"] = source + if allow_lazy_start is not None: + __body["allow_lazy_start"] = allow_lazy_start + if analyzed_fields is not None: + __body["analyzed_fields"] = analyzed_fields + if description is not None: + __body["description"] = description + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if max_num_threads is not None: + __body["max_num_threads"] = max_num_threads + if model_memory_limit is not None: + __body["model_memory_limit"] = model_memory_limit + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("PUT", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, ) - def put_datafeed(self, datafeed_id, body, params=None, headers=None): + def put_datafeed( + self, + *, + datafeed_id: Any, + aggregations: Optional[Dict[str, Any]] = None, + allow_no_indices: Optional[bool] = None, + chunking_config: Optional[Any] = None, + delayed_data_check_config: Optional[Any] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + frequency: Optional[Any] = None, + human: Optional[bool] = None, + ignore_throttled: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + indices: Optional[List[str]] = None, + indices_options: Optional[Any] = None, + job_id: Optional[Any] = None, + max_empty_searches: Optional[int] = None, + pretty: Optional[bool] = None, + query: Optional[Any] = None, + query_delay: Optional[Any] = None, + runtime_mappings: Optional[Any] = None, + script_fields: Optional[Dict[str, Any]] = None, + scroll_size: Optional[int] = None, + ) -> Any: """ Instantiates a datafeed. - ``_ - - :arg datafeed_id: The ID of the datafeed to create - :arg body: The datafeed config - :arg allow_no_indices: Ignore if the source indices expressions - resolves to no concrete indices (default: true) - :arg expand_wildcards: Whether source index expressions should - get expanded to open or closed indices (default: open) Valid choices: - open, closed, hidden, none, all - :arg ignore_throttled: Ignore indices that are marked as - throttled (default: true) - :arg ignore_unavailable: Ignore unavailable indexes (default: - false) - """ - client, params = _deprecated_options(self, params) - for param in (datafeed_id, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "PUT", - _make_path("_ml", "datafeeds", datafeed_id), - params=params, - headers=headers, - body=body, - ) - - @query_params() - def put_filter(self, filter_id, body, params=None, headers=None): + ``_ + + :param datafeed_id: A numerical character string that uniquely identifies the + datafeed. This identifier can contain lowercase alphanumeric characters (a-z + and 0-9), hyphens, and underscores. It must start and end with alphanumeric + characters. + :param aggregations: If set, the datafeed performs aggregation searches. Support + for aggregations is limited and should be used only with low cardinality + data. + :param allow_no_indices: Ignore if the source indices expressions resolves to + no concrete indices (default: true) + :param chunking_config: Datafeeds might be required to search over long time + periods, for several months or years. This search is split into time chunks + in order to ensure the load on Elasticsearch is managed. Chunking configuration + controls how the size of these time chunks are calculated; it is an advanced + configuration option. + :param delayed_data_check_config: Specifies whether the datafeed checks for missing + data and the size of the window. The datafeed can optionally search over + indices that have already been read in an effort to determine whether any + data has subsequently been added to the index. If missing data is found, + it is a good indication that the `query_delay` is set too low and the data + is being indexed after the datafeed has passed that moment in time. This + check runs only on real-time datafeeds. + :param expand_wildcards: Whether source index expressions should get expanded + to open or closed indices (default: open) + :param frequency: The interval at which scheduled queries are made while the + datafeed runs in real time. The default value is either the bucket span for + short bucket spans, or, for longer bucket spans, a sensible fraction of the + bucket span. When `frequency` is shorter than the bucket span, interim results + for the last (partial) bucket are written then eventually overwritten by + the full bucket results. If the datafeed uses aggregations, this value must + be divisible by the interval of the date histogram aggregation. + :param ignore_throttled: Ignore indices that are marked as throttled (default: + true) + :param ignore_unavailable: Ignore unavailable indexes (default: false) + :param indices: An array of index names. Wildcards are supported. If any of the + indices are in remote clusters, the machine learning nodes must have the + `remote_cluster_client` role. + :param indices_options: Specifies index expansion options that are used during + search + :param job_id: Identifier for the anomaly detection job. + :param max_empty_searches: If a real-time datafeed has never seen any data (including + during any initial training period), it automatically stops and closes the + associated job after this many real-time searches return no documents. In + other words, it stops after `frequency` times `max_empty_searches` of real-time + operation. If not set, a datafeed with no end time that sees no data remains + started until it is explicitly stopped. By default, it is not set. + :param query: The Elasticsearch query domain-specific language (DSL). This value + corresponds to the query object in an Elasticsearch search POST body. All + the options that are supported by Elasticsearch can be used, as this object + is passed verbatim to Elasticsearch. + :param query_delay: The number of seconds behind real time that data is queried. + For example, if data from 10:04 a.m. might not be searchable in Elasticsearch + until 10:06 a.m., set this property to 120 seconds. The default value is + randomly selected between `60s` and `120s`. This randomness improves the + query performance when there are multiple jobs running on the same node. + :param runtime_mappings: Specifies runtime fields for the datafeed search. + :param script_fields: Specifies scripts that evaluate custom expressions and + returns script fields to the datafeed. The detector configuration objects + in a job can contain functions that use these script fields. + :param scroll_size: The size parameter that is used in Elasticsearch searches + when the datafeed does not use aggregations. The maximum value is the value + of `index.max_result_window`, which is 10,000 by default. + """ + if datafeed_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'datafeed_id'") + __path = f"/_ml/datafeeds/{_quote(datafeed_id)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if aggregations is not None: + __body["aggregations"] = aggregations + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if chunking_config is not None: + __body["chunking_config"] = chunking_config + if delayed_data_check_config is not None: + __body["delayed_data_check_config"] = delayed_data_check_config + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if frequency is not None: + __body["frequency"] = frequency + if human is not None: + __query["human"] = human + if ignore_throttled is not None: + __query["ignore_throttled"] = ignore_throttled + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if indices is not None: + __body["indices"] = indices + if indices_options is not None: + __body["indices_options"] = indices_options + if job_id is not None: + __body["job_id"] = job_id + if max_empty_searches is not None: + __body["max_empty_searches"] = max_empty_searches + if pretty is not None: + __query["pretty"] = pretty + if query is not None: + __body["query"] = query + if query_delay is not None: + __body["query_delay"] = query_delay + if runtime_mappings is not None: + __body["runtime_mappings"] = runtime_mappings + if script_fields is not None: + __body["script_fields"] = script_fields + if scroll_size is not None: + __body["scroll_size"] = scroll_size + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("PUT", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, + ) + def put_filter( + self, + *, + filter_id: Any, + description: Optional[str] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + items: Optional[List[str]] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Instantiates a filter. - ``_ + ``_ - :arg filter_id: The ID of the filter to create - :arg body: The filter details + :param filter_id: A string that uniquely identifies a filter. + :param description: A description of the filter. + :param items: The items of the filter. A wildcard `*` can be used at the beginning + or the end of an item. Up to 10000 items are allowed in each filter. """ - client, params = _deprecated_options(self, params) - for param in (filter_id, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "PUT", - _make_path("_ml", "filters", filter_id), - params=params, - headers=headers, - body=body, - ) - - @query_params( - "allow_no_indices", "expand_wildcards", "ignore_throttled", "ignore_unavailable" + if filter_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'filter_id'") + __path = f"/_ml/filters/{_quote(filter_id)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if description is not None: + __body["description"] = description + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if items is not None: + __body["items"] = items + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("PUT", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, ) - def put_job(self, job_id, body, params=None, headers=None): + def put_job( + self, + *, + job_id: Any, + analysis_config: Any, + background_persist_interval: Any, + data_description: Any, + allow_lazy_open: Optional[bool] = None, + analysis_limits: Optional[Any] = None, + custom_settings: Optional[Any] = None, + daily_model_snapshot_retention_after_days: Optional[int] = None, + datafeed_config: Optional[Any] = None, + description: Optional[str] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + groups: Optional[List[str]] = None, + human: Optional[bool] = None, + model_plot_config: Optional[Any] = None, + model_snapshot_retention_days: Optional[int] = None, + pretty: Optional[bool] = None, + renormalization_window_days: Optional[int] = None, + results_index_name: Optional[Any] = None, + results_retention_days: Optional[int] = None, + ) -> Any: """ Instantiates an anomaly detection job. - ``_ - - :arg job_id: The ID of the job to create - :arg body: The job - :arg allow_no_indices: Ignore if the source indices expressions - resolves to no concrete indices (default: true). Only set if - datafeed_config is provided. - :arg expand_wildcards: Whether source index expressions should - get expanded to open or closed indices (default: open). Only set if - datafeed_config is provided. Valid choices: open, closed, hidden, none, - all - :arg ignore_throttled: Ignore indices that are marked as - throttled (default: true). Only set if datafeed_config is provided. - :arg ignore_unavailable: Ignore unavailable indexes (default: - false). Only set if datafeed_config is provided. - """ - client, params = _deprecated_options(self, params) - for param in (job_id, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "PUT", - _make_path("_ml", "anomaly_detectors", job_id), - params=params, - headers=headers, - body=body, - ) - - @query_params("enabled", "timeout") - 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 + ``_ + + :param job_id: The identifier for the anomaly detection job. This identifier + can contain lowercase alphanumeric characters (a-z and 0-9), hyphens, and + underscores. It must start and end with alphanumeric characters. + :param analysis_config: Specifies how to analyze the data. After you create a + job, you cannot change the analysis configuration; all the properties are + informational. + :param background_persist_interval: Advanced configuration option. The time between + each periodic persistence of the model. The default value is a randomized + value between 3 to 4 hours, which avoids all jobs persisting at exactly the + same time. The smallest allowed value is 1 hour. For very large models (several + GB), persistence could take 10-20 minutes, so do not set the `background_persist_interval` + value too low. + :param data_description: Defines the format of the input data when you send data + to the job by using the post data API. Note that when configure a datafeed, + these properties are automatically set. When data is received via the post + data API, it is not stored in Elasticsearch. Only the results for anomaly + detection are retained. + :param allow_lazy_open: Advanced configuration option. Specifies whether this + job can open when there is insufficient machine learning node capacity for + it to be immediately assigned to a node. By default, if a machine learning + node with capacity to run the job cannot immediately be found, the open anomaly + detection jobs API returns an error. However, this is also subject to the + cluster-wide `xpack.ml.max_lazy_ml_nodes` setting. If this option is set + to true, the open anomaly detection jobs API does not return an error and + the job waits in the opening state until sufficient machine learning node + capacity is available. + :param analysis_limits: Limits can be applied for the resources required to hold + the mathematical models in memory. These limits are approximate and can be + set per job. They do not control the memory used by other processes, for + example the Elasticsearch Java processes. + :param custom_settings: Advanced configuration option. Contains custom meta data + about the job. + :param daily_model_snapshot_retention_after_days: Advanced configuration option, + which affects the automatic removal of old model snapshots for this job. + It specifies a period of time (in days) after which only the first snapshot + per day is retained. This period is relative to the timestamp of the most + recent snapshot for this job. Valid values range from 0 to `model_snapshot_retention_days`. + :param datafeed_config: Defines a datafeed for the anomaly detection job. If + Elasticsearch security features are enabled, your datafeed remembers which + roles the user who created it had at the time of creation and runs the query + using those same roles. If you provide secondary authorization headers, those + credentials are used instead. + :param description: A description of the job. + :param groups: A list of job groups. A job can belong to no groups or many. + :param model_plot_config: This advanced configuration option stores model information + along with the results. It provides a more detailed view into anomaly detection. + If you enable model plot it can add considerable overhead to the performance + of the system; it is not feasible for jobs with many entities. Model plot + provides a simplified and indicative view of the model and its bounds. It + does not display complex features such as multivariate correlations or multimodal + data. As such, anomalies may occasionally be reported which cannot be seen + in the model plot. Model plot config can be configured when the job is created + or updated later. It must be disabled if performance issues are experienced. + :param model_snapshot_retention_days: Advanced configuration option, which affects + the automatic removal of old model snapshots for this job. It specifies the + maximum period of time (in days) that snapshots are retained. This period + is relative to the timestamp of the most recent snapshot for this job. By + default, snapshots ten days older than the newest snapshot are deleted. + :param renormalization_window_days: Advanced configuration option. The period + over which adjustments to the score are applied, as new data is seen. The + default value is the longer of 30 days or 100 bucket spans. + :param results_index_name: A text string that affects the name of the machine + learning results index. By default, the job generates an index named `.ml-anomalies-shared`. + :param results_retention_days: Advanced configuration option. The period of time + (in days) that results are retained. Age is calculated relative to the timestamp + of the latest bucket result. If this property has a non-null value, once + per day at 00:30 (server time), results that are the specified number of + days older than the latest bucket result are deleted from Elasticsearch. + The default value is null, which means all results are retained. Annotations + generated by the system also count as results for retention purposes; they + are deleted after the same number of days as results. Annotations added by + users are retained forever. """ - client, params = _deprecated_options(self, params) - return client._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): - """ - Starts one or more datafeeds. - - ``_ - - :arg datafeed_id: The ID of the datafeed to start - :arg body: The start datafeed parameters - :arg end: The end time when the datafeed should stop. When not - set, the datafeed continues in real time - :arg start: The start time from where the datafeed should begin - :arg timeout: Controls the time to wait until a datafeed has - started. Default to 20 seconds - """ - client, params = _deprecated_options(self, params) - if datafeed_id in SKIP_IN_PATH: - raise ValueError( - "Empty value passed for a required argument 'datafeed_id'." - ) - - return client._perform_request( - "POST", - _make_path("_ml", "datafeeds", datafeed_id, "_start"), - params=params, - headers=headers, - body=body, - ) - - @query_params("allow_no_datafeeds", "allow_no_match", "force", "timeout") - def stop_datafeed(self, datafeed_id, body=None, params=None, headers=None): - """ - Stops one or more datafeeds. - - ``_ - - :arg datafeed_id: The ID of the datafeed to stop - :arg body: The URL params optionally sent in the body - :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) - :arg allow_no_match: Whether to ignore if a wildcard expression - matches no datafeeds. (This includes `_all` string or when no datafeeds - have been specified) - :arg force: True if the datafeed should be forcefully stopped. - :arg timeout: Controls the time to wait until a datafeed has - stopped. Default to 20 seconds - """ - client, params = _deprecated_options(self, params) - if datafeed_id in SKIP_IN_PATH: + if job_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'job_id'") + if analysis_config is None: + raise ValueError("Empty value passed for parameter 'analysis_config'") + if background_persist_interval is None: raise ValueError( - "Empty value passed for a required argument 'datafeed_id'." + "Empty value passed for parameter 'background_persist_interval'" ) - - return client._perform_request( - "POST", - _make_path("_ml", "datafeeds", datafeed_id, "_stop"), - params=params, - headers=headers, - body=body, - ) - - @query_params( - "allow_no_indices", "expand_wildcards", "ignore_throttled", "ignore_unavailable" + if data_description is None: + raise ValueError("Empty value passed for parameter 'data_description'") + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if analysis_config is not None: + __body["analysis_config"] = analysis_config + if background_persist_interval is not None: + __body["background_persist_interval"] = background_persist_interval + if data_description is not None: + __body["data_description"] = data_description + if allow_lazy_open is not None: + __body["allow_lazy_open"] = allow_lazy_open + if analysis_limits is not None: + __body["analysis_limits"] = analysis_limits + if custom_settings is not None: + __body["custom_settings"] = custom_settings + if daily_model_snapshot_retention_after_days is not None: + __body[ + "daily_model_snapshot_retention_after_days" + ] = daily_model_snapshot_retention_after_days + if datafeed_config is not None: + __body["datafeed_config"] = datafeed_config + if description is not None: + __body["description"] = description + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if groups is not None: + __body["groups"] = groups + if human is not None: + __query["human"] = human + if model_plot_config is not None: + __body["model_plot_config"] = model_plot_config + if model_snapshot_retention_days is not None: + __body["model_snapshot_retention_days"] = model_snapshot_retention_days + if pretty is not None: + __query["pretty"] = pretty + if renormalization_window_days is not None: + __body["renormalization_window_days"] = renormalization_window_days + if results_index_name is not None: + __body["results_index_name"] = results_index_name + if results_retention_days is not None: + __body["results_retention_days"] = results_retention_days + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("PUT", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, ) - 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 - :arg allow_no_indices: Ignore if the source indices expressions - resolves to no concrete indices (default: true) - :arg expand_wildcards: Whether source index expressions should - get expanded to open or closed indices (default: open) Valid choices: - open, closed, hidden, none, all - :arg ignore_throttled: Ignore indices that are marked as - throttled (default: true) - :arg ignore_unavailable: Ignore unavailable indexes (default: - false) - """ - client, params = _deprecated_options(self, params) - for param in (datafeed_id, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "POST", - _make_path("_ml", "datafeeds", datafeed_id, "_update"), - params=params, - headers=headers, - body=body, - ) - - @query_params() - def update_filter(self, filter_id, body, params=None, headers=None): + def put_trained_model( + self, + *, + model_id: Any, + inference_config: Any, + input: Any, + compressed_definition: Optional[str] = None, + definition: Optional[Any] = None, + description: Optional[str] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + metadata: Optional[Any] = None, + pretty: Optional[bool] = None, + tags: Optional[List[str]] = None, + ) -> Any: """ - Updates the description of a filter, adds items, or removes items. - - ``_ + Creates an inference trained model. - :arg filter_id: The ID of the filter to update - :arg body: The filter update + ``_ + + :param model_id: The unique identifier of the trained model. + :param inference_config: The default configuration for inference. This can be + either a regression or classification configuration. It must match the underlying + definition.trained_model's target_type. + :param input: The input field names for the model definition. + :param compressed_definition: The compressed (GZipped and Base64 encoded) inference + definition of the model. If compressed_definition is specified, then definition + cannot be specified. + :param definition: The inference definition for the model. If definition is specified, + then compressed_definition cannot be specified. + :param description: A human-readable description of the inference trained model. + :param metadata: An object map that contains metadata about the model. + :param tags: An array of tags to organize the model. """ - client, params = _deprecated_options(self, params) - for param in (filter_id, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "POST", - _make_path("_ml", "filters", filter_id, "_update"), - params=params, - headers=headers, - body=body, - ) - - @query_params() - def update_job(self, job_id, body, params=None, headers=None): + if model_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'model_id'") + if inference_config is None: + raise ValueError("Empty value passed for parameter 'inference_config'") + if input is None: + raise ValueError("Empty value passed for parameter 'input'") + __path = f"/_ml/trained_models/{_quote(model_id)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if inference_config is not None: + __body["inference_config"] = inference_config + if input is not None: + __body["input"] = input + if compressed_definition is not None: + __body["compressed_definition"] = compressed_definition + if definition is not None: + __body["definition"] = definition + if description is not None: + __body["description"] = description + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if metadata is not None: + __body["metadata"] = metadata + if pretty is not None: + __query["pretty"] = pretty + if tags is not None: + __body["tags"] = tags + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("PUT", __target, headers=__headers, body=__body) + + @_rewrite_parameters() + def put_trained_model_alias( + self, + *, + model_id: Any, + model_alias: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + reassign: Optional[bool] = None, + ) -> Any: + """ + Creates a new model alias (or reassigns an existing one) to refer to the trained + model + + ``_ + + :param model_id: The identifier for the trained model that the alias refers to. + :param model_alias: The alias to create or update. This value cannot end in numbers. + :param reassign: Specifies whether the alias gets reassigned to the specified + trained model if it is already assigned to a different model. If the alias + is already assigned and this parameter is false, the API returns an error. """ - Updates certain properties of an anomaly detection job. - - ``_ - - :arg job_id: The ID of the job to create - :arg body: The job update settings + if model_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'model_id'") + if model_alias in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'model_alias'") + __path = f"/_ml/trained_models/{_quote(model_id)}/model_aliases/{_quote(model_alias)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if reassign is not None: + __query["reassign"] = reassign + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("PUT", __target, headers=__headers) + + @_rewrite_parameters() + def reset_job( + self, + *, + job_id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + wait_for_completion: Optional[bool] = None, + ) -> Any: """ - client, params = _deprecated_options(self, params) - for param in (job_id, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") + Resets an existing anomaly detection job. - return client._perform_request( - "POST", - _make_path("_ml", "anomaly_detectors", job_id, "_update"), - params=params, - headers=headers, - body=body, - ) + ``_ - @query_params() - def validate(self, body, params=None, headers=None): + :param job_id: The ID of the job to reset. + :param wait_for_completion: Should this request wait until the operation has + completed before returning. """ - Validates an anomaly detection job. - - ``_ - - :arg body: The job config + if job_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'job_id'") + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}/_reset" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if wait_for_completion is not None: + __query["wait_for_completion"] = wait_for_completion + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + def revert_model_snapshot( + self, + *, + job_id: Any, + snapshot_id: Any, + delete_intervening_results: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") + Reverts to a specific snapshot. - return client._perform_request( - "POST", - "/_ml/anomaly_detectors/_validate", - params=params, - headers=headers, - body=body, - ) + ``_ - @query_params() - def validate_detector(self, body, params=None, headers=None): + :param job_id: Identifier for the anomaly detection job. + :param snapshot_id: You can specify `empty` as the . Reverting to + the empty snapshot means the anomaly detection job starts learning a new + model from scratch when it is started. + :param delete_intervening_results: If true, deletes the results in the time period + between the latest results and the time of the reverted snapshot. It also + resets the model to accept records for this time period. If you choose not + to delete intervening results when reverting a snapshot, the job will not + accept input data that is older than the current time. If you want to resend + data, then delete the intervening results. """ - Validates an anomaly detection detector. - - ``_ - - :arg body: The detector + if job_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'job_id'") + if snapshot_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'snapshot_id'") + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}/model_snapshots/{_quote(snapshot_id)}/_revert" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if delete_intervening_results is not None: + __body["delete_intervening_results"] = delete_intervening_results + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters() + def set_upgrade_mode( + self, + *, + enabled: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return client._perform_request( - "POST", - "/_ml/anomaly_detectors/_validate/detector", - params=params, - headers=headers, - body=body, - ) + Sets a cluster wide upgrade_mode setting that prepares machine learning indices + for an upgrade. - @query_params("force", "timeout") - def delete_data_frame_analytics(self, id, params=None, headers=None): + ``_ + + :param enabled: When `true`, it enables `upgrade_mode` which temporarily halts + all job and datafeed tasks and prohibits new job and datafeed tasks from + starting. + :param timeout: The time to wait for the request to be completed. + """ + __path = "/_ml/set_upgrade_mode" + __query: Dict[str, Any] = {} + if enabled is not None: + __query["enabled"] = enabled + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters() + def start_data_frame_analytics( + self, + *, + id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ - Deletes an existing data frame analytics job. + Starts a 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 - :arg timeout: Controls the time to wait until a job is deleted. - Defaults to 1 minute + :param id: Identifier for the data frame analytics job. This identifier can contain + lowercase alphanumeric characters (a-z and 0-9), hyphens, and underscores. + It must start and end with alphanumeric characters. + :param timeout: Controls the amount of time to wait until the data frame analytics + job starts. """ - client, params = _deprecated_options(self, params) if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'id'.") - - return client._perform_request( - "DELETE", - _make_path("_ml", "data_frame", "analytics", id), - params=params, - headers=headers, - ) - - @query_params() - def evaluate_data_frame(self, body, params=None, headers=None): - """ - Evaluates the data frame analytics for an annotated index. - - ``_ - - :arg body: The evaluation definition - """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return client._perform_request( - "POST", - "/_ml/data_frame/_evaluate", - params=params, - headers=headers, - body=body, - ) - - @query_params("allow_no_match", "exclude_generated", "from_", "size") - 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 exclude_generated: Omits fields that are illegal to set on - data frame analytics PUT - :arg from\\_: skips a number of analytics - :arg size: specifies a max number of analytics to get Default: - 100 - """ - client, params = _deprecated_options(self, params) - if params and "from_" in params: - params["from"] = params.pop("from_") - - return client._perform_request( - "GET", - _make_path("_ml", "data_frame", "analytics", id), - params=params, - headers=headers, - ) - - @query_params("allow_no_match", "from_", "size", "verbose") - 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 size: specifies a max number of analytics to get Default: - 100 - :arg verbose: whether the stats response should be verbose - """ - client, params = _deprecated_options(self, params) - if params and "from_" in params: - params["from"] = params.pop("from_") - - return client._perform_request( - "GET", - _make_path("_ml", "data_frame", "analytics", id, "_stats"), - params=params, - headers=headers, - ) - - @query_params() - 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 - """ - client, params = _deprecated_options(self, params) - for param in (id, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "PUT", - _make_path("_ml", "data_frame", "analytics", id), - params=params, - headers=headers, - body=body, - ) - - @query_params("timeout") - def start_data_frame_analytics(self, id, body=None, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/_ml/data_frame/analytics/{_quote(id)}/_start" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + def start_datafeed( + self, + *, + datafeed_id: Any, + end: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + start: Optional[Any] = None, + timeout: Optional[Any] = None, + ) -> Any: """ - Starts a data frame analytics job. + Starts one or more datafeeds. - ``_ + ``_ - :arg id: The ID of the data frame analytics to start - :arg body: The start data frame analytics parameters - :arg timeout: Controls the time to wait until the task has - started. Defaults to 20 seconds + :param datafeed_id: A numerical character string that uniquely identifies the + datafeed. This identifier can contain lowercase alphanumeric characters (a-z + and 0-9), hyphens, and underscores. It must start and end with alphanumeric + characters. + :param end: Refer to the description for the `end` query parameter. + :param start: Refer to the description for the `start` query parameter. + :param timeout: Refer to the description for the `timeout` query parameter. """ - client, params = _deprecated_options(self, params) - if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'id'.") - - return client._perform_request( - "POST", - _make_path("_ml", "data_frame", "analytics", id, "_start"), - params=params, - headers=headers, - body=body, - ) - - @query_params("allow_no_match", "force", "timeout") - def stop_data_frame_analytics(self, id, body=None, params=None, headers=None): + if datafeed_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'datafeed_id'") + __path = f"/_ml/datafeeds/{_quote(datafeed_id)}/_start" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if end is not None: + __body["end"] = end + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if start is not None: + __body["start"] = start + if timeout is not None: + __body["timeout"] = timeout + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters() + def stop_data_frame_analytics( + self, + *, + id: Any, + allow_no_match: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + force: Optional[bool] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ 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 - :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) - :arg force: True if the data frame analytics should be - forcefully stopped - :arg timeout: Controls the time to wait until the task has - stopped. Defaults to 20 seconds + ``_ + + :param id: Identifier for the data frame analytics job. This identifier can contain + lowercase alphanumeric characters (a-z and 0-9), hyphens, and underscores. + It must start and end with alphanumeric characters. + :param allow_no_match: Specifies what to do when the request: 1. Contains wildcard + expressions and there are no data frame analytics jobs that match. 2. Contains + the _all string or no identifiers and there are no matches. 3. Contains wildcard + expressions and there are only partial matches. The default value is true, + which returns an empty data_frame_analytics array when there are no matches + and the subset of results when there are partial matches. If this parameter + is false, the request returns a 404 status code when there are no matches + or only partial matches. + :param force: If true, the data frame analytics job is stopped forcefully. + :param timeout: Controls the amount of time to wait until the data frame analytics + job stops. Defaults to 20 seconds. """ - client, params = _deprecated_options(self, params) if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'id'.") - - return client._perform_request( - "POST", - _make_path("_ml", "data_frame", "analytics", id, "_stop"), - params=params, - headers=headers, - body=body, - ) - - @query_params("timeout") - 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 - :arg timeout: Controls the amount of time to wait for the model - to be deleted. Default: 30s - """ - client, params = _deprecated_options(self, params) - if model_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'model_id'.") - - return client._perform_request( - "DELETE", - _make_path("_ml", "trained_models", model_id), - params=params, - headers=headers, - ) - - @query_params( - "allow_no_match", - "decompress_definition", - "exclude_generated", - "from_", - "include", - "include_model_definition", - "size", - "tags", + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/_ml/data_frame/analytics/{_quote(id)}/_stop" + __query: Dict[str, Any] = {} + if allow_no_match is not None: + __query["allow_no_match"] = allow_no_match + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if force is not None: + __query["force"] = force + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, ) - 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 - matches no trained models. (This includes `_all` string or when no - trained models have been specified) Default: True - :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 exclude_generated: Omits fields that are illegal to set on - model PUT - :arg from\\_: skips a number of trained models - :arg include: A comma-separate list of fields to optionally - include. Valid options are 'definition' and 'total_feature_importance'. - Default is none. - :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. - :arg size: specifies a max number of trained models to get - Default: 100 - :arg tags: A comma-separated list of tags that the model must - have. - """ - client, params = _deprecated_options(self, params) - if params and "from_" in params: - params["from"] = params.pop("from_") - - return client._perform_request( - "GET", - _make_path("_ml", "trained_models", model_id), - params=params, - headers=headers, - ) - - @query_params("allow_no_match", "from_", "size") - 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 size: specifies a max number of trained models to get - Default: 100 - """ - client, params = _deprecated_options(self, params) - if params and "from_" in params: - params["from"] = params.pop("from_") - - return client._perform_request( - "GET", - _make_path("_ml", "trained_models", model_id, "_stats"), - params=params, - headers=headers, - ) - - @query_params("defer_definition_decompression") - 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 - :arg defer_definition_decompression: If set to `true` and a - `compressed_definition` is provided, the request defers definition - decompression and skips relevant validations. - """ - client, params = _deprecated_options(self, params) - for param in (model_id, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "PUT", - _make_path("_ml", "trained_models", model_id), - params=params, - headers=headers, - body=body, - ) - - @query_params() - def estimate_model_memory(self, body, params=None, headers=None): + def stop_datafeed( + self, + *, + datafeed_id: Any, + allow_no_match: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + force: Optional[bool] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ - Estimates the model memory + Stops one or more datafeeds. - ``_ + ``_ - :arg body: The analysis config, plus cardinality estimates for - fields it references + :param datafeed_id: Identifier for the datafeed. You can stop multiple datafeeds + in a single API request by using a comma-separated list of datafeeds or a + wildcard expression. You can close all datafeeds by using `_all` or by specifying + `*` as the identifier. + :param allow_no_match: Refer to the description for the `allow_no_match` query + parameter. + :param force: Refer to the description for the `force` query parameter. + :param timeout: Refer to the description for the `timeout` query parameter. """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return client._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 - ): + if datafeed_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'datafeed_id'") + __path = f"/_ml/datafeeds/{_quote(datafeed_id)}/_stop" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if allow_no_match is not None: + __body["allow_no_match"] = allow_no_match + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if force is not None: + __body["force"] = force + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __body["timeout"] = timeout + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, + ) + def update_data_frame_analytics( + self, + *, + id: Any, + allow_lazy_start: Optional[bool] = None, + description: Optional[str] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + max_num_threads: Optional[int] = None, + model_memory_limit: Optional[str] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Explains a data frame analytics config. - - ``_ + Updates certain properties of a data frame analytics job. - :arg body: The data frame analytics config to explain - :arg id: The ID of the data frame analytics to explain + ``_ + + :param id: Identifier for the data frame analytics job. This identifier can contain + lowercase alphanumeric characters (a-z and 0-9), hyphens, and underscores. + It must start and end with alphanumeric characters. + :param allow_lazy_start: Specifies whether this job can start when there is insufficient + machine learning node capacity for it to be immediately assigned to a node. + :param description: A description of the job. + :param max_num_threads: The maximum number of threads to be used by the analysis. + Using more threads may decrease the time necessary to complete the analysis + at the cost of using more CPU. Note that the process may use additional threads + for operational functionality other than the analysis itself. + :param model_memory_limit: The approximate maximum amount of memory resources + that are permitted for analytical processing. The default value for data + frame analytics jobs is 1gb. If your elasticsearch.yml file contains an `xpack.ml.max_model_memory_limit` + setting, an error occurs when you try to create data frame analytics jobs + that have model_memory_limit values greater than that setting. """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "POST", - _make_path("_ml", "data_frame", "analytics", id, "_explain"), - params=params, - headers=headers, - body=body, - ) - - @query_params("from_", "partition_field_value", "size") - def get_categories( - self, job_id, body=None, category_id=None, params=None, headers=None - ): + if id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/_ml/data_frame/analytics/{_quote(id)}/_update" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if allow_lazy_start is not None: + __body["allow_lazy_start"] = allow_lazy_start + if description is not None: + __body["description"] = description + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if max_num_threads is not None: + __body["max_num_threads"] = max_num_threads + if model_memory_limit is not None: + __body["model_memory_limit"] = model_memory_limit + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, + ) + def update_filter( + self, + *, + filter_id: Any, + add_items: Optional[List[str]] = None, + description: Optional[str] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + remove_items: Optional[List[str]] = None, + ) -> Any: """ - Retrieves anomaly detection job results for one or more categories. + Updates the description of a filter, adds items, or removes items. - ``_ + ``_ - :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 partition_field_value: Specifies the partition to retrieve - categories for. This is optional, and should never be used for jobs - where per-partition categorization is disabled. - :arg size: specifies a max number of categories to get + :param filter_id: A string that uniquely identifies a filter. + :param add_items: The items to add to the filter. + :param description: A description for the filter. + :param remove_items: The items to remove from the filter. """ - client, params = _deprecated_options(self, params) - if params and "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 client._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 - ): + if filter_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'filter_id'") + __path = f"/_ml/filters/{_quote(filter_id)}/_update" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if add_items is not None: + __body["add_items"] = add_items + if description is not None: + __body["description"] = description + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if remove_items is not None: + __body["remove_items"] = remove_items + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, + ) + def update_job( + self, + *, + job_id: Any, + allow_lazy_open: Optional[bool] = None, + analysis_limits: Optional[Any] = None, + background_persist_interval: Optional[Any] = None, + categorization_filters: Optional[List[str]] = None, + custom_settings: Optional[Dict[str, Any]] = None, + daily_model_snapshot_retention_after_days: Optional[int] = None, + description: Optional[str] = None, + detectors: Optional[List[Any]] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + groups: Optional[List[str]] = None, + human: Optional[bool] = None, + model_plot_config: Optional[Any] = None, + model_snapshot_retention_days: Optional[int] = None, + per_partition_categorization: Optional[Any] = None, + pretty: Optional[bool] = None, + renormalization_window_days: Optional[int] = None, + results_retention_days: Optional[int] = None, + ) -> Any: """ - Retrieves information about model snapshots. - - ``_ + Updates certain properties of an anomaly detection job. - :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 + ``_ + + :param job_id: Identifier for the job. + :param allow_lazy_open: Advanced configuration option. Specifies whether this + job can open when there is insufficient machine learning node capacity for + it to be immediately assigned to a node. If `false` and a machine learning + node with capacity to run the job cannot immediately be found, the open anomaly + detection jobs API returns an error. However, this is also subject to the + cluster-wide `xpack.ml.max_lazy_ml_nodes` setting. If this option is set + to `true`, the open anomaly detection jobs API does not return an error and + the job waits in the opening state until sufficient machine learning node + capacity is available. + :param analysis_limits: + :param background_persist_interval: Advanced configuration option. The time between + each periodic persistence of the model. The default value is a randomized + value between 3 to 4 hours, which avoids all jobs persisting at exactly the + same time. The smallest allowed value is 1 hour. For very large models (several + GB), persistence could take 10-20 minutes, so do not set the value too low. + If the job is open when you make the update, you must stop the datafeed, + close the job, then reopen the job and restart the datafeed for the changes + to take effect. + :param categorization_filters: + :param custom_settings: Advanced configuration option. Contains custom meta data + about the job. For example, it can contain custom URL information as shown + in Adding custom URLs to machine learning results. + :param daily_model_snapshot_retention_after_days: Advanced configuration option, + which affects the automatic removal of old model snapshots for this job. + It specifies a period of time (in days) after which only the first snapshot + per day is retained. This period is relative to the timestamp of the most + recent snapshot for this job. Valid values range from 0 to `model_snapshot_retention_days`. + For jobs created before version 7.8.0, the default value matches `model_snapshot_retention_days`. + :param description: A description of the job. + :param detectors: An array of detector update objects. + :param groups: A list of job groups. A job can belong to no groups or many. + :param model_plot_config: + :param model_snapshot_retention_days: Advanced configuration option, which affects + the automatic removal of old model snapshots for this job. It specifies the + maximum period of time (in days) that snapshots are retained. This period + is relative to the timestamp of the most recent snapshot for this job. + :param per_partition_categorization: Settings related to how categorization interacts + with partition fields. + :param renormalization_window_days: Advanced configuration option. The period + over which adjustments to the score are applied, as new data is seen. + :param results_retention_days: Advanced configuration option. The period of time + (in days) that results are retained. Age is calculated relative to the timestamp + of the latest bucket result. If this property has a non-null value, once + per day at 00:30 (server time), results that are the specified number of + days older than the latest bucket result are deleted from Elasticsearch. + The default value is null, which means all results are retained. """ - client, params = _deprecated_options(self, params) - if params and "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 client._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? - """ - client, params = _deprecated_options(self, params) - for param in (job_id, snapshot_id): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "POST", - _make_path( - "_ml", - "anomaly_detectors", - job_id, - "model_snapshots", - snapshot_id, - "_revert", - ), - params=params, - headers=headers, - body=body, - ) - - @query_params() + raise ValueError("Empty value passed for parameter 'job_id'") + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}/_update" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if allow_lazy_open is not None: + __body["allow_lazy_open"] = allow_lazy_open + if analysis_limits is not None: + __body["analysis_limits"] = analysis_limits + if background_persist_interval is not None: + __body["background_persist_interval"] = background_persist_interval + if categorization_filters is not None: + __body["categorization_filters"] = categorization_filters + if custom_settings is not None: + __body["custom_settings"] = custom_settings + if daily_model_snapshot_retention_after_days is not None: + __body[ + "daily_model_snapshot_retention_after_days" + ] = daily_model_snapshot_retention_after_days + if description is not None: + __body["description"] = description + if detectors is not None: + __body["detectors"] = detectors + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if groups is not None: + __body["groups"] = groups + if human is not None: + __query["human"] = human + if model_plot_config is not None: + __body["model_plot_config"] = model_plot_config + if model_snapshot_retention_days is not None: + __body["model_snapshot_retention_days"] = model_snapshot_retention_days + if per_partition_categorization is not None: + __body["per_partition_categorization"] = per_partition_categorization + if pretty is not None: + __query["pretty"] = pretty + if renormalization_window_days is not None: + __body["renormalization_window_days"] = renormalization_window_days + if results_retention_days is not None: + __body["results_retention_days"] = results_retention_days + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, + ) def update_model_snapshot( - self, job_id, snapshot_id, body, params=None, headers=None - ): + self, + *, + job_id: Any, + snapshot_id: Any, + description: Optional[str] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + retain: Optional[bool] = None, + ) -> Any: """ 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 - """ - client, params = _deprecated_options(self, params) - for param in (job_id, snapshot_id, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "POST", - _make_path( - "_ml", - "anomaly_detectors", - job_id, - "model_snapshots", - snapshot_id, - "_update", - ), - params=params, - headers=headers, - body=body, - ) - - @query_params() - def update_data_frame_analytics(self, id, body, params=None, headers=None): - """ - Updates certain properties of a data frame analytics job. - - ``_ + ``_ - :arg id: The ID of the data frame analytics to update - :arg body: The data frame analytics settings to update + :param job_id: Identifier for the anomaly detection job. + :param snapshot_id: Identifier for the model snapshot. + :param description: A description of the model snapshot. + :param retain: If `true`, this snapshot will not be deleted during automatic + cleanup of snapshots older than `model_snapshot_retention_days`. However, + this snapshot will be deleted when the job is deleted. """ - client, params = _deprecated_options(self, params) - for param in (id, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "POST", - _make_path("_ml", "data_frame", "analytics", id, "_update"), - params=params, - headers=headers, - body=body, - ) - - @query_params("timeout", "wait_for_completion") - def upgrade_job_snapshot(self, job_id, snapshot_id, params=None, headers=None): + if job_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'job_id'") + if snapshot_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'snapshot_id'") + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}/model_snapshots/{_quote(snapshot_id)}/_update" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if description is not None: + __body["description"] = description + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if retain is not None: + __body["retain"] = retain + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters() + def upgrade_job_snapshot( + self, + *, + job_id: Any, + snapshot_id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + wait_for_completion: Optional[bool] = None, + ) -> Any: """ Upgrades a given job snapshot to the current major version. - ``_ - - :arg job_id: The ID of the job - :arg snapshot_id: The ID of the snapshot - :arg timeout: How long should the API wait for the job to be - opened and the old snapshot to be loaded. - :arg wait_for_completion: Should the request wait until the task - is complete before responding to the caller. Default is false. - """ - client, params = _deprecated_options(self, params) - for param in (job_id, snapshot_id): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "POST", - _make_path( - "_ml", - "anomaly_detectors", - job_id, - "model_snapshots", - snapshot_id, - "_upgrade", - ), - params=params, - headers=headers, - ) - - @query_params() - def delete_trained_model_alias( - self, model_id, model_alias, params=None, headers=None - ): - """ - Deletes a model alias that refers to the trained model - - ``_ - - :arg model_id: The trained model where the model alias is - assigned - :arg model_alias: The trained model alias to delete - """ - client, params = _deprecated_options(self, params) - for param in (model_id, model_alias): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "DELETE", - _make_path("_ml", "trained_models", model_id, "model_aliases", model_alias), - params=params, - headers=headers, - ) - - @query_params("reassign") - def put_trained_model_alias(self, model_id, model_alias, params=None, headers=None): - """ - Creates a new model alias (or reassigns an existing one) to refer to the - trained model - - ``_ - - :arg model_id: The trained model where the model alias should be - assigned - :arg model_alias: The trained model alias to update - :arg reassign: If the model_alias already exists and points to a - separate model_id, this parameter must be true. Defaults to false. - """ - client, params = _deprecated_options(self, params) - for param in (model_id, model_alias): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "PUT", - _make_path("_ml", "trained_models", model_id, "model_aliases", model_alias), - params=params, - headers=headers, - ) - - @query_params() - def preview_data_frame_analytics( - self, body=None, id=None, params=None, headers=None - ): - """ - Previews that will be analyzed given a data frame analytics config. - - ``_ + ``_ - :arg body: The data frame analytics config to preview - :arg id: The ID of the data frame analytics to preview + :param job_id: Identifier for the anomaly detection job. + :param snapshot_id: A numerical character string that uniquely identifies the + model snapshot. + :param timeout: Controls the time to wait for the request to complete. + :param wait_for_completion: When true, the API won’t respond until the upgrade + is complete. Otherwise, it responds as soon as the upgrade task is assigned + to a node. """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "POST", - _make_path("_ml", "data_frame", "analytics", id, "_preview"), - params=params, - headers=headers, - body=body, - ) - - @query_params("timeout") - def infer_trained_model_deployment(self, model_id, body, params=None, headers=None): - """ - Evaluate a trained model. - - ``_ - - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - - :arg model_id: The unique identifier of the trained model. - :arg body: The docs to apply inference on - :arg timeout: Controls the amount of time to wait for inference - results. Default: 10s - """ - client, params = _deprecated_options(self, params) - for param in (model_id, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "POST", - _make_path("_ml", "trained_models", model_id, "deployment", "_infer"), - params=params, - headers=headers, - body=body, - ) - - @query_params("wait_for_completion") - def reset_job(self, job_id, params=None, headers=None): - """ - Resets an existing anomaly detection job. - - ``_ - - :arg job_id: The ID of the job to reset - :arg wait_for_completion: Should this request wait until the - operation has completed before returning Default: True - """ - client, params = _deprecated_options(self, params) if job_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'job_id'.") - - return client._perform_request( - "POST", - _make_path("_ml", "anomaly_detectors", job_id, "_reset"), - params=params, - headers=headers, - ) - - @query_params("timeout", "wait_for") - def start_trained_model_deployment(self, model_id, params=None, headers=None): - """ - Start a trained model deployment. - - ``_ - - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - - :arg model_id: The unique identifier of the trained model. - :arg timeout: Controls the amount of time to wait for the model - to deploy. Default: 20s - :arg wait_for: The allocation status for which to wait Valid - choices: starting, started, fully_allocated Default: started - """ - client, params = _deprecated_options(self, params) - if model_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'model_id'.") - - return client._perform_request( - "POST", - _make_path("_ml", "trained_models", model_id, "deployment", "_start"), - params=params, - headers=headers, - ) - - @query_params() - def stop_trained_model_deployment(self, model_id, params=None, headers=None): - """ - Stop a trained model deployment. - - ``_ - - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - - :arg model_id: The unique identifier of the trained model. - """ - client, params = _deprecated_options(self, params) - if model_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'model_id'.") - - return client._perform_request( - "POST", - _make_path("_ml", "trained_models", model_id, "deployment", "_stop"), - params=params, - headers=headers, - ) - - @query_params() - def get_trained_model_deployment_stats(self, model_id, params=None, headers=None): - """ - Get information about trained model deployments. - - ``_ - - :arg model_id: The ID of the trained model deployment stats to - fetch - """ - client, params = _deprecated_options(self, params) - if model_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'model_id'.") - - return client._perform_request( - "GET", - _make_path("_ml", "trained_models", model_id, "deployment", "_stats"), - params=params, - headers=headers, - ) - - @query_params() - def put_trained_model_definition_part( - self, model_id, part, body, params=None, headers=None - ): - """ - Creates part of a trained model definition - - ``_ - - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - - :arg model_id: The ID of the trained model for this definition - part - :arg part: The part number - :arg body: The trained model definition part + raise ValueError("Empty value passed for parameter 'job_id'") + if snapshot_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'snapshot_id'") + __path = f"/_ml/anomaly_detectors/{_quote(job_id)}/model_snapshots/{_quote(snapshot_id)}/_upgrade" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if wait_for_completion is not None: + __query["wait_for_completion"] = wait_for_completion + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + def validate( + self, + *, + analysis_config: Optional[Any] = None, + analysis_limits: Optional[Any] = None, + data_description: Optional[Any] = None, + description: Optional[str] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + job_id: Optional[Any] = None, + model_plot: Optional[Any] = None, + model_snapshot_retention_days: Optional[int] = None, + pretty: Optional[bool] = None, + results_index_name: Optional[Any] = None, + ) -> Any: """ - client, params = _deprecated_options(self, params) - for param in (model_id, part, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") + Validates an anomaly detection job. - return client._perform_request( - "PUT", - _make_path("_ml", "trained_models", model_id, "definition", part), - params=params, - headers=headers, - body=body, - ) + ``_ - @query_params() - def put_trained_model_vocabulary(self, model_id, body, params=None, headers=None): + :param analysis_config: + :param analysis_limits: + :param data_description: + :param description: + :param job_id: + :param model_plot: + :param model_snapshot_retention_days: + :param results_index_name: + """ + __path = "/_ml/anomaly_detectors/_validate" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if analysis_config is not None: + __body["analysis_config"] = analysis_config + if analysis_limits is not None: + __body["analysis_limits"] = analysis_limits + if data_description is not None: + __body["data_description"] = data_description + if description is not None: + __body["description"] = description + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if job_id is not None: + __body["job_id"] = job_id + if model_plot is not None: + __body["model_plot"] = model_plot + if model_snapshot_retention_days is not None: + __body["model_snapshot_retention_days"] = model_snapshot_retention_days + if pretty is not None: + __query["pretty"] = pretty + if results_index_name is not None: + __body["results_index_name"] = results_index_name + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_name="detector", + ) + def validate_detector( + self, + *, + detector: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Creates a trained model vocabulary - - ``_ - - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version + Validates an anomaly detection detector. - :arg model_id: The ID of the trained model for this vocabulary - :arg body: The trained model vocabulary - """ - client, params = _deprecated_options(self, params) - for param in (model_id, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") + ``_ - return client._perform_request( - "PUT", - _make_path("_ml", "trained_models", model_id, "vocabulary"), - params=params, - headers=headers, - body=body, - ) + :param detector: + """ + if detector is None: + raise ValueError("Empty value passed for parameter 'detector'") + __path = "/_ml/anomaly_detectors/_validate/detector" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + __body = detector + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("POST", __target, headers=__headers, body=__body) diff --git a/elasticsearch/_sync/client/ml.pyi b/elasticsearch/_sync/client/ml.pyi deleted file mode 100644 index 19021ef2e..000000000 --- a/elasticsearch/_sync/client/ml.pyi +++ /dev/null @@ -1,1398 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class MlClient(NamespacedClient): - def close_job( - self, - job_id: Any, - *, - body: Optional[Any] = ..., - allow_no_jobs: Optional[Any] = ..., - allow_no_match: Optional[Any] = ..., - force: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def delete_calendar( - self, - calendar_id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def delete_calendar_event( - self, - calendar_id: Any, - event_id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def delete_calendar_job( - self, - calendar_id: Any, - job_id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def delete_datafeed( - self, - datafeed_id: Any, - *, - force: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def delete_expired_data( - self, - *, - body: Optional[Any] = ..., - job_id: Optional[Any] = ..., - requests_per_second: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def delete_filter( - self, - filter_id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def delete_forecast( - self, - job_id: Any, - *, - forecast_id: Optional[Any] = ..., - allow_no_forecasts: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def delete_job( - self, - job_id: Any, - *, - force: Optional[Any] = ..., - wait_for_completion: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def delete_model_snapshot( - self, - job_id: Any, - snapshot_id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def flush_job( - self, - job_id: Any, - *, - body: Optional[Any] = ..., - advance_time: Optional[Any] = ..., - calc_interim: Optional[Any] = ..., - end: Optional[Any] = ..., - skip_time: Optional[Any] = ..., - start: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def forecast( - self, - job_id: Any, - *, - duration: Optional[Any] = ..., - expires_in: Optional[Any] = ..., - max_model_memory: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_buckets( - self, - job_id: Any, - *, - body: Optional[Any] = ..., - timestamp: Optional[Any] = ..., - anomaly_score: Optional[Any] = ..., - desc: Optional[Any] = ..., - end: Optional[Any] = ..., - exclude_interim: Optional[Any] = ..., - expand: Optional[Any] = ..., - from_: Optional[Any] = ..., - size: Optional[Any] = ..., - sort: Optional[Any] = ..., - start: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_calendar_events( - self, - calendar_id: Any, - *, - end: Optional[Any] = ..., - from_: Optional[Any] = ..., - job_id: Optional[Any] = ..., - size: Optional[Any] = ..., - start: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_calendars( - self, - *, - body: Optional[Any] = ..., - calendar_id: Optional[Any] = ..., - from_: Optional[Any] = ..., - size: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_datafeed_stats( - self, - *, - datafeed_id: Optional[Any] = ..., - allow_no_datafeeds: Optional[Any] = ..., - allow_no_match: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_datafeeds( - self, - *, - datafeed_id: Optional[Any] = ..., - allow_no_datafeeds: Optional[Any] = ..., - allow_no_match: Optional[Any] = ..., - exclude_generated: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_filters( - self, - *, - filter_id: Optional[Any] = ..., - from_: Optional[Any] = ..., - size: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_influencers( - self, - job_id: Any, - *, - body: Optional[Any] = ..., - desc: Optional[Any] = ..., - end: Optional[Any] = ..., - exclude_interim: Optional[Any] = ..., - from_: Optional[Any] = ..., - influencer_score: Optional[Any] = ..., - size: Optional[Any] = ..., - sort: Optional[Any] = ..., - start: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_job_stats( - self, - *, - job_id: Optional[Any] = ..., - allow_no_jobs: Optional[Any] = ..., - allow_no_match: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_jobs( - self, - *, - job_id: Optional[Any] = ..., - allow_no_jobs: Optional[Any] = ..., - allow_no_match: Optional[Any] = ..., - exclude_generated: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_overall_buckets( - self, - job_id: Any, - *, - body: Optional[Any] = ..., - allow_no_jobs: Optional[Any] = ..., - allow_no_match: Optional[Any] = ..., - bucket_span: Optional[Any] = ..., - end: Optional[Any] = ..., - exclude_interim: Optional[Any] = ..., - overall_score: Optional[Any] = ..., - start: Optional[Any] = ..., - top_n: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_records( - self, - job_id: Any, - *, - body: Optional[Any] = ..., - desc: Optional[Any] = ..., - end: Optional[Any] = ..., - exclude_interim: Optional[Any] = ..., - from_: Optional[Any] = ..., - record_score: Optional[Any] = ..., - size: Optional[Any] = ..., - sort: Optional[Any] = ..., - start: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def info( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def open_job( - self, - job_id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def post_calendar_events( - self, - calendar_id: Any, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def post_data( - self, - job_id: Any, - *, - body: Any, - reset_end: Optional[Any] = ..., - reset_start: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def preview_datafeed( - self, - *, - body: Optional[Any] = ..., - datafeed_id: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def put_calendar( - self, - calendar_id: Any, - *, - body: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def put_calendar_job( - self, - calendar_id: Any, - job_id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def put_datafeed( - self, - datafeed_id: Any, - *, - body: Any, - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - ignore_throttled: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def put_filter( - self, - filter_id: Any, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def put_job( - self, - job_id: Any, - *, - body: Any, - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - ignore_throttled: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def set_upgrade_mode( - self, - *, - enabled: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def start_datafeed( - self, - datafeed_id: Any, - *, - body: Optional[Any] = ..., - end: Optional[Any] = ..., - start: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def stop_datafeed( - self, - datafeed_id: Any, - *, - body: Optional[Any] = ..., - allow_no_datafeeds: Optional[Any] = ..., - allow_no_match: Optional[Any] = ..., - force: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def update_datafeed( - self, - datafeed_id: Any, - *, - body: Any, - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - ignore_throttled: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def update_filter( - self, - filter_id: Any, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def update_job( - self, - job_id: Any, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def validate( - self, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def validate_detector( - self, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def delete_data_frame_analytics( - self, - id: Any, - *, - force: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def evaluate_data_frame( - self, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_data_frame_analytics( - self, - *, - id: Optional[Any] = ..., - allow_no_match: Optional[Any] = ..., - exclude_generated: Optional[Any] = ..., - from_: Optional[Any] = ..., - size: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_data_frame_analytics_stats( - self, - *, - id: Optional[Any] = ..., - allow_no_match: Optional[Any] = ..., - from_: Optional[Any] = ..., - size: Optional[Any] = ..., - verbose: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def put_data_frame_analytics( - self, - id: Any, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def start_data_frame_analytics( - self, - id: Any, - *, - body: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def stop_data_frame_analytics( - self, - id: Any, - *, - body: Optional[Any] = ..., - allow_no_match: Optional[Any] = ..., - force: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def delete_trained_model( - self, - model_id: Any, - *, - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_trained_models( - self, - *, - model_id: Optional[Any] = ..., - allow_no_match: Optional[Any] = ..., - decompress_definition: Optional[Any] = ..., - exclude_generated: Optional[Any] = ..., - from_: Optional[Any] = ..., - include: Optional[Any] = ..., - include_model_definition: Optional[Any] = ..., - size: Optional[Any] = ..., - tags: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_trained_models_stats( - self, - *, - model_id: Optional[Any] = ..., - allow_no_match: Optional[Any] = ..., - from_: Optional[Any] = ..., - size: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def put_trained_model( - self, - model_id: Any, - *, - body: Any, - defer_definition_decompression: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def estimate_model_memory( - self, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def explain_data_frame_analytics( - self, - *, - body: Optional[Any] = ..., - id: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_categories( - self, - job_id: Any, - *, - body: Optional[Any] = ..., - category_id: Optional[Any] = ..., - from_: Optional[Any] = ..., - partition_field_value: Optional[Any] = ..., - size: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_model_snapshots( - self, - job_id: Any, - *, - body: Optional[Any] = ..., - snapshot_id: Optional[Any] = ..., - desc: Optional[Any] = ..., - end: Optional[Any] = ..., - from_: Optional[Any] = ..., - size: Optional[Any] = ..., - sort: Optional[Any] = ..., - start: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def revert_model_snapshot( - self, - job_id: Any, - snapshot_id: Any, - *, - body: Optional[Any] = ..., - delete_intervening_results: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def update_model_snapshot( - self, - job_id: Any, - snapshot_id: Any, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def update_data_frame_analytics( - self, - id: Any, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def upgrade_job_snapshot( - self, - job_id: Any, - snapshot_id: Any, - *, - timeout: Optional[Any] = ..., - wait_for_completion: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def delete_trained_model_alias( - self, - model_id: Any, - model_alias: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def put_trained_model_alias( - self, - model_id: Any, - model_alias: Any, - *, - reassign: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def preview_data_frame_analytics( - self, - *, - body: Optional[Any] = ..., - id: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def infer_trained_model_deployment( - self, - model_id: Any, - *, - body: Any, - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def reset_job( - self, - job_id: Any, - *, - wait_for_completion: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def start_trained_model_deployment( - self, - model_id: Any, - *, - timeout: Optional[Any] = ..., - wait_for: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def stop_trained_model_deployment( - self, - model_id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_trained_model_deployment_stats( - self, - model_id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def put_trained_model_definition_part( - self, - model_id: Any, - part: Any, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def put_trained_model_vocabulary( - self, - model_id: Any, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_sync/client/monitoring.py b/elasticsearch/_sync/client/monitoring.py index abc25f930..941b8f3ae 100644 --- a/elasticsearch/_sync/client/monitoring.py +++ b/elasticsearch/_sync/client/monitoring.py @@ -15,36 +15,69 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params +from .utils import _quote_query, _rewrite_parameters class MonitoringClient(NamespacedClient): - @query_params("interval", "system_api_version", "system_id") - def bulk(self, body, doc_type=None, params=None, headers=None): + @_rewrite_parameters( + body_name="operations", + ) + def bulk( + self, + *, + interval: Any, + operations: List[Any], + system_api_version: str, + system_id: str, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Used by the monitoring features to send monitoring data. ``_ - :arg body: The operation definition and data (action-data - pairs), separated by newlines - :arg doc_type: Default document type for items which don't - provide one - :arg interval: Collection interval (e.g., '10s' or '10000ms') of - the payload - :arg system_api_version: API Version of the monitored system - :arg system_id: Identifier of the monitored system + :param interval: Collection interval (e.g., '10s' or '10000ms') of the payload + :param operations: + :param system_api_version: + :param system_id: Identifier of the monitored system """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - headers["content-type"] = "application/x-ndjson" - return client._perform_request( - "POST", - _make_path("_monitoring", doc_type, "bulk"), - params=params, - headers=headers, - body=body, - ) + if interval is None: + raise ValueError("Empty value passed for parameter 'interval'") + if operations is None: + raise ValueError("Empty value passed for parameter 'operations'") + if system_api_version is None: + raise ValueError("Empty value passed for parameter 'system_api_version'") + if system_id is None: + raise ValueError("Empty value passed for parameter 'system_id'") + __path = "/_monitoring/bulk" + __query: Dict[str, Any] = {} + if interval is not None: + __query["interval"] = interval + if system_api_version is not None: + __query["system_api_version"] = system_api_version + if system_id is not None: + __query["system_id"] = system_id + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + __body = operations + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = { + "accept": "application/json", + "content-type": "application/x-ndjson", + } + return self._perform_request("PUT", __target, headers=__headers, body=__body) diff --git a/elasticsearch/_sync/client/monitoring.pyi b/elasticsearch/_sync/client/monitoring.pyi deleted file mode 100644 index 75035878a..000000000 --- a/elasticsearch/_sync/client/monitoring.pyi +++ /dev/null @@ -1,45 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class MonitoringClient(NamespacedClient): - def bulk( - self, - *, - body: Any, - doc_type: Optional[Any] = ..., - interval: Optional[Any] = ..., - system_api_version: Optional[Any] = ..., - system_id: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_sync/client/nodes.py b/elasticsearch/_sync/client/nodes.py index 914608fbb..2123f419b 100644 --- a/elasticsearch/_sync/client/nodes.py +++ b/elasticsearch/_sync/client/nodes.py @@ -15,242 +15,345 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params +from .utils import SKIP_IN_PATH, _quote, _quote_query, _rewrite_parameters class NodesClient(NamespacedClient): - @query_params("timeout") - def reload_secure_settings( - self, body=None, node_id=None, params=None, headers=None - ): + @_rewrite_parameters() + def hot_threads( + self, + *, + node_id: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_idle_threads: Optional[bool] = None, + interval: Optional[Any] = None, + pretty: Optional[bool] = None, + snapshots: Optional[int] = None, + thread_type: Optional[Any] = None, + threads: Optional[int] = None, + timeout: Optional[Any] = None, + ) -> Any: """ - Reloads secure settings. + Returns information about hot threads on each node in the cluster. - ``_ + ``_ - :arg body: An object containing the password for the - elasticsearch keystore - :arg node_id: A comma-separated list of node IDs to span the - reload/reinit call. Should stay empty because reloading usually involves - all cluster nodes. - :arg timeout: Explicit operation timeout + :param 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 + :param ignore_idle_threads: Don't show threads that are in known-idle places, + such as waiting on a socket select or pulling from an empty task queue (default: + true) + :param interval: The interval for the second sampling of threads + :param snapshots: Number of samples of thread stacktrace (default: 10) + :param thread_type: + :param threads: Specify the number of threads to provide information for (default: + 3) + :param timeout: Explicit operation timeout """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "POST", - _make_path("_nodes", node_id, "reload_secure_settings"), - params=params, - headers=headers, - body=body, - ) + if node_id not in SKIP_IN_PATH: + __path = f"/_nodes/{_quote(node_id)}/hot_threads" + else: + __path = "/_nodes/hot_threads" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_idle_threads is not None: + __query["ignore_idle_threads"] = ignore_idle_threads + if interval is not None: + __query["interval"] = interval + if pretty is not None: + __query["pretty"] = pretty + if snapshots is not None: + __query["snapshots"] = snapshots + if thread_type is not None: + __query["thread_type"] = thread_type + if threads is not None: + __query["threads"] = threads + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "text/plain"} + return self._perform_request("GET", __target, headers=__headers) - @query_params("flat_settings", "timeout") - def info(self, node_id=None, metric=None, params=None, headers=None): + @_rewrite_parameters() + def info( + self, + *, + node_id: Optional[Any] = None, + metric: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + flat_settings: Optional[bool] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ 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 - the node you're connecting to, leave empty to get information from all - nodes - :arg metric: A comma-separated list of metrics you wish - returned. Use `_all` to retrieve all metrics and `_none` to retrieve the - node identity without any additional metrics. Valid choices: settings, - os, process, jvm, thread_pool, transport, http, plugins, ingest, - indices, aggregations, _all, _none - :arg flat_settings: Return settings in flat format (default: - false) - :arg timeout: Explicit operation timeout + :param node_id: Comma-separated list of node IDs or names used to limit returned + information. + :param metric: Limits the information returned to the specific metrics. Supports + a comma-separated list, such as http,ingest. + :param flat_settings: If true, returns settings in flat format. + :param master_timeout: Period to wait for a connection to the master node. If + no response is received before the timeout expires, the request fails and + returns an error. + :param timeout: Period to wait for a response. If no response is received before + the timeout expires, the request fails and returns an error. """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", _make_path("_nodes", node_id, metric), params=params, headers=headers - ) + if node_id not in SKIP_IN_PATH and metric not in SKIP_IN_PATH: + __path = f"/_nodes/{_quote(node_id)}/{_quote(metric)}" + elif node_id not in SKIP_IN_PATH: + __path = f"/_nodes/{_quote(node_id)}" + elif metric not in SKIP_IN_PATH: + __path = f"/_nodes/{_quote(metric)}" + else: + __path = "/_nodes" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if flat_settings is not None: + __query["flat_settings"] = flat_settings + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) - @query_params( - "doc_type", - "ignore_idle_threads", - "interval", - "snapshots", - "sort", - "threads", - "timeout", + @_rewrite_parameters( + body_fields=True, ) - 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 - the node you're connecting to, leave empty to get information from all - nodes - :arg doc_type: The type to sample (default: cpu) Valid choices: - cpu, wait, block, mem - :arg ignore_idle_threads: Don't show threads that are in known- - idle places, such as waiting on a socket select or pulling from an empty - task queue (default: true) - :arg interval: The interval for the second sampling of threads - :arg snapshots: Number of samples of thread stacktrace (default: - 10) - :arg sort: The sort order for 'cpu' type (default: total) Valid - choices: cpu, total - :arg threads: Specify the number of threads to provide - information for (default: 3) - :arg timeout: Explicit operation timeout - """ - client, params = _deprecated_options(self, params) - if params and "doc_type" in params: - params["type"] = params.pop("doc_type") - - return client._perform_request( - "GET", - _make_path("_nodes", node_id, "hot_threads"), - params=params, - headers=headers, - ) - - @query_params("timeout") - def usage(self, node_id=None, metric=None, params=None, headers=None): + def reload_secure_settings( + self, + *, + node_id: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + secure_settings_password: Optional[Any] = None, + timeout: Optional[Any] = None, + ) -> Any: """ - Returns low-level information about REST actions usage on nodes. + Reloads secure settings. - ``_ + ``_ - :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, rest_actions - :arg timeout: Explicit operation timeout + :param node_id: A comma-separated list of node IDs to span the reload/reinit + call. Should stay empty because reloading usually involves all cluster nodes. + :param secure_settings_password: + :param timeout: Explicit operation timeout """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", - _make_path("_nodes", node_id, "usage", metric), - params=params, - headers=headers, - ) + if node_id not in SKIP_IN_PATH: + __path = f"/_nodes/{_quote(node_id)}/reload_secure_settings" + else: + __path = "/_nodes/reload_secure_settings" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if secure_settings_password is not None: + __body["secure_settings_password"] = secure_settings_password + if timeout is not None: + __query["timeout"] = timeout + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("POST", __target, headers=__headers, body=__body) - @query_params( - "completion_fields", - "fielddata_fields", - "fields", - "groups", - "include_segment_file_sizes", - "include_unloaded_segments", - "level", - "timeout", - "types", - ) + @_rewrite_parameters() def stats( - self, node_id=None, metric=None, index_metric=None, params=None, headers=None - ): + self, + *, + node_id: Optional[Any] = None, + metric: Optional[Any] = None, + index_metric: Optional[Any] = None, + completion_fields: Optional[Any] = None, + error_trace: Optional[bool] = None, + fielddata_fields: Optional[Any] = None, + fields: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + groups: Optional[bool] = None, + human: Optional[bool] = None, + include_segment_file_sizes: Optional[bool] = None, + include_unloaded_segments: Optional[bool] = None, + level: Optional[Any] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + types: Optional[List[str]] = None, + ) -> Any: """ 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, indexing_pressure - :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, bulk, shard_stats - :arg completion_fields: A comma-separated list of fields for the - `completion` index metric (supports wildcards) - :arg fielddata_fields: A comma-separated list of fields for the - `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 include_unloaded_segments: If set to true segment stats - will include stats for segments that are not currently loaded into - memory - :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 - """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", - _make_path("_nodes", node_id, "stats", metric, index_metric), - params=params, - headers=headers, - ) - - @query_params() - def clear_repositories_metering_archive( - self, node_id, max_archive_version, params=None, headers=None - ): - """ - Removes the archived repositories metering information present in the cluster. - - ``_ - - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - - :arg node_id: Comma-separated list of node IDs or names used to - limit returned information. - :arg max_archive_version: Specifies the maximum archive_version - to be cleared from the archive. + :param node_id: Comma-separated list of node IDs or names used to limit returned + information. + :param metric: Limit the information returned to the specified metrics + :param index_metric: Limit the information returned for indices metric to the + specific index metrics. It can be used only if indices (or all) metric is + specified. + :param completion_fields: Comma-separated list or wildcard expressions of fields + to include in fielddata and suggest statistics. + :param fielddata_fields: Comma-separated list or wildcard expressions of fields + to include in fielddata statistics. + :param fields: Comma-separated list or wildcard expressions of fields to include + in the statistics. + :param groups: Comma-separated list of search groups to include in the search + statistics. + :param include_segment_file_sizes: If true, the call reports the aggregated disk + usage of each one of the Lucene index files (only applies if segment stats + are requested). + :param include_unloaded_segments: If set to true segment stats will include stats + for segments that are not currently loaded into memory + :param level: Indicates whether statistics are aggregated at the cluster, index, + or shard level. + :param master_timeout: Period to wait for a connection to the master node. If + no response is received before the timeout expires, the request fails and + returns an error. + :param timeout: Period to wait for a response. If no response is received before + the timeout expires, the request fails and returns an error. + :param types: A comma-separated list of document types for the indexing index + metric. """ - client, params = _deprecated_options(self, params) - for param in (node_id, max_archive_version): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") + if ( + node_id not in SKIP_IN_PATH + and metric not in SKIP_IN_PATH + and index_metric not in SKIP_IN_PATH + ): + __path = f"/_nodes/{_quote(node_id)}/stats/{_quote(metric)}/{_quote(index_metric)}" + elif node_id not in SKIP_IN_PATH and metric not in SKIP_IN_PATH: + __path = f"/_nodes/{_quote(node_id)}/stats/{_quote(metric)}" + elif metric not in SKIP_IN_PATH and index_metric not in SKIP_IN_PATH: + __path = f"/_nodes/stats/{_quote(metric)}/{_quote(index_metric)}" + elif node_id not in SKIP_IN_PATH: + __path = f"/_nodes/{_quote(node_id)}/stats" + elif metric not in SKIP_IN_PATH: + __path = f"/_nodes/stats/{_quote(metric)}" + else: + __path = "/_nodes/stats" + __query: Dict[str, Any] = {} + if completion_fields is not None: + __query["completion_fields"] = completion_fields + if error_trace is not None: + __query["error_trace"] = error_trace + if fielddata_fields is not None: + __query["fielddata_fields"] = fielddata_fields + if fields is not None: + __query["fields"] = fields + if filter_path is not None: + __query["filter_path"] = filter_path + if groups is not None: + __query["groups"] = groups + if human is not None: + __query["human"] = human + if include_segment_file_sizes is not None: + __query["include_segment_file_sizes"] = include_segment_file_sizes + if include_unloaded_segments is not None: + __query["include_unloaded_segments"] = include_unloaded_segments + if level is not None: + __query["level"] = level + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if types is not None: + __query["types"] = types + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) - return client._perform_request( - "DELETE", - _make_path( - "_nodes", node_id, "_repositories_metering", max_archive_version - ), - params=params, - headers=headers, - ) - - @query_params() - def get_repositories_metering_info(self, node_id, params=None, headers=None): + @_rewrite_parameters() + def usage( + self, + *, + node_id: Optional[Any] = None, + metric: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ - Returns cluster repositories metering information. - - ``_ - - .. warning:: + Returns low-level information about REST actions usage on nodes. - This API is **experimental** so may include breaking changes - or be removed in a future version + ``_ - :arg node_id: A comma-separated list of node IDs or names to - limit the returned information. + :param 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 + :param metric: Limit the information returned to the specified metrics + :param timeout: Explicit operation timeout """ - client, params = _deprecated_options(self, params) - if node_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'node_id'.") - - return client._perform_request( - "GET", - _make_path("_nodes", node_id, "_repositories_metering"), - params=params, - headers=headers, - ) + if node_id not in SKIP_IN_PATH and metric not in SKIP_IN_PATH: + __path = f"/_nodes/{_quote(node_id)}/usage/{_quote(metric)}" + elif node_id not in SKIP_IN_PATH: + __path = f"/_nodes/{_quote(node_id)}/usage" + elif metric not in SKIP_IN_PATH: + __path = f"/_nodes/usage/{_quote(metric)}" + else: + __path = "/_nodes/usage" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) diff --git a/elasticsearch/_sync/client/nodes.pyi b/elasticsearch/_sync/client/nodes.pyi deleted file mode 100644 index 3a8b43ae3..000000000 --- a/elasticsearch/_sync/client/nodes.pyi +++ /dev/null @@ -1,169 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse, TextApiResponse - -from ._base import NamespacedClient - -class NodesClient(NamespacedClient): - def reload_secure_settings( - self, - *, - body: Optional[Any] = ..., - node_id: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def info( - self, - *, - node_id: Optional[Any] = ..., - metric: Optional[Any] = ..., - flat_settings: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def hot_threads( - self, - *, - node_id: Optional[Any] = ..., - doc_type: Optional[Any] = ..., - ignore_idle_threads: Optional[Any] = ..., - interval: Optional[Any] = ..., - snapshots: Optional[Any] = ..., - sort: Optional[Any] = ..., - threads: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> TextApiResponse: ... - def usage( - self, - *, - node_id: Optional[Any] = ..., - metric: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def stats( - self, - *, - node_id: Optional[Any] = ..., - metric: Optional[Any] = ..., - index_metric: Optional[Any] = ..., - completion_fields: Optional[Any] = ..., - fielddata_fields: Optional[Any] = ..., - fields: Optional[Any] = ..., - groups: Optional[Any] = ..., - include_segment_file_sizes: Optional[Any] = ..., - include_unloaded_segments: Optional[Any] = ..., - level: Optional[Any] = ..., - timeout: Optional[Any] = ..., - types: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def clear_repositories_metering_archive( - self, - node_id: Any, - max_archive_version: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_repositories_metering_info( - self, - node_id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_sync/client/rollup.py b/elasticsearch/_sync/client/rollup.py index fdf7d31d0..8f409c608 100644 --- a/elasticsearch/_sync/client/rollup.py +++ b/elasticsearch/_sync/client/rollup.py @@ -15,240 +15,421 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params +from .utils import SKIP_IN_PATH, _quote, _quote_query, _rewrite_parameters class RollupClient(NamespacedClient): - @query_params() - def delete_job(self, id, params=None, headers=None): + @_rewrite_parameters() + def delete_job( + self, + *, + id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Deletes an existing rollup job. ``_ - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - - :arg id: The ID of the job to delete + :param id: The ID of the job to delete """ - client, params = _deprecated_options(self, params) if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'id'.") - - return client._perform_request( - "DELETE", _make_path("_rollup", "job", id), params=params, headers=headers - ) - - @query_params() - def get_jobs(self, id=None, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/_rollup/job/{_quote(id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + def get_jobs( + self, + *, + id: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Retrieves the configuration, stats, and status of rollup jobs. ``_ - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - - :arg id: The ID of the job(s) to fetch. Accepts glob patterns, - or left blank for all jobs + :param id: The ID of the job(s) to fetch. Accepts glob patterns, or left blank + for all jobs """ - client, params = _deprecated_options(self, params) - return client._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): + if id not in SKIP_IN_PATH: + __path = f"/_rollup/job/{_quote(id)}" + else: + __path = "/_rollup/job" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def get_rollup_caps( + self, + *, + id: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Returns the capabilities of any rollup jobs that have been configured for a - specific index or index pattern. + Returns the capabilities of any rollup jobs that have been configured for a specific + index or index pattern. ``_ - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - - :arg id: The ID of the index to check rollup capabilities on, or - left blank for all jobs + :param id: The ID of the index to check rollup capabilities on, or left blank + for all jobs """ - client, params = _deprecated_options(self, params) - return client._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): + if id not in SKIP_IN_PATH: + __path = f"/_rollup/data/{_quote(id)}" + else: + __path = "/_rollup/data" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def get_rollup_index_caps( + self, + *, + index: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Returns the rollup capabilities of all jobs inside of a rollup index (e.g. the index where rollup data is stored). ``_ - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - - :arg index: The rollup index or index pattern to obtain rollup - capabilities from. + :param index: The rollup index or index pattern to obtain rollup capabilities + from. """ - client, params = _deprecated_options(self, params) if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'index'.") - - return client._perform_request( - "GET", _make_path(index, "_rollup", "data"), params=params, headers=headers - ) - - @query_params() - def put_job(self, id, body, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'index'") + __path = f"/{_quote(index)}/_rollup/data" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + def put_job( + self, + *, + id: Any, + cron: Optional[str] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + groups: Optional[Any] = None, + human: Optional[bool] = None, + index_pattern: Optional[str] = None, + metrics: Optional[List[Any]] = None, + page_size: Optional[int] = None, + pretty: Optional[bool] = None, + rollup_index: Optional[Any] = None, + ) -> Any: """ Creates a rollup job. ``_ - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - - :arg id: The ID of the job to create - :arg body: The job configuration + :param id: The ID of the job to create + :param cron: + :param groups: + :param index_pattern: + :param metrics: + :param page_size: + :param rollup_index: """ - client, params = _deprecated_options(self, params) - for param in (id, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") + if id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/_rollup/job/{_quote(id)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if cron is not None: + __body["cron"] = cron + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if groups is not None: + __body["groups"] = groups + if human is not None: + __query["human"] = human + if index_pattern is not None: + __body["index_pattern"] = index_pattern + if metrics is not None: + __body["metrics"] = metrics + if page_size is not None: + __body["page_size"] = page_size + if pretty is not None: + __query["pretty"] = pretty + if rollup_index is not None: + __body["rollup_index"] = rollup_index + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("PUT", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_name="config", + ) + def rollup( + self, + *, + index: Any, + rollup_index: Any, + config: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: + """ + Rollup an index - return client._perform_request( - "PUT", - _make_path("_rollup", "job", id), - params=params, - headers=headers, - body=body, - ) + ``_ - @query_params("rest_total_hits_as_int", "typed_keys") - def rollup_search(self, index, body, doc_type=None, params=None, headers=None): + :param index: The index to roll up + :param rollup_index: The name of the rollup index to create + :param config: + """ + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + if rollup_index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'rollup_index'") + if config is None: + raise ValueError("Empty value passed for parameter 'config'") + __path = f"/{_quote(index)}/_rollup/{_quote(rollup_index)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + __body = config + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, + ) + def rollup_search( + self, + *, + index: Any, + type: Optional[Any] = None, + aggregations: Optional[Dict[str, Any]] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + query: Optional[Any] = None, + rest_total_hits_as_int: Optional[bool] = None, + size: Optional[int] = None, + typed_keys: Optional[bool] = None, + ) -> Any: """ Enables searching rolled-up data using the standard query DSL. ``_ - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - - :arg index: The indices or index-pattern(s) (containing rollup - or regular data) that should be searched - :arg body: The search request body - :arg doc_type: The doc type inside the index - :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 typed_keys: Specify whether aggregation and suggester names - should be prefixed by their respective types in the response + :param index: The indices or index-pattern(s) (containing rollup or regular data) + that should be searched + :param type: The doc type inside the index + :param aggregations: + :param query: + :param rest_total_hits_as_int: Indicates whether hits.total should be rendered + as an integer or an object in the rest search response + :param size: Must be zero if set, as rollups work on pre-aggregated data + :param typed_keys: Specify whether aggregation and suggester names should be + prefixed by their respective types in the response """ - client, params = _deprecated_options(self, params) - for param in (index, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "POST", - _make_path(index, doc_type, "_rollup_search"), - params=params, - headers=headers, - body=body, - ) - - @query_params() - def start_job(self, id, params=None, headers=None): + if index in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'index'") + if index not in SKIP_IN_PATH and type not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/{_quote(type)}/_rollup_search" + elif index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_rollup_search" + else: + raise ValueError("Couldn't find a path for the given parameters") + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if aggregations is not None: + __body["aggregations"] = aggregations + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if query is not None: + __body["query"] = query + if rest_total_hits_as_int is not None: + __query["rest_total_hits_as_int"] = rest_total_hits_as_int + if size is not None: + __body["size"] = size + if typed_keys is not None: + __query["typed_keys"] = typed_keys + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters() + def start_job( + self, + *, + id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Starts an existing, stopped rollup job. ``_ - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - - :arg id: The ID of the job to start + :param id: The ID of the job to start """ - client, params = _deprecated_options(self, params) if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'id'.") - - return client._perform_request( - "POST", - _make_path("_rollup", "job", id, "_start"), - params=params, - headers=headers, - ) - - @query_params("timeout", "wait_for_completion") - def stop_job(self, id, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/_rollup/job/{_quote(id)}/_start" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters() + def stop_job( + self, + *, + id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + wait_for_completion: Optional[bool] = None, + ) -> Any: """ Stops an existing, started rollup job. ``_ - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - - :arg id: The ID of the job to stop - :arg timeout: Block for (at maximum) the specified duration - while waiting for the job to stop. Defaults to 30s. - :arg wait_for_completion: True if the API should block until the - job has fully stopped, false if should be executed async. Defaults to - false. + :param id: The ID of the job to stop + :param timeout: Block for (at maximum) the specified duration while waiting for + the job to stop. Defaults to 30s. + :param wait_for_completion: True if the API should block until the job has fully + stopped, false if should be executed async. Defaults to false. """ - client, params = _deprecated_options(self, params) if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'id'.") - - return client._perform_request( - "POST", - _make_path("_rollup", "job", id, "_stop"), - params=params, - headers=headers, - ) - - @query_params() - def rollup(self, index, rollup_index, body, params=None, headers=None): - """ - Rollup an index - - ``_ - - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - - :arg index: The index to roll up - :arg rollup_index: The name of the rollup index to create - :arg body: The rollup configuration - """ - client, params = _deprecated_options(self, params) - for param in (index, rollup_index, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "POST", - _make_path(index, "_rollup", rollup_index), - params=params, - headers=headers, - body=body, - ) + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/_rollup/job/{_quote(id)}/_stop" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if wait_for_completion is not None: + __query["wait_for_completion"] = wait_for_completion + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) diff --git a/elasticsearch/_sync/client/rollup.pyi b/elasticsearch/_sync/client/rollup.pyi deleted file mode 100644 index 948daee6d..000000000 --- a/elasticsearch/_sync/client/rollup.pyi +++ /dev/null @@ -1,186 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class RollupClient(NamespacedClient): - def delete_job( - self, - id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_jobs( - self, - *, - id: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_rollup_caps( - self, - *, - id: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_rollup_index_caps( - self, - index: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def put_job( - self, - id: Any, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def rollup_search( - self, - index: Any, - *, - body: Any, - doc_type: Optional[Any] = ..., - rest_total_hits_as_int: Optional[Any] = ..., - typed_keys: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def start_job( - self, - id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def stop_job( - self, - id: Any, - *, - timeout: Optional[Any] = ..., - wait_for_completion: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def rollup( - self, - index: Any, - rollup_index: Any, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_sync/client/searchable_snapshots.py b/elasticsearch/_sync/client/searchable_snapshots.py index 92675db9b..ac05da5a5 100644 --- a/elasticsearch/_sync/client/searchable_snapshots.py +++ b/elasticsearch/_sync/client/searchable_snapshots.py @@ -15,114 +15,179 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params +from .utils import SKIP_IN_PATH, _quote, _quote_query, _rewrite_parameters class SearchableSnapshotsClient(NamespacedClient): - @query_params("allow_no_indices", "expand_wildcards", "ignore_unavailable") - def clear_cache(self, index=None, params=None, headers=None): + @_rewrite_parameters() + def clear_cache( + self, + *, + index: Optional[Any] = None, + allow_no_indices: Optional[bool] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Clear the cache of searchable snapshots. ``_ - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - - :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, none, all Default: open - :arg ignore_unavailable: Whether specified concrete indices - should be ignored when unavailable (missing or closed) + :param index: A comma-separated list of index names + :param 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) + :param expand_wildcards: Whether to expand wildcard expression to concrete indices + that are open, closed or both. + :param ignore_unavailable: Whether specified concrete indices should be ignored + when unavailable (missing or closed) """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "POST", - _make_path(index, "_searchable_snapshots", "cache", "clear"), - params=params, - headers=headers, - ) - - @query_params("master_timeout", "storage", "wait_for_completion") - def mount(self, repository, snapshot, body, params=None, headers=None): + if index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_searchable_snapshots/cache/clear" + else: + __path = "/_searchable_snapshots/cache/clear" + __query: Dict[str, Any] = {} + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + def mount( + self, + *, + repository: Any, + snapshot: Any, + index: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_index_settings: Optional[List[str]] = None, + index_settings: Optional[Dict[str, Any]] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + renamed_index: Optional[Any] = None, + storage: Optional[str] = None, + wait_for_completion: Optional[bool] = None, + ) -> Any: """ Mount a snapshot as a searchable index. ``_ - :arg repository: The name of the repository containing the - snapshot of the index to mount - :arg snapshot: The name of the snapshot of the index to mount - :arg body: The restore configuration for mounting the snapshot - as searchable - :arg master_timeout: Explicit operation timeout for connection - to master node - :arg storage: Selects the kind of local storage used to - accelerate searches. Experimental, and defaults to `full_copy` - :arg wait_for_completion: Should this request wait until the - operation has completed before returning + :param repository: The name of the repository containing the snapshot of the + index to mount + :param snapshot: The name of the snapshot of the index to mount + :param index: + :param ignore_index_settings: + :param index_settings: + :param master_timeout: Explicit operation timeout for connection to master node + :param renamed_index: + :param storage: Selects the kind of local storage used to accelerate searches. + Experimental, and defaults to `full_copy` + :param wait_for_completion: Should this request wait until the operation has + completed before returning """ - client, params = _deprecated_options(self, params) - for param in (repository, snapshot, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "POST", - _make_path("_snapshot", repository, snapshot, "_mount"), - params=params, - headers=headers, - body=body, - ) - - @query_params("level") - def stats(self, index=None, params=None, headers=None): + if repository in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'repository'") + if snapshot in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'snapshot'") + if index is None: + raise ValueError("Empty value passed for parameter 'index'") + __path = f"/_snapshot/{_quote(repository)}/{_quote(snapshot)}/_mount" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if index is not None: + __body["index"] = index + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_index_settings is not None: + __body["ignore_index_settings"] = ignore_index_settings + if index_settings is not None: + __body["index_settings"] = index_settings + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if renamed_index is not None: + __body["renamed_index"] = renamed_index + if storage is not None: + __query["storage"] = storage + if wait_for_completion is not None: + __query["wait_for_completion"] = wait_for_completion + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters() + def stats( + self, + *, + index: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + level: Optional[Any] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Retrieve shard-level statistics about searchable snapshots. ``_ - :arg index: A comma-separated list of index names - :arg level: Return stats aggregated at cluster, index or shard - level Valid choices: cluster, indices, shards Default: indices - """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", - _make_path(index, "_searchable_snapshots", "stats"), - params=params, - headers=headers, - ) - - @query_params() - def cache_stats(self, node_id=None, params=None, headers=None): - """ - Retrieve node-level cache statistics about searchable snapshots. - - ``_ - - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - - :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 + :param index: A comma-separated list of index names + :param level: Return stats aggregated at cluster, index or shard level """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", - _make_path("_searchable_snapshots", node_id, "cache", "stats"), - params=params, - headers=headers, - ) + if index not in SKIP_IN_PATH: + __path = f"/{_quote(index)}/_searchable_snapshots/stats" + else: + __path = "/_searchable_snapshots/stats" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if level is not None: + __query["level"] = level + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) diff --git a/elasticsearch/_sync/client/searchable_snapshots.pyi b/elasticsearch/_sync/client/searchable_snapshots.pyi deleted file mode 100644 index 6007dc2e9..000000000 --- a/elasticsearch/_sync/client/searchable_snapshots.pyi +++ /dev/null @@ -1,101 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class SearchableSnapshotsClient(NamespacedClient): - def clear_cache( - self, - *, - index: Optional[Any] = ..., - allow_no_indices: Optional[Any] = ..., - expand_wildcards: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def mount( - self, - repository: Any, - snapshot: Any, - *, - body: Any, - master_timeout: Optional[Any] = ..., - storage: Optional[Any] = ..., - wait_for_completion: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def stats( - self, - *, - index: Optional[Any] = ..., - level: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def cache_stats( - self, - *, - node_id: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_sync/client/security.py b/elasticsearch/_sync/client/security.py index b0f9bf47c..8408d11ad 100644 --- a/elasticsearch/_sync/client/security.py +++ b/elasticsearch/_sync/client/security.py @@ -15,918 +15,1622 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params +from .utils import SKIP_IN_PATH, _quote, _quote_query, _rewrite_parameters class SecurityClient(NamespacedClient): - @query_params() - def authenticate(self, params=None, headers=None): - """ - Enables authentication as a user and retrieve information about the - authenticated user. - - ``_ - """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", "/_security/_authenticate", params=params, headers=headers - ) - - @query_params("refresh") - def change_password(self, body, username=None, params=None, headers=None): + @_rewrite_parameters() + def authenticate( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: + """ + Enables authentication as a user and retrieve information about the authenticated + user. + + ``_ + """ + __path = "/_security/_authenticate" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + def change_password( + self, + *, + username: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + password: Optional[Any] = None, + pretty: Optional[bool] = None, + refresh: Optional[Any] = None, + ) -> Any: """ 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 - for - :arg refresh: If `true` (the default) then refresh the affected - shards to make this operation visible to search, if `wait_for` then wait - for a refresh to make this operation visible to search, if `false` then - do nothing with refreshes. Valid choices: true, false, wait_for + ``_ + + :param username: The username of the user to change the password for + :param password: + :param refresh: If `true` (the default) then refresh the affected shards to make + this operation visible to search, if `wait_for` then wait for a refresh to + make this operation visible to search, if `false` then do nothing with refreshes. + """ + if username not in SKIP_IN_PATH: + __path = f"/_security/user/{_quote(username)}/_password" + else: + __path = "/_security/user/_password" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if password is not None: + __body["password"] = password + if pretty is not None: + __query["pretty"] = pretty + if refresh is not None: + __query["refresh"] = refresh + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("PUT", __target, headers=__headers, body=__body) + + @_rewrite_parameters() + def clear_api_key_cache( + self, + *, + ids: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") + Clear a subset or all entries from the API key cache. - return client._perform_request( - "PUT", - _make_path("_security", "user", username, "_password"), - params=params, - headers=headers, - body=body, - ) + ``_ - @query_params("usernames") - def clear_cached_realms(self, realms, params=None, headers=None): + :param ids: A comma-separated list of IDs of API keys to clear from the cache + """ + if ids in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'ids'") + __path = f"/_security/api_key/{_quote(ids)}/_clear_cache" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters() + def clear_cached_privileges( + self, + *, + application: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Evicts users from the user cache. Can completely clear the cache or evict - specific users. + Evicts application privileges from the native application privileges cache. - ``_ + ``_ - :arg realms: Comma-separated list of realms to clear - :arg usernames: Comma-separated list of usernames to clear from - the cache + :param application: A comma-separated list of application names + """ + if application in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'application'") + __path = f"/_security/privilege/{_quote(application)}/_clear_cache" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters() + def clear_cached_realms( + self, + *, + realms: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + usernames: Optional[List[str]] = None, + ) -> Any: + """ + Evicts users from the user cache. Can completely clear the cache or evict specific + users. + + ``_ + + :param realms: Comma-separated list of realms to clear + :param usernames: Comma-separated list of usernames to clear from the cache """ - client, params = _deprecated_options(self, params) if realms in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'realms'.") - - return client._perform_request( - "POST", - _make_path("_security", "realm", realms, "_clear_cache"), - params=params, - headers=headers, - ) - - @query_params() - def clear_cached_roles(self, name, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'realms'") + __path = f"/_security/realm/{_quote(realms)}/_clear_cache" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if usernames is not None: + __query["usernames"] = usernames + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters() + def clear_cached_roles( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Evicts roles from the native role cache. - ``_ + ``_ - :arg name: Role name + :param name: Role name """ - client, params = _deprecated_options(self, params) if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'name'.") - - return client._perform_request( - "POST", - _make_path("_security", "role", name, "_clear_cache"), - params=params, - headers=headers, - ) - - @query_params("refresh") - def create_api_key(self, body, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_security/role/{_quote(name)}/_clear_cache" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters() + def clear_cached_service_tokens( + self, + *, + namespace: Any, + service: Any, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Creates an API key for access without requiring basic authentication. + Evicts tokens from the service account token caches. - ``_ + ``_ - :arg body: The api key request to create an API key - :arg refresh: If `true` (the default) then refresh the affected - shards to make this operation visible to search, if `wait_for` then wait - for a refresh to make this operation visible to search, if `false` then - do nothing with refreshes. Valid choices: true, false, wait_for + :param namespace: An identifier for the namespace + :param service: An identifier for the service name + :param name: A comma-separated list of service token names """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return client._perform_request( - "PUT", "/_security/api_key", params=params, headers=headers, body=body - ) + if namespace in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'namespace'") + if service in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'service'") + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_security/service/{_quote(namespace)}/{_quote(service)}/credential/token/{_quote(name)}/_clear_cache" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + def create_api_key( + self, + *, + error_trace: Optional[bool] = None, + expiration: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + metadata: Optional[Any] = None, + name: Optional[Any] = None, + pretty: Optional[bool] = None, + refresh: Optional[Any] = None, + role_descriptors: Optional[Dict[str, Any]] = None, + ) -> Any: + """ + Creates an API key for access without requiring basic authentication. - @query_params("refresh") - def delete_privileges(self, application, name, params=None, headers=None): + ``_ + + :param expiration: Expiration time for the API key. By default, API keys never + expire. + :param metadata: Arbitrary metadata that you want to associate with the API key. + It supports nested data structure. Within the metadata object, keys beginning + with _ are reserved for system usage. + :param name: Specifies the name for this API key. + :param refresh: If `true` (the default) then refresh the affected shards to make + this operation visible to search, if `wait_for` then wait for a refresh to + make this operation visible to search, if `false` then do nothing with refreshes. + :param role_descriptors: An array of role descriptors for this API key. This + parameter is optional. When it is not specified or is an empty array, then + the API key will have a point in time snapshot of permissions of the authenticated + user. If you supply role descriptors then the resultant permissions would + be an intersection of API keys permissions and authenticated user’s permissions + thereby limiting the access scope for API keys. The structure of role descriptor + is the same as the request for create role API. For more details, see create + or update roles API. + """ + __path = "/_security/api_key" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if expiration is not None: + __body["expiration"] = expiration + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if metadata is not None: + __body["metadata"] = metadata + if name is not None: + __body["name"] = name + if pretty is not None: + __query["pretty"] = pretty + if refresh is not None: + __query["refresh"] = refresh + if role_descriptors is not None: + __body["role_descriptors"] = role_descriptors + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("PUT", __target, headers=__headers, body=__body) + + @_rewrite_parameters() + def create_service_token( + self, + *, + namespace: Any, + service: Any, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: + """ + Creates a service account token for access without requiring basic authentication. + + ``_ + + :param namespace: An identifier for the namespace + :param service: An identifier for the service name + :param name: An identifier for the token name + """ + if namespace in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'namespace'") + if service in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'service'") + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + if ( + namespace not in SKIP_IN_PATH + and service not in SKIP_IN_PATH + and name not in SKIP_IN_PATH + ): + __path = f"/_security/service/{_quote(namespace)}/{_quote(service)}/credential/token/{_quote(name)}" + __method = "PUT" + elif namespace not in SKIP_IN_PATH and service not in SKIP_IN_PATH: + __path = f"/_security/service/{_quote(namespace)}/{_quote(service)}/credential/token" + __method = "POST" + else: + raise ValueError("Couldn't find a path for the given parameters") + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request(__method, __target, headers=__headers) + + @_rewrite_parameters() + def delete_privileges( + self, + *, + application: Any, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + refresh: Optional[Any] = None, + ) -> Any: """ Removes application privileges. - ``_ + ``_ - :arg application: Application name - :arg name: Privilege name - :arg refresh: If `true` (the default) then refresh the affected - shards to make this operation visible to search, if `wait_for` then wait - for a refresh to make this operation visible to search, if `false` then - do nothing with refreshes. Valid choices: true, false, wait_for + :param application: Application name + :param name: Privilege name + :param refresh: If `true` (the default) then refresh the affected shards to make + this operation visible to search, if `wait_for` then wait for a refresh to + make this operation visible to search, if `false` then do nothing with refreshes. """ - client, params = _deprecated_options(self, params) - for param in (application, name): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "DELETE", - _make_path("_security", "privilege", application, name), - params=params, - headers=headers, - ) - - @query_params("refresh") - def delete_role(self, name, params=None, headers=None): + if application in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'application'") + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_security/privilege/{_quote(application)}/{_quote(name)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if refresh is not None: + __query["refresh"] = refresh + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + def delete_role( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + refresh: Optional[Any] = None, + ) -> Any: """ Removes roles in the native realm. - ``_ + ``_ - :arg name: Role name - :arg refresh: If `true` (the default) then refresh the affected - shards to make this operation visible to search, if `wait_for` then wait - for a refresh to make this operation visible to search, if `false` then - do nothing with refreshes. Valid choices: true, false, wait_for + :param name: Role name + :param refresh: If `true` (the default) then refresh the affected shards to make + this operation visible to search, if `wait_for` then wait for a refresh to + make this operation visible to search, if `false` then do nothing with refreshes. """ - client, params = _deprecated_options(self, params) if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'name'.") - - return client._perform_request( - "DELETE", - _make_path("_security", "role", name), - params=params, - headers=headers, - ) - - @query_params("refresh") - def delete_role_mapping(self, name, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_security/role/{_quote(name)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if refresh is not None: + __query["refresh"] = refresh + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + def delete_role_mapping( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + refresh: Optional[Any] = None, + ) -> Any: """ Removes role mappings. - ``_ + ``_ - :arg name: Role-mapping name - :arg refresh: If `true` (the default) then refresh the affected - shards to make this operation visible to search, if `wait_for` then wait - for a refresh to make this operation visible to search, if `false` then - do nothing with refreshes. Valid choices: true, false, wait_for + :param name: Role-mapping name + :param refresh: If `true` (the default) then refresh the affected shards to make + this operation visible to search, if `wait_for` then wait for a refresh to + make this operation visible to search, if `false` then do nothing with refreshes. """ - client, params = _deprecated_options(self, params) if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'name'.") + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_security/role_mapping/{_quote(name)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if refresh is not None: + __query["refresh"] = refresh + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + def delete_service_token( + self, + *, + namespace: Any, + service: Any, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + refresh: Optional[Any] = None, + ) -> Any: + """ + Deletes a service account token. - return client._perform_request( - "DELETE", - _make_path("_security", "role_mapping", name), - params=params, - headers=headers, - ) + ``_ - @query_params("refresh") - def delete_user(self, username, params=None, headers=None): + :param namespace: An identifier for the namespace + :param service: An identifier for the service name + :param name: An identifier for the token name + :param refresh: If `true` then refresh the affected shards to make this operation + visible to search, if `wait_for` (the default) then wait for a refresh to + make this operation visible to search, if `false` then do nothing with refreshes. + """ + if namespace in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'namespace'") + if service in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'service'") + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_security/service/{_quote(namespace)}/{_quote(service)}/credential/token/{_quote(name)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if refresh is not None: + __query["refresh"] = refresh + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + def delete_user( + self, + *, + username: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + refresh: Optional[Any] = None, + ) -> Any: """ Deletes users from the native realm. - ``_ + ``_ - :arg username: username - :arg refresh: If `true` (the default) then refresh the affected - shards to make this operation visible to search, if `wait_for` then wait - for a refresh to make this operation visible to search, if `false` then - do nothing with refreshes. Valid choices: true, false, wait_for + :param username: username + :param refresh: If `true` (the default) then refresh the affected shards to make + this operation visible to search, if `wait_for` then wait for a refresh to + make this operation visible to search, if `false` then do nothing with refreshes. """ - client, params = _deprecated_options(self, params) if username in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'username'.") - - return client._perform_request( - "DELETE", - _make_path("_security", "user", username), - params=params, - headers=headers, - ) - - @query_params("refresh") - def disable_user(self, username, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'username'") + __path = f"/_security/user/{_quote(username)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if refresh is not None: + __query["refresh"] = refresh + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + def disable_user( + self, + *, + username: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + refresh: Optional[Any] = None, + ) -> Any: """ 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 - shards to make this operation visible to search, if `wait_for` then wait - for a refresh to make this operation visible to search, if `false` then - do nothing with refreshes. Valid choices: true, false, wait_for + :param username: The username of the user to disable + :param refresh: If `true` (the default) then refresh the affected shards to make + this operation visible to search, if `wait_for` then wait for a refresh to + make this operation visible to search, if `false` then do nothing with refreshes. """ - client, params = _deprecated_options(self, params) if username in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'username'.") - - return client._perform_request( - "PUT", - _make_path("_security", "user", username, "_disable"), - params=params, - headers=headers, - ) - - @query_params("refresh") - def enable_user(self, username, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'username'") + __path = f"/_security/user/{_quote(username)}/_disable" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if refresh is not None: + __query["refresh"] = refresh + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("PUT", __target, headers=__headers) + + @_rewrite_parameters() + def enable_user( + self, + *, + username: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + refresh: Optional[Any] = None, + ) -> Any: """ 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 - shards to make this operation visible to search, if `wait_for` then wait - for a refresh to make this operation visible to search, if `false` then - do nothing with refreshes. Valid choices: true, false, wait_for + :param username: The username of the user to enable + :param refresh: If `true` (the default) then refresh the affected shards to make + this operation visible to search, if `wait_for` then wait for a refresh to + make this operation visible to search, if `false` then do nothing with refreshes. """ - client, params = _deprecated_options(self, params) if username in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'username'.") - - return client._perform_request( - "PUT", - _make_path("_security", "user", username, "_enable"), - params=params, - headers=headers, - ) - - @query_params("id", "name", "owner", "realm_name", "username") - def get_api_key(self, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'username'") + __path = f"/_security/user/{_quote(username)}/_enable" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if refresh is not None: + __query["refresh"] = refresh + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("PUT", __target, headers=__headers) + + @_rewrite_parameters() + def get_api_key( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + id: Optional[Any] = None, + name: Optional[Any] = None, + owner: Optional[bool] = None, + pretty: Optional[bool] = None, + realm_name: Optional[Any] = None, + username: Optional[Any] = None, + ) -> Any: """ 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 - :arg owner: flag to query API keys owned by the currently - authenticated user - :arg realm_name: realm name of the user who created this API key - to be retrieved - :arg username: user name of the user who created this API key to - be retrieved - """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", "/_security/api_key", params=params, headers=headers - ) - - @query_params() - def get_privileges(self, application=None, name=None, params=None, headers=None): + ``_ + + :param id: API key id of the API key to be retrieved + :param name: API key name of the API key to be retrieved + :param owner: flag to query API keys owned by the currently authenticated user + :param realm_name: realm name of the user who created this API key to be retrieved + :param username: user name of the user who created this API key to be retrieved + """ + __path = "/_security/api_key" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if id is not None: + __query["id"] = id + if name is not None: + __query["name"] = name + if owner is not None: + __query["owner"] = owner + if pretty is not None: + __query["pretty"] = pretty + if realm_name is not None: + __query["realm_name"] = realm_name + if username is not None: + __query["username"] = username + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def get_builtin_privileges( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: + """ + Retrieves the list of cluster privileges and index privileges that are available + in this version of Elasticsearch. + + ``_ + """ + __path = "/_security/privilege/_builtin" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def get_privileges( + self, + *, + application: Optional[Any] = None, + name: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Retrieves application privileges. - ``_ - - :arg application: Application name - :arg name: Privilege name - """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", - _make_path("_security", "privilege", application, name), - params=params, - headers=headers, - ) - - @query_params() - def get_role(self, name=None, params=None, headers=None): + ``_ + + :param application: Application name + :param name: Privilege name + """ + if application not in SKIP_IN_PATH and name not in SKIP_IN_PATH: + __path = f"/_security/privilege/{_quote(application)}/{_quote(name)}" + elif application not in SKIP_IN_PATH: + __path = f"/_security/privilege/{_quote(application)}" + else: + __path = "/_security/privilege" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def get_role( + self, + *, + name: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Retrieves roles in the native realm. - ``_ - - :arg name: A comma-separated list of role names - """ - client, params = _deprecated_options(self, params) - return client._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): + ``_ + + :param name: A comma-separated list of role names + """ + if name not in SKIP_IN_PATH: + __path = f"/_security/role/{_quote(name)}" + else: + __path = "/_security/role" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def get_role_mapping( + self, + *, + name: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Retrieves role mappings. - ``_ - - :arg name: A comma-separated list of role-mapping names + ``_ + + :param name: A comma-separated list of role-mapping names + """ + if name not in SKIP_IN_PATH: + __path = f"/_security/role_mapping/{_quote(name)}" + else: + __path = "/_security/role_mapping" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def get_service_accounts( + self, + *, + namespace: Optional[Any] = None, + service: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", - _make_path("_security", "role_mapping", name), - params=params, - headers=headers, - ) + Retrieves information about service accounts. - @query_params() - def get_token(self, body, params=None, headers=None): + ``_ + + :param namespace: An identifier for the namespace + :param service: An identifier for the service name + """ + if namespace not in SKIP_IN_PATH and service not in SKIP_IN_PATH: + __path = f"/_security/service/{_quote(namespace)}/{_quote(service)}" + elif namespace not in SKIP_IN_PATH: + __path = f"/_security/service/{_quote(namespace)}" + else: + __path = "/_security/service" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def get_service_credentials( + self, + *, + namespace: Any, + service: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Creates a bearer token for access without requiring basic authentication. - - ``_ + Retrieves information of all service credentials for a service account. - :arg body: The token request to get + ``_ + + :param namespace: Name of the namespace. + :param service: Name of the service name. + """ + if namespace in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'namespace'") + if service in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'service'") + __path = f"/_security/service/{_quote(namespace)}/{_quote(service)}/credential" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + def get_token( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + grant_type: Optional[Any] = None, + human: Optional[bool] = None, + kerberos_ticket: Optional[str] = None, + password: Optional[Any] = None, + pretty: Optional[bool] = None, + refresh_token: Optional[str] = None, + scope: Optional[str] = None, + username: Optional[Any] = None, + ) -> Any: """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return client._perform_request( - "POST", "/_security/oauth2/token", params=params, headers=headers, body=body - ) + Creates a bearer token for access without requiring basic authentication. - @query_params() - def get_user(self, username=None, params=None, headers=None): + ``_ + + :param grant_type: + :param kerberos_ticket: + :param password: + :param refresh_token: + :param scope: + :param username: + """ + __path = "/_security/oauth2/token" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if grant_type is not None: + __body["grant_type"] = grant_type + if human is not None: + __query["human"] = human + if kerberos_ticket is not None: + __body["kerberos_ticket"] = kerberos_ticket + if password is not None: + __body["password"] = password + if pretty is not None: + __query["pretty"] = pretty + if refresh_token is not None: + __body["refresh_token"] = refresh_token + if scope is not None: + __body["scope"] = scope + if username is not None: + __body["username"] = username + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters() + def get_user( + self, + *, + username: Optional[Union[Any, List[Any]]] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Retrieves information about users in the native realm and built-in users. - ``_ - - :arg username: A comma-separated list of usernames - """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", - _make_path("_security", "user", username), - params=params, - headers=headers, - ) - - @query_params() - def get_user_privileges(self, params=None, headers=None): + ``_ + + :param username: An identifier for the user. You can specify multiple usernames + as a comma-separated list. If you omit this parameter, the API retrieves + information about all users. + """ + if username not in SKIP_IN_PATH: + __path = f"/_security/user/{_quote(username)}" + else: + __path = "/_security/user" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def get_user_privileges( + self, + *, + application: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + priviledge: Optional[Any] = None, + ) -> Any: """ Retrieves security privileges for the logged in user. - ``_ + ``_ + + :param application: The name of the application. Application privileges are always + associated with exactly one application. If you do not specify this parameter, + the API returns information about all privileges for all applications. + :param priviledge: The name of the privilege. If you do not specify this parameter, + the API returns information about all privileges for the requested application. + """ + __path = "/_security/user/_privileges" + __query: Dict[str, Any] = {} + if application is not None: + __query["application"] = application + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if priviledge is not None: + __query["priviledge"] = priviledge + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ignore_deprecated_options={"api_key"}, + ) + def grant_api_key( + self, + *, + api_key: Any, + grant_type: Any, + access_token: Optional[str] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + password: Optional[Any] = None, + pretty: Optional[bool] = None, + username: Optional[Any] = None, + ) -> Any: """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", "/_security/user/_privileges", params=params, headers=headers - ) + Creates an API key on behalf of another user. - @query_params() - def has_privileges(self, body, user=None, params=None, headers=None): + ``_ + + :param api_key: + :param grant_type: + :param access_token: + :param password: + :param username: + """ + if api_key is None: + raise ValueError("Empty value passed for parameter 'api_key'") + if grant_type is None: + raise ValueError("Empty value passed for parameter 'grant_type'") + __path = "/_security/api_key/grant" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if api_key is not None: + __body["api_key"] = api_key + if grant_type is not None: + __body["grant_type"] = grant_type + if access_token is not None: + __body["access_token"] = access_token + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if password is not None: + __body["password"] = password + if pretty is not None: + __query["pretty"] = pretty + if username is not None: + __body["username"] = username + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, + ) + def has_privileges( + self, + *, + user: Optional[Any] = None, + application: Optional[List[Any]] = None, + cluster: Optional[List[Any]] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + index: Optional[List[Any]] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Determines whether the specified user has a specified list of privileges. - ``_ - - :arg body: The privileges to test - :arg user: Username - """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return client._perform_request( - "POST", - _make_path("_security", "user", user, "_has_privileges"), - params=params, - headers=headers, - body=body, - ) - - @query_params() - def invalidate_api_key(self, body, params=None, headers=None): + ``_ + + :param user: Username + :param application: + :param cluster: + :param index: + """ + if user not in SKIP_IN_PATH: + __path = f"/_security/user/{_quote(user)}/_has_privileges" + else: + __path = "/_security/user/_has_privileges" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if application is not None: + __body["application"] = application + if cluster is not None: + __body["cluster"] = cluster + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if index is not None: + __body["index"] = index + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, + ) + def invalidate_api_key( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + id: Optional[Any] = None, + ids: Optional[List[Any]] = None, + name: Optional[Any] = None, + owner: Optional[bool] = None, + pretty: Optional[bool] = None, + realm_name: Optional[str] = None, + username: Optional[Any] = None, + ) -> Any: """ Invalidates one or more API keys. - ``_ - - :arg body: The api key request to invalidate API key(s) - """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return client._perform_request( - "DELETE", "/_security/api_key", params=params, headers=headers, body=body - ) - - @query_params() - def invalidate_token(self, body, params=None, headers=None): + ``_ + + :param id: + :param ids: + :param name: + :param owner: + :param realm_name: + :param username: + """ + __path = "/_security/api_key" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if id is not None: + __body["id"] = id + if ids is not None: + __body["ids"] = ids + if name is not None: + __body["name"] = name + if owner is not None: + __body["owner"] = owner + if pretty is not None: + __query["pretty"] = pretty + if realm_name is not None: + __body["realm_name"] = realm_name + if username is not None: + __body["username"] = username + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("DELETE", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, + ) + def invalidate_token( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + realm_name: Optional[Any] = None, + refresh_token: Optional[str] = None, + token: Optional[str] = None, + username: Optional[Any] = None, + ) -> Any: """ Invalidates one or more access tokens or refresh tokens. - ``_ - - :arg body: The token to invalidate - """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return client._perform_request( - "DELETE", - "/_security/oauth2/token", - params=params, - headers=headers, - body=body, - ) - - @query_params("refresh") - def put_privileges(self, body, params=None, headers=None): + ``_ + + :param realm_name: + :param refresh_token: + :param token: + :param username: + """ + __path = "/_security/oauth2/token" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if realm_name is not None: + __body["realm_name"] = realm_name + if refresh_token is not None: + __body["refresh_token"] = refresh_token + if token is not None: + __body["token"] = token + if username is not None: + __body["username"] = username + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("DELETE", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_name="privileges", + ) + def put_privileges( + self, + *, + privileges: Dict[str, Dict[str, Any]], + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + refresh: Optional[Any] = None, + ) -> Any: """ Adds or updates application privileges. - ``_ - - :arg body: The privilege(s) to add - :arg refresh: If `true` (the default) then refresh the affected - shards to make this operation visible to search, if `wait_for` then wait - for a refresh to make this operation visible to search, if `false` then - do nothing with refreshes. Valid choices: true, false, wait_for - """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return client._perform_request( - "PUT", "/_security/privilege/", params=params, headers=headers, body=body - ) - - @query_params("refresh") - def put_role(self, name, body, params=None, headers=None): + ``_ + + :param privileges: + :param refresh: If `true` (the default) then refresh the affected shards to make + this operation visible to search, if `wait_for` then wait for a refresh to + make this operation visible to search, if `false` then do nothing with refreshes. + """ + if privileges is None: + raise ValueError("Empty value passed for parameter 'privileges'") + __path = "/_security/privilege" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if refresh is not None: + __query["refresh"] = refresh + __body = privileges + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("PUT", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, + parameter_aliases={"global": "global_"}, + ) + def put_role( + self, + *, + name: Any, + applications: Optional[List[Any]] = None, + cluster: Optional[List[Any]] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + global_: Optional[Dict[str, Any]] = None, + human: Optional[bool] = None, + indices: Optional[List[Any]] = None, + metadata: Optional[Any] = None, + pretty: Optional[bool] = None, + refresh: Optional[Any] = None, + run_as: Optional[List[str]] = None, + transient_metadata: Optional[Any] = None, + ) -> Any: """ Adds and updates roles in the native realm. - ``_ - - :arg name: Role name - :arg body: The role to add - :arg refresh: If `true` (the default) then refresh the affected - shards to make this operation visible to search, if `wait_for` then wait - for a refresh to make this operation visible to search, if `false` then - do nothing with refreshes. Valid choices: true, false, wait_for + ``_ + + :param name: Role name + :param applications: A list of application privilege entries. + :param cluster: A list of cluster privileges. These privileges define the cluster-level + actions for users with this role. + :param global_: An object defining global privileges. A global privilege is a + form of cluster privilege that is request-aware. Support for global privileges + is currently limited to the management of application privileges. + :param indices: A list of indices permissions entries. + :param metadata: Optional metadata. Within the metadata object, keys that begin + with an underscore (`_`) are reserved for system use. + :param refresh: If `true` (the default) then refresh the affected shards to make + this operation visible to search, if `wait_for` then wait for a refresh to + make this operation visible to search, if `false` then do nothing with refreshes. + :param run_as: A list of users that the owners of this role can impersonate. + :param transient_metadata: Indicates roles that might be incompatible with the + current cluster license, specifically roles with document and field level + security. When the cluster license doesn’t allow certain features for a given + role, this parameter is updated dynamically to list the incompatible features. + If `enabled` is `false`, the role is ignored, but is still listed in the + response from the authenticate API. """ - client, params = _deprecated_options(self, params) - for param in (name, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "PUT", - _make_path("_security", "role", name), - params=params, - headers=headers, - body=body, - ) - - @query_params("refresh") - def put_role_mapping(self, name, body, params=None, headers=None): + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_security/role/{_quote(name)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if applications is not None: + __body["applications"] = applications + if cluster is not None: + __body["cluster"] = cluster + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if global_ is not None: + __body["global"] = global_ + if human is not None: + __query["human"] = human + if indices is not None: + __body["indices"] = indices + if metadata is not None: + __body["metadata"] = metadata + if pretty is not None: + __query["pretty"] = pretty + if refresh is not None: + __query["refresh"] = refresh + if run_as is not None: + __body["run_as"] = run_as + if transient_metadata is not None: + __body["transient_metadata"] = transient_metadata + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("PUT", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, + ) + def put_role_mapping( + self, + *, + name: Any, + enabled: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + metadata: Optional[Any] = None, + pretty: Optional[bool] = None, + refresh: Optional[Any] = None, + roles: Optional[List[str]] = None, + rules: Optional[Any] = None, + run_as: Optional[List[str]] = None, + ) -> Any: """ Creates and updates role mappings. - ``_ + ``_ - :arg name: Role-mapping name - :arg body: The role mapping to add - :arg refresh: If `true` (the default) then refresh the affected - shards to make this operation visible to search, if `wait_for` then wait - for a refresh to make this operation visible to search, if `false` then - do nothing with refreshes. Valid choices: true, false, wait_for + :param name: Role-mapping name + :param enabled: + :param metadata: + :param refresh: If `true` (the default) then refresh the affected shards to make + this operation visible to search, if `wait_for` then wait for a refresh to + make this operation visible to search, if `false` then do nothing with refreshes. + :param roles: + :param rules: + :param run_as: """ - client, params = _deprecated_options(self, params) - for param in (name, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "PUT", - _make_path("_security", "role_mapping", name), - params=params, - headers=headers, - body=body, - ) - - @query_params("refresh") - def put_user(self, username, body, params=None, headers=None): + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_security/role_mapping/{_quote(name)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if enabled is not None: + __body["enabled"] = enabled + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if metadata is not None: + __body["metadata"] = metadata + if pretty is not None: + __query["pretty"] = pretty + if refresh is not None: + __query["refresh"] = refresh + if roles is not None: + __body["roles"] = roles + if rules is not None: + __body["rules"] = rules + if run_as is not None: + __body["run_as"] = run_as + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("PUT", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, + ) + def put_user( + self, + *, + username: Any, + email: Optional[Union[None, str]] = None, + enabled: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + full_name: Optional[Union[None, str]] = None, + human: Optional[bool] = None, + metadata: Optional[Any] = None, + password: Optional[Any] = None, + password_hash: Optional[str] = None, + pretty: Optional[bool] = None, + refresh: Optional[Any] = None, + roles: Optional[List[str]] = None, + ) -> Any: """ 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 - :arg refresh: If `true` (the default) then refresh the affected - shards to make this operation visible to search, if `wait_for` then wait - for a refresh to make this operation visible to search, if `false` then - do nothing with refreshes. Valid choices: true, false, wait_for - """ - client, params = _deprecated_options(self, params) - for param in (username, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "PUT", - _make_path("_security", "user", username), - params=params, - headers=headers, - body=body, - ) + ``_ - @query_params() - def get_builtin_privileges(self, params=None, headers=None): + :param username: The username of the User + :param email: + :param enabled: + :param full_name: + :param metadata: + :param password: + :param password_hash: + :param refresh: If `true` (the default) then refresh the affected shards to make + this operation visible to search, if `wait_for` then wait for a refresh to + make this operation visible to search, if `false` then do nothing with refreshes. + :param roles: """ - Retrieves the list of cluster privileges and index privileges that are - available in this version of Elasticsearch. - - ``_ - """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", "/_security/privilege/_builtin", params=params, headers=headers - ) - - @query_params() - def clear_cached_privileges(self, application, params=None, headers=None): - """ - Evicts application privileges from the native application privileges cache. - - ``_ - - :arg application: A comma-separated list of application names - """ - client, params = _deprecated_options(self, params) - if application in SKIP_IN_PATH: - raise ValueError( - "Empty value passed for a required argument 'application'." - ) - - return client._perform_request( - "POST", - _make_path("_security", "privilege", application, "_clear_cache"), - params=params, - headers=headers, - ) - - @query_params() - def clear_api_key_cache(self, ids, params=None, headers=None): - """ - Clear a subset or all entries from the API key cache. - - ``_ - - :arg ids: A comma-separated list of IDs of API keys to clear - from the cache - """ - client, params = _deprecated_options(self, params) - if ids in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'ids'.") - - return client._perform_request( - "POST", - _make_path("_security", "api_key", ids, "_clear_cache"), - params=params, - headers=headers, - ) - - @query_params("refresh") - def grant_api_key(self, body, params=None, headers=None): - """ - Creates an API key on behalf of another user. - - ``_ - - :arg body: The api key request to create an API key - :arg refresh: If `true` (the default) then refresh the affected - shards to make this operation visible to search, if `wait_for` then wait - for a refresh to make this operation visible to search, if `false` then - do nothing with refreshes. Valid choices: true, false, wait_for - """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return client._perform_request( - "POST", - "/_security/api_key/grant", - params=params, - headers=headers, - body=body, - ) - - @query_params() - def clear_cached_service_tokens( - self, namespace, service, name, params=None, headers=None - ): - """ - Evicts tokens from the service account token caches. - - ``_ - - :arg namespace: An identifier for the namespace - :arg service: An identifier for the service name - :arg name: A comma-separated list of service token names - """ - client, params = _deprecated_options(self, params) - for param in (namespace, service, name): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "POST", - _make_path( - "_security", - "service", - namespace, - service, - "credential", - "token", - name, - "_clear_cache", - ), - params=params, - headers=headers, - ) - - @query_params("refresh") - def create_service_token( - self, namespace, service, name=None, params=None, headers=None - ): - """ - Creates a service account token for access without requiring basic - authentication. - - ``_ - - :arg namespace: An identifier for the namespace - :arg service: An identifier for the service name - :arg name: An identifier for the token name - :arg refresh: If `true` then refresh the affected shards to make - this operation visible to search, if `wait_for` (the default) then wait - for a refresh to make this operation visible to search, if `false` then - do nothing with refreshes. Valid choices: true, false, wait_for - """ - client, params = _deprecated_options(self, params) - for param in (namespace, service): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "PUT", - _make_path( - "_security", "service", namespace, service, "credential", "token", name - ), - params=params, - headers=headers, - ) - - @query_params("refresh") - def delete_service_token(self, namespace, service, name, params=None, headers=None): - """ - Deletes a service account token. - - ``_ - - :arg namespace: An identifier for the namespace - :arg service: An identifier for the service name - :arg name: An identifier for the token name - :arg refresh: If `true` then refresh the affected shards to make - this operation visible to search, if `wait_for` (the default) then wait - for a refresh to make this operation visible to search, if `false` then - do nothing with refreshes. Valid choices: true, false, wait_for - """ - client, params = _deprecated_options(self, params) - for param in (namespace, service, name): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "DELETE", - _make_path( - "_security", "service", namespace, service, "credential", "token", name - ), - params=params, - headers=headers, - ) - - @query_params() - def get_service_accounts( - self, namespace=None, service=None, params=None, headers=None - ): - """ - Retrieves information about service accounts. - - ``_ - - :arg namespace: An identifier for the namespace - :arg service: An identifier for the service name - """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", - _make_path("_security", "service", namespace, service), - params=params, - headers=headers, - ) - - @query_params() - def get_service_credentials(self, namespace, service, params=None, headers=None): - """ - Retrieves information of all service credentials for a service account. - - ``_ - - :arg namespace: An identifier for the namespace - :arg service: An identifier for the service name - """ - client, params = _deprecated_options(self, params) - for param in (namespace, service): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "GET", - _make_path("_security", "service", namespace, service, "credential"), - params=params, - headers=headers, - ) - - @query_params() - def enroll_node(self, params=None, headers=None): - """ - Allows a new node to enroll to an existing cluster with security enabled. - - ``_ - """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", "/_security/enroll/node", params=params, headers=headers - ) - - @query_params() - def saml_complete_logout(self, body, params=None, headers=None): - """ - Verifies the logout response sent from the SAML IdP - - ``_ - - :arg body: The logout response to verify - """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return client._perform_request( - "POST", - "/_security/saml/complete_logout", - params=params, - headers=headers, - body=body, - ) - - @query_params() - def enroll_kibana(self, params=None, headers=None): - """ - Allows a kibana instance to configure itself to communicate with a secured - elasticsearch cluster. - - ``_ - """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", "/_security/enroll/kibana", params=params, headers=headers - ) - - @query_params() - def saml_authenticate(self, body, params=None, headers=None): - """ - Exchanges a SAML Response message for an Elasticsearch access token and refresh - token pair - - ``_ - - :arg body: The SAML response to authenticate - """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return client._perform_request( - "POST", - "/_security/saml/authenticate", - params=params, - headers=headers, - body=body, - ) - - @query_params() - def saml_invalidate(self, body, params=None, headers=None): - """ - Consumes a SAML LogoutRequest - - ``_ - - :arg body: The LogoutRequest message - """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return client._perform_request( - "POST", - "/_security/saml/invalidate", - params=params, - headers=headers, - body=body, - ) - - @query_params() - def saml_logout(self, body, params=None, headers=None): - """ - Invalidates an access token and a refresh token that were generated via the - SAML Authenticate API - - ``_ - - :arg body: The tokens to invalidate - """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return client._perform_request( - "POST", "/_security/saml/logout", params=params, headers=headers, body=body - ) - - @query_params() - def saml_prepare_authentication(self, body, params=None, headers=None): - """ - Creates a SAML authentication request - - ``_ - - :arg body: The realm for which to create the authentication - request, identified by either its name or the ACS URL - """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return client._perform_request( - "POST", "/_security/saml/prepare", params=params, headers=headers, body=body - ) - - @query_params() - def saml_service_provider_metadata(self, realm_name, params=None, headers=None): - """ - Generates SAML metadata for the Elastic stack SAML 2.0 Service Provider - - ``_ - - :arg realm_name: The name of the SAML realm to get the metadata - for - """ - client, params = _deprecated_options(self, params) - if realm_name in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'realm_name'.") - - return client._perform_request( - "GET", - _make_path("_security", "saml", "metadata", realm_name), - params=params, - headers=headers, - ) - - @query_params() - def query_api_keys(self, body=None, params=None, headers=None): - """ - Retrieves information for API keys using a subset of query DSL - - ``_ - - :arg body: From, size, query, sort and search_after - """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "POST", - "/_security/_query/api_key", - params=params, - headers=headers, - body=body, - ) + if username in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'username'") + __path = f"/_security/user/{_quote(username)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if email is not None: + __body["email"] = email + if enabled is not None: + __body["enabled"] = enabled + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if full_name is not None: + __body["full_name"] = full_name + if human is not None: + __query["human"] = human + if metadata is not None: + __body["metadata"] = metadata + if password is not None: + __body["password"] = password + if password_hash is not None: + __body["password_hash"] = password_hash + if pretty is not None: + __query["pretty"] = pretty + if refresh is not None: + __query["refresh"] = refresh + if roles is not None: + __body["roles"] = roles + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("PUT", __target, headers=__headers, body=__body) diff --git a/elasticsearch/_sync/client/security.pyi b/elasticsearch/_sync/client/security.pyi deleted file mode 100644 index eaed59806..000000000 --- a/elasticsearch/_sync/client/security.pyi +++ /dev/null @@ -1,785 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class SecurityClient(NamespacedClient): - def authenticate( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def change_password( - self, - *, - body: Any, - username: Optional[Any] = ..., - refresh: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def clear_cached_realms( - self, - realms: Any, - *, - usernames: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def clear_cached_roles( - self, - name: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def create_api_key( - self, - *, - body: Any, - refresh: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def delete_privileges( - self, - application: Any, - name: Any, - *, - refresh: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def delete_role( - self, - name: Any, - *, - refresh: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def delete_role_mapping( - self, - name: Any, - *, - refresh: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def delete_user( - self, - username: Any, - *, - refresh: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def disable_user( - self, - username: Any, - *, - refresh: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def enable_user( - self, - username: Any, - *, - refresh: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_api_key( - self, - *, - id: Optional[Any] = ..., - name: Optional[Any] = ..., - owner: Optional[Any] = ..., - realm_name: Optional[Any] = ..., - username: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_privileges( - self, - *, - application: Optional[Any] = ..., - name: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_role( - self, - *, - name: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_role_mapping( - self, - *, - name: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_token( - self, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_user( - self, - *, - username: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_user_privileges( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def has_privileges( - self, - *, - body: Any, - user: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def invalidate_api_key( - self, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def invalidate_token( - self, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def put_privileges( - self, - *, - body: Any, - refresh: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def put_role( - self, - name: Any, - *, - body: Any, - refresh: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def put_role_mapping( - self, - name: Any, - *, - body: Any, - refresh: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def put_user( - self, - username: Any, - *, - body: Any, - refresh: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_builtin_privileges( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def clear_cached_privileges( - self, - application: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def clear_api_key_cache( - self, - ids: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def grant_api_key( - self, - *, - body: Any, - refresh: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def clear_cached_service_tokens( - self, - namespace: Any, - service: Any, - name: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def create_service_token( - self, - namespace: Any, - service: Any, - *, - name: Optional[Any] = ..., - refresh: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def delete_service_token( - self, - namespace: Any, - service: Any, - name: Any, - *, - refresh: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_service_accounts( - self, - *, - namespace: Optional[Any] = ..., - service: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_service_credentials( - self, - namespace: Any, - service: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def enroll_node( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def saml_complete_logout( - self, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def enroll_kibana( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def saml_authenticate( - self, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def saml_invalidate( - self, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def saml_logout( - self, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def saml_prepare_authentication( - self, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def saml_service_provider_metadata( - self, - realm_name: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def query_api_keys( - self, - *, - body: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_sync/client/shutdown.py b/elasticsearch/_sync/client/shutdown.py index 156072a0e..23724f442 100644 --- a/elasticsearch/_sync/client/shutdown.py +++ b/elasticsearch/_sync/client/shutdown.py @@ -15,72 +15,121 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params +from .utils import SKIP_IN_PATH, _quote, _quote_query, _rewrite_parameters class ShutdownClient(NamespacedClient): - @query_params() - def delete_node(self, node_id, params=None, headers=None): + @_rewrite_parameters() + def delete_node( + self, + *, + node_id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Removes a node from the shutdown list. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported. ``_ - :arg node_id: The node id of node to be removed from the - shutdown state + :param node_id: The node id of node to be removed from the shutdown state """ - client, params = _deprecated_options(self, params) if node_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'node_id'.") - - return client._perform_request( - "DELETE", - _make_path("_nodes", node_id, "shutdown"), - params=params, - headers=headers, - ) + raise ValueError("Empty value passed for parameter 'node_id'") + __path = f"/_nodes/{_quote(node_id)}/shutdown" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("DELETE", __target, headers=__headers) - @query_params() - def get_node(self, node_id=None, params=None, headers=None): + @_rewrite_parameters() + def get_node( + self, + *, + node_id: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Retrieve status of a node or nodes that are currently marked as shutting down. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported. ``_ - :arg node_id: Which node for which to retrieve the shutdown - status + :param node_id: Which node for which to retrieve the shutdown status """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", - _make_path("_nodes", node_id, "shutdown"), - params=params, - headers=headers, - ) + if node_id not in SKIP_IN_PATH: + __path = f"/_nodes/{_quote(node_id)}/shutdown" + else: + __path = "/_nodes/shutdown" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) - @query_params() - def put_node(self, node_id, body, params=None, headers=None): + @_rewrite_parameters() + def put_node( + self, + *, + node_id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Adds a node to be shut down. Designed for indirect use by ECE/ESS and ECK. - Direct use is not supported. + Adds a node to be shut down. Designed for indirect use by ECE/ESS and ECK. Direct + use is not supported. ``_ - :arg node_id: The node id of node to be shut down - :arg body: The shutdown type definition to register + :param node_id: The node id of node to be shut down """ - client, params = _deprecated_options(self, params) - for param in (node_id, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "PUT", - _make_path("_nodes", node_id, "shutdown"), - params=params, - headers=headers, - body=body, - ) + if node_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'node_id'") + __path = f"/_nodes/{_quote(node_id)}/shutdown" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("PUT", __target, headers=__headers) diff --git a/elasticsearch/_sync/client/shutdown.pyi b/elasticsearch/_sync/client/shutdown.pyi deleted file mode 100644 index f3f9db133..000000000 --- a/elasticsearch/_sync/client/shutdown.pyi +++ /dev/null @@ -1,76 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class ShutdownClient(NamespacedClient): - def delete_node( - self, - node_id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_node( - self, - *, - node_id: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def put_node( - self, - node_id: Any, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_sync/client/slm.py b/elasticsearch/_sync/client/slm.py index fed2f3493..c2ea71f04 100644 --- a/elasticsearch/_sync/client/slm.py +++ b/elasticsearch/_sync/client/slm.py @@ -15,153 +15,357 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params +from .utils import SKIP_IN_PATH, _quote, _quote_query, _rewrite_parameters class SlmClient(NamespacedClient): - @query_params() - def delete_lifecycle(self, policy_id, params=None, headers=None): + @_rewrite_parameters() + def delete_lifecycle( + self, + *, + policy_id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Deletes an existing snapshot lifecycle policy. - ``_ + ``_ - :arg policy_id: The id of the snapshot lifecycle policy to - remove + :param policy_id: The id of the snapshot lifecycle policy to remove """ - client, params = _deprecated_options(self, params) if policy_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'policy_id'.") - - return client._perform_request( - "DELETE", - _make_path("_slm", "policy", policy_id), - params=params, - headers=headers, - ) + raise ValueError("Empty value passed for parameter 'policy_id'") + __path = f"/_slm/policy/{_quote(policy_id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("DELETE", __target, headers=__headers) - @query_params() - def execute_lifecycle(self, policy_id, params=None, headers=None): + @_rewrite_parameters() + def execute_lifecycle( + self, + *, + policy_id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Immediately creates a snapshot according to the lifecycle policy, without - waiting for the scheduled time. + 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 + :param policy_id: The id of the snapshot lifecycle policy to be executed """ - client, params = _deprecated_options(self, params) if policy_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'policy_id'.") - - return client._perform_request( - "PUT", - _make_path("_slm", "policy", policy_id, "_execute"), - params=params, - headers=headers, - ) + raise ValueError("Empty value passed for parameter 'policy_id'") + __path = f"/_slm/policy/{_quote(policy_id)}/_execute" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("PUT", __target, headers=__headers) - @query_params() - def execute_retention(self, params=None, headers=None): + @_rewrite_parameters() + def execute_retention( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Deletes any snapshots that are expired according to the policy's retention - rules. + Deletes any snapshots that are expired according to the policy's retention rules. - ``_ + ``_ """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "POST", "/_slm/_execute_retention", params=params, headers=headers - ) + __path = "/_slm/_execute_retention" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) - @query_params() - def get_lifecycle(self, policy_id=None, params=None, headers=None): + @_rewrite_parameters() + def get_lifecycle( + self, + *, + policy_id: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Retrieves one or more snapshot lifecycle policy definitions and information - about the latest snapshot attempts. + 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 + :param policy_id: Comma-separated list of snapshot lifecycle policies to retrieve """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", - _make_path("_slm", "policy", policy_id), - params=params, - headers=headers, - ) + if policy_id not in SKIP_IN_PATH: + __path = f"/_slm/policy/{_quote(policy_id)}" + else: + __path = "/_slm/policy" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) - @query_params() - def get_stats(self, params=None, headers=None): + @_rewrite_parameters() + def get_stats( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Returns global and policy-level statistics about actions taken by snapshot - lifecycle management. + Returns global and policy-level statistics about actions taken by snapshot lifecycle + management. ``_ """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", "/_slm/stats", params=params, headers=headers - ) + __path = "/_slm/stats" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) - @query_params() - def put_lifecycle(self, policy_id, body=None, params=None, headers=None): + @_rewrite_parameters() + def get_status( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Creates or updates a snapshot lifecycle policy. - - ``_ + Retrieves the status of snapshot lifecycle management (SLM). - :arg policy_id: The id of the snapshot lifecycle policy - :arg body: The snapshot lifecycle policy definition to register + ``_ """ - client, params = _deprecated_options(self, params) - if policy_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'policy_id'.") - - return client._perform_request( - "PUT", - _make_path("_slm", "policy", policy_id), - params=params, - headers=headers, - body=body, - ) + __path = "/_slm/status" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) - @query_params() - def get_status(self, params=None, headers=None): + @_rewrite_parameters( + body_fields=True, + ) + def put_lifecycle( + self, + *, + policy_id: Any, + config: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + name: Optional[Any] = None, + pretty: Optional[bool] = None, + repository: Optional[str] = None, + retention: Optional[Any] = None, + schedule: Optional[Any] = None, + timeout: Optional[Any] = None, + ) -> Any: """ - Retrieves the status of snapshot lifecycle management (SLM). + Creates or updates a snapshot lifecycle policy. + + ``_ - ``_ + :param policy_id: ID for the snapshot lifecycle policy you want to create or + update. + :param config: Configuration for each snapshot created by the policy. + :param master_timeout: Period to wait for a connection to the master node. If + no response is received before the timeout expires, the request fails and + returns an error. + :param name: Name automatically assigned to each snapshot created by the policy. + Date math is supported. To prevent conflicting snapshot names, a UUID is + automatically appended to each snapshot name. + :param repository: Repository used to store snapshots created by this policy. + This repository must exist prior to the policy’s creation. You can create + a repository using the snapshot repository API. + :param retention: Retention rules used to retain and delete snapshots created + by the policy. + :param schedule: Periodic or absolute schedule at which the policy creates snapshots. + SLM applies schedule changes immediately. + :param timeout: Period to wait for a response. If no response is received before + the timeout expires, the request fails and returns an error. """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", "/_slm/status", params=params, headers=headers - ) + if policy_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'policy_id'") + __path = f"/_slm/policy/{_quote(policy_id)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if config is not None: + __body["config"] = config + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if name is not None: + __body["name"] = name + if pretty is not None: + __query["pretty"] = pretty + if repository is not None: + __body["repository"] = repository + if retention is not None: + __body["retention"] = retention + if schedule is not None: + __body["schedule"] = schedule + if timeout is not None: + __query["timeout"] = timeout + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("PUT", __target, headers=__headers, body=__body) - @query_params() - def start(self, params=None, headers=None): + @_rewrite_parameters() + def start( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Turns on snapshot lifecycle management (SLM). - ``_ + ``_ """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "POST", "/_slm/start", params=params, headers=headers - ) + __path = "/_slm/start" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) - @query_params() - def stop(self, params=None, headers=None): + @_rewrite_parameters() + def stop( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Turns off snapshot lifecycle management (SLM). - ``_ + ``_ """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "POST", "/_slm/stop", params=params, headers=headers - ) + __path = "/_slm/stop" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) diff --git a/elasticsearch/_sync/client/slm.pyi b/elasticsearch/_sync/client/slm.pyi deleted file mode 100644 index a02206f20..000000000 --- a/elasticsearch/_sync/client/slm.pyi +++ /dev/null @@ -1,173 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class SlmClient(NamespacedClient): - def delete_lifecycle( - self, - policy_id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def execute_lifecycle( - self, - policy_id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def execute_retention( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_lifecycle( - self, - *, - policy_id: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_stats( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def put_lifecycle( - self, - policy_id: Any, - *, - body: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_status( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def start( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def stop( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_sync/client/snapshot.py b/elasticsearch/_sync/client/snapshot.py index ea7ae3e09..e79e8fece 100644 --- a/elasticsearch/_sync/client/snapshot.py +++ b/elasticsearch/_sync/client/snapshot.py @@ -15,348 +15,674 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params +from .utils import SKIP_IN_PATH, _quote, _quote_query, _rewrite_parameters class SnapshotClient(NamespacedClient): - @query_params("master_timeout", "wait_for_completion") - 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 - :arg body: The snapshot definition - :arg master_timeout: Explicit operation timeout for connection - to master node - :arg wait_for_completion: Should this request wait until the - operation has completed before returning - """ - client, params = _deprecated_options(self, params) - for param in (repository, snapshot): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "PUT", - _make_path("_snapshot", repository, snapshot), - params=params, - headers=headers, - body=body, - ) - - @query_params("master_timeout") - def delete(self, repository, snapshot, params=None, headers=None): + @_rewrite_parameters() + def cleanup_repository( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ - Deletes one or more snapshots. + Removes stale data from repository. - ``_ + ``_ - :arg repository: A repository name - :arg snapshot: A comma-separated list of snapshot names - :arg master_timeout: Explicit operation timeout for connection - to master node + :param name: A repository name + :param master_timeout: Explicit operation timeout for connection to master node + :param timeout: Explicit operation timeout """ - client, params = _deprecated_options(self, params) - for param in (repository, snapshot): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "DELETE", - _make_path("_snapshot", repository, snapshot), - params=params, - headers=headers, - ) - - @query_params( - "ignore_unavailable", - "include_repository", - "index_details", - "master_timeout", - "verbose", + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_snapshot/{_quote(name)}/_cleanup" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, ) - def get(self, repository, snapshot, params=None, headers=None): + def clone( + self, + *, + repository: Any, + snapshot: Any, + target_snapshot: Any, + indices: str, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ - Returns information about a snapshot. + Clones indices from one snapshot into another snapshot in the same repository. ``_ - :arg repository: A repository name - :arg snapshot: A comma-separated list of snapshot names - :arg ignore_unavailable: Whether to ignore unavailable - snapshots, defaults to false which means a SnapshotMissingException is - thrown - :arg include_repository: Whether to include the repository name - in the snapshot info. Defaults to true. - :arg index_details: Whether to include details of each index in - the snapshot, if those details are available. Defaults to false. - :arg master_timeout: Explicit operation timeout for connection - to master node - :arg verbose: Whether to show verbose snapshot info or only show - the basic info found in the repository index blob + :param repository: A repository name + :param snapshot: The name of the snapshot to clone from + :param target_snapshot: The name of the cloned snapshot to create + :param indices: + :param master_timeout: Explicit operation timeout for connection to master node + :param timeout: """ - client, params = _deprecated_options(self, params) - for param in (repository, snapshot): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "GET", - _make_path("_snapshot", repository, snapshot), - params=params, - headers=headers, - ) - - @query_params("master_timeout", "timeout") - def delete_repository(self, repository, params=None, headers=None): + if repository in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'repository'") + if snapshot in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'snapshot'") + if target_snapshot in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'target_snapshot'") + if indices is None: + raise ValueError("Empty value passed for parameter 'indices'") + __path = f"/_snapshot/{_quote(repository)}/{_quote(snapshot)}/_clone/{_quote(target_snapshot)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if indices is not None: + __body["indices"] = indices + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("PUT", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, + ) + def create( + self, + *, + repository: Any, + snapshot: Any, + error_trace: Optional[bool] = None, + feature_states: Optional[List[str]] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + include_global_state: Optional[bool] = None, + indices: Optional[Any] = None, + master_timeout: Optional[Any] = None, + metadata: Optional[Any] = None, + partial: Optional[bool] = None, + pretty: Optional[bool] = None, + wait_for_completion: Optional[bool] = None, + ) -> Any: """ - Deletes a repository. + Creates a snapshot in a repository. ``_ - :arg repository: Name of the snapshot repository to unregister. - Wildcard (`*`) patterns are supported. - :arg master_timeout: Explicit operation timeout for connection - to master node - :arg timeout: Explicit operation timeout + :param repository: Repository for the snapshot. + :param snapshot: Name of the snapshot. Must be unique in the repository. + :param feature_states: Feature states to include in the snapshot. Each feature + state includes one or more system indices containing related data. You can + view a list of eligible features using the get features API. If `include_global_state` + is `true`, all current feature states are included by default. If `include_global_state` + is `false`, no feature states are included by default. + :param ignore_unavailable: If `true`, the request ignores data streams and indices + in `indices` that are missing or closed. If `false`, the request returns + an error for any data stream or index that is missing or closed. + :param include_global_state: If `true`, the current cluster state is included + in the snapshot. The cluster state includes persistent cluster settings, + composable index templates, legacy index templates, ingest pipelines, and + ILM policies. It also includes data stored in system indices, such as Watches + and task records (configurable via `feature_states`). + :param indices: Data streams and indices to include in the snapshot. Supports + multi-target syntax. Includes all data streams and indices by default. + :param master_timeout: Period to wait for a connection to the master node. If + no response is received before the timeout expires, the request fails and + returns an error. + :param metadata: Optional metadata for the snapshot. May have any contents. Must + be less than 1024 bytes. This map is not automatically generated by Elasticsearch. + :param partial: If `true`, allows restoring a partial snapshot of indices with + unavailable shards. Only shards that were successfully included in the snapshot + will be restored. All missing shards will be recreated as empty. If `false`, + the entire restore operation will fail if one or more indices included in + the snapshot do not have all primary shards available. + :param wait_for_completion: If `true`, the request returns a response when the + snapshot is complete. If `false`, the request returns a response when the + snapshot initializes. """ - client, params = _deprecated_options(self, params) if repository in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'repository'.") - - return client._perform_request( - "DELETE", - _make_path("_snapshot", repository), - params=params, - headers=headers, - ) - - @query_params("local", "master_timeout") - def get_repository(self, repository=None, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'repository'") + if snapshot in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'snapshot'") + __path = f"/_snapshot/{_quote(repository)}/{_quote(snapshot)}" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if feature_states is not None: + __body["feature_states"] = feature_states + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __body["ignore_unavailable"] = ignore_unavailable + if include_global_state is not None: + __body["include_global_state"] = include_global_state + if indices is not None: + __body["indices"] = indices + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if metadata is not None: + __body["metadata"] = metadata + if partial is not None: + __body["partial"] = partial + if pretty is not None: + __query["pretty"] = pretty + if wait_for_completion is not None: + __query["wait_for_completion"] = wait_for_completion + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("PUT", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, + ) + def create_repository( + self, + *, + name: Any, + settings: Any, + type: str, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + repository: Optional[Any] = None, + timeout: Optional[Any] = None, + verify: Optional[bool] = None, + ) -> Any: """ - Returns information about a repository. + Creates a repository. ``_ - :arg repository: A comma-separated list of repository names - :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 + :param name: A repository name + :param settings: + :param type: + :param master_timeout: Explicit operation timeout for connection to master node + :param repository: + :param timeout: Explicit operation timeout + :param verify: Whether to verify the repository after creation """ - client, params = _deprecated_options(self, params) - return client._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): + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + if settings is None: + raise ValueError("Empty value passed for parameter 'settings'") + if type is None: + raise ValueError("Empty value passed for parameter 'type'") + __path = f"/_snapshot/{_quote(name)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if settings is not None: + __body["settings"] = settings + if type is not None: + __body["type"] = type + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if repository is not None: + __body["repository"] = repository + if timeout is not None: + __query["timeout"] = timeout + if verify is not None: + __query["verify"] = verify + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("PUT", __target, headers=__headers, body=__body) + + @_rewrite_parameters() + def delete( + self, + *, + repository: Any, + snapshot: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Creates a repository. + Deletes one or more snapshots. ``_ - :arg repository: A repository name - :arg body: The repository definition - :arg master_timeout: Explicit operation timeout for connection - to master node - :arg timeout: Explicit operation timeout - :arg verify: Whether to verify the repository after creation + :param repository: A repository name + :param snapshot: A comma-separated list of snapshot names + :param master_timeout: Explicit operation timeout for connection to master node """ - client, params = _deprecated_options(self, params) - for param in (repository, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "PUT", - _make_path("_snapshot", repository), - params=params, - headers=headers, - body=body, - ) - - @query_params("master_timeout", "wait_for_completion") - def restore(self, repository, snapshot, body=None, params=None, headers=None): + if repository in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'repository'") + if snapshot in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'snapshot'") + __path = f"/_snapshot/{_quote(repository)}/{_quote(snapshot)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + def delete_repository( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ - Restores a snapshot. + Deletes a repository. ``_ - :arg repository: A repository name - :arg snapshot: A snapshot name - :arg body: Details of what to restore - :arg master_timeout: Explicit operation timeout for connection - to master node - :arg wait_for_completion: Should this request wait until the - operation has completed before returning + :param name: Name of the snapshot repository to unregister. Wildcard (`*`) patterns + are supported. + :param master_timeout: Explicit operation timeout for connection to master node + :param timeout: Explicit operation timeout """ - client, params = _deprecated_options(self, params) - for param in (repository, snapshot): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "POST", - _make_path("_snapshot", repository, snapshot, "_restore"), - params=params, - headers=headers, - body=body, - ) - - @query_params("ignore_unavailable", "master_timeout") - def status(self, repository=None, snapshot=None, params=None, headers=None): + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_snapshot/{_quote(name)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters() + def get( + self, + *, + repository: Any, + snapshot: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + include_repository: Optional[bool] = None, + index_details: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + verbose: Optional[bool] = None, + ) -> Any: """ - Returns information about the status of a snapshot. + Returns information about a snapshot. ``_ - :arg repository: A repository name - :arg snapshot: A comma-separated list of snapshot names - :arg ignore_unavailable: Whether to ignore unavailable - snapshots, defaults to false which means a SnapshotMissingException is - thrown - :arg master_timeout: Explicit operation timeout for connection - to master node + :param repository: Comma-separated list of snapshot repository names used to + limit the request. Wildcard (*) expressions are supported. + :param snapshot: Comma-separated list of snapshot names to retrieve. Also accepts + wildcards (*). - To get information about all snapshots in a registered repository, + use a wildcard (*) or _all. - To get information about any snapshots that + are currently running, use _current. + :param ignore_unavailable: If false, the request returns an error for any snapshots + that are unavailable. + :param include_repository: Whether to include the repository name in the snapshot + info. Defaults to true. + :param index_details: If true, returns additional information about each index + in the snapshot comprising the number of shards in the index, the total size + of the index in bytes, and the maximum number of segments per shard in the + index. Defaults to false, meaning that this information is omitted. + :param master_timeout: Period to wait for a connection to the master node. If + no response is received before the timeout expires, the request fails and + returns an error. + :param verbose: If true, returns additional information about each snapshot such + as the version of Elasticsearch which took the snapshot, the start and end + times of the snapshot, and the number of shards snapshotted. """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", - _make_path("_snapshot", repository, snapshot, "_status"), - params=params, - headers=headers, - ) - - @query_params("master_timeout", "timeout") - def verify_repository(self, repository, params=None, headers=None): + if repository in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'repository'") + if snapshot in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'snapshot'") + __path = f"/_snapshot/{_quote(repository)}/{_quote(snapshot)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if include_repository is not None: + __query["include_repository"] = include_repository + if index_details is not None: + __query["index_details"] = index_details + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if verbose is not None: + __query["verbose"] = verbose + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def get_repository( + self, + *, + name: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + local: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Verifies a repository. + Returns information about a repository. ``_ - :arg repository: A repository name - :arg master_timeout: Explicit operation timeout for connection - to master node - :arg timeout: Explicit operation timeout + :param name: A comma-separated list of repository names + :param local: Return local information, do not retrieve the state from master + node (default: false) + :param master_timeout: Explicit operation timeout for connection to master node """ - client, params = _deprecated_options(self, params) - if repository in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'repository'.") - - return client._perform_request( - "POST", - _make_path("_snapshot", repository, "_verify"), - params=params, - headers=headers, - ) - - @query_params("master_timeout", "timeout") - def cleanup_repository(self, repository, params=None, headers=None): + if name not in SKIP_IN_PATH: + __path = f"/_snapshot/{_quote(name)}" + else: + __path = "/_snapshot" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if local is not None: + __query["local"] = local + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + def restore( + self, + *, + repository: Any, + snapshot: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_index_settings: Optional[List[str]] = None, + ignore_unavailable: Optional[bool] = None, + include_aliases: Optional[bool] = None, + include_global_state: Optional[bool] = None, + index_settings: Optional[Any] = None, + indices: Optional[Any] = None, + master_timeout: Optional[Any] = None, + partial: Optional[bool] = None, + pretty: Optional[bool] = None, + rename_pattern: Optional[str] = None, + rename_replacement: Optional[str] = None, + wait_for_completion: Optional[bool] = None, + ) -> Any: """ - Removes stale data from repository. + Restores a snapshot. - ``_ + ``_ - :arg repository: A repository name - :arg master_timeout: Explicit operation timeout for connection - to master node - :arg timeout: Explicit operation timeout + :param repository: A repository name + :param snapshot: A snapshot name + :param ignore_index_settings: + :param ignore_unavailable: + :param include_aliases: + :param include_global_state: + :param index_settings: + :param indices: + :param master_timeout: Explicit operation timeout for connection to master node + :param partial: + :param rename_pattern: + :param rename_replacement: + :param wait_for_completion: Should this request wait until the operation has + completed before returning """ - client, params = _deprecated_options(self, params) if repository in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'repository'.") - - return client._perform_request( - "POST", - _make_path("_snapshot", repository, "_cleanup"), - params=params, - headers=headers, - ) - - @query_params("master_timeout") - def clone( - self, repository, snapshot, target_snapshot, body, params=None, headers=None - ): + raise ValueError("Empty value passed for parameter 'repository'") + if snapshot in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'snapshot'") + __path = f"/_snapshot/{_quote(repository)}/{_quote(snapshot)}/_restore" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_index_settings is not None: + __body["ignore_index_settings"] = ignore_index_settings + if ignore_unavailable is not None: + __body["ignore_unavailable"] = ignore_unavailable + if include_aliases is not None: + __body["include_aliases"] = include_aliases + if include_global_state is not None: + __body["include_global_state"] = include_global_state + if index_settings is not None: + __body["index_settings"] = index_settings + if indices is not None: + __body["indices"] = indices + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if partial is not None: + __body["partial"] = partial + if pretty is not None: + __query["pretty"] = pretty + if rename_pattern is not None: + __body["rename_pattern"] = rename_pattern + if rename_replacement is not None: + __body["rename_replacement"] = rename_replacement + if wait_for_completion is not None: + __query["wait_for_completion"] = wait_for_completion + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters() + def status( + self, + *, + repository: Optional[Any] = None, + snapshot: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Clones indices from one snapshot into another snapshot in the same repository. + Returns information about the status of a snapshot. ``_ - :arg repository: A repository name - :arg snapshot: The name of the snapshot to clone from - :arg target_snapshot: The name of the cloned snapshot to create - :arg body: The snapshot clone definition - :arg master_timeout: Explicit operation timeout for connection - to master node + :param repository: A repository name + :param snapshot: A comma-separated list of snapshot names + :param ignore_unavailable: Whether to ignore unavailable snapshots, defaults + to false which means a SnapshotMissingException is thrown + :param master_timeout: Explicit operation timeout for connection to master node """ - client, params = _deprecated_options(self, params) - for param in (repository, snapshot, target_snapshot, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "PUT", - _make_path("_snapshot", repository, snapshot, "_clone", target_snapshot), - params=params, - headers=headers, - body=body, - ) - - @query_params( - "blob_count", - "concurrency", - "detailed", - "early_read_node_count", - "max_blob_size", - "max_total_data_size", - "rare_action_probability", - "rarely_abort_writes", - "read_node_count", - "seed", - "timeout", - ) - def repository_analyze(self, repository, params=None, headers=None): + if repository not in SKIP_IN_PATH and snapshot not in SKIP_IN_PATH: + __path = f"/_snapshot/{_quote(repository)}/{_quote(snapshot)}/_status" + elif repository not in SKIP_IN_PATH: + __path = f"/_snapshot/{_quote(repository)}/_status" + else: + __path = "/_snapshot/_status" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def verify_repository( + self, + *, + name: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ - Analyzes a repository for correctness and performance + Verifies a repository. ``_ - :arg repository: A repository name - :arg blob_count: Number of blobs to create during the test. - Defaults to 100. - :arg concurrency: Number of operations to run concurrently - during the test. Defaults to 10. - :arg detailed: Whether to return detailed results or a summary. - Defaults to 'false' so that only the summary is returned. - :arg early_read_node_count: Number of nodes on which to perform - an early read on a blob, i.e. before writing has completed. Early reads - are rare actions so the 'rare_action_probability' parameter is also - relevant. Defaults to 2. - :arg max_blob_size: Maximum size of a blob to create during the - test, e.g '1gb' or '100mb'. Defaults to '10mb'. - :arg max_total_data_size: Maximum total size of all blobs to - create during the test, e.g '1tb' or '100gb'. Defaults to '1gb'. - :arg rare_action_probability: Probability of taking a rare - action such as an early read or an overwrite. Defaults to 0.02. - :arg rarely_abort_writes: Whether to rarely abort writes before - they complete. Defaults to 'true'. - :arg read_node_count: Number of nodes on which to read a blob - after writing. Defaults to 10. - :arg seed: Seed for the random number generator used to create - the test workload. Defaults to a random value. - :arg timeout: Explicit operation timeout. Defaults to '30s'. + :param name: A repository name + :param master_timeout: Explicit operation timeout for connection to master node + :param timeout: Explicit operation timeout """ - client, params = _deprecated_options(self, params) - if repository in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'repository'.") - - return client._perform_request( - "POST", - _make_path("_snapshot", repository, "_analyze"), - params=params, - headers=headers, - ) + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'name'") + __path = f"/_snapshot/{_quote(name)}/_verify" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) diff --git a/elasticsearch/_sync/client/snapshot.pyi b/elasticsearch/_sync/client/snapshot.pyi deleted file mode 100644 index f87ea2444..000000000 --- a/elasticsearch/_sync/client/snapshot.pyi +++ /dev/null @@ -1,274 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class SnapshotClient(NamespacedClient): - def create( - self, - repository: Any, - snapshot: Any, - *, - body: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - wait_for_completion: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def delete( - self, - repository: Any, - snapshot: Any, - *, - master_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get( - self, - repository: Any, - snapshot: Any, - *, - ignore_unavailable: Optional[Any] = ..., - include_repository: Optional[Any] = ..., - index_details: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - verbose: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def delete_repository( - self, - repository: Any, - *, - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_repository( - self, - *, - repository: Optional[Any] = ..., - local: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def create_repository( - self, - repository: Any, - *, - body: Any, - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - verify: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def restore( - self, - repository: Any, - snapshot: Any, - *, - body: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - wait_for_completion: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def status( - self, - *, - repository: Optional[Any] = ..., - snapshot: Optional[Any] = ..., - ignore_unavailable: Optional[Any] = ..., - master_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def verify_repository( - self, - repository: Any, - *, - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def cleanup_repository( - self, - repository: Any, - *, - master_timeout: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def clone( - self, - repository: Any, - snapshot: Any, - target_snapshot: Any, - *, - body: Any, - master_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def repository_analyze( - self, - repository: Any, - *, - blob_count: Optional[Any] = ..., - concurrency: Optional[Any] = ..., - detailed: Optional[Any] = ..., - early_read_node_count: Optional[Any] = ..., - max_blob_size: Optional[Any] = ..., - max_total_data_size: Optional[Any] = ..., - rare_action_probability: Optional[Any] = ..., - rarely_abort_writes: Optional[Any] = ..., - read_node_count: Optional[Any] = ..., - seed: Optional[Any] = ..., - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_sync/client/sql.py b/elasticsearch/_sync/client/sql.py index c6e5ef3f0..b47ea0c86 100644 --- a/elasticsearch/_sync/client/sql.py +++ b/elasticsearch/_sync/client/sql.py @@ -15,128 +15,183 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params +from .utils import _quote_query, _rewrite_parameters class SqlClient(NamespacedClient): - @query_params() - def clear_cursor(self, body, params=None, headers=None): + @_rewrite_parameters( + body_fields=True, + ) + def clear_cursor( + self, + *, + cursor: str, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Clears the SQL cursor - ``_ + ``_ - :arg body: Specify the cursor value in the `cursor` element to - clean the cursor. + :param cursor: """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return client._perform_request( - "POST", "/_sql/close", params=params, headers=headers, body=body - ) - - @query_params("format") - def query(self, body, params=None, headers=None): + if cursor is None: + raise ValueError("Empty value passed for parameter 'cursor'") + __path = "/_sql/close" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if cursor is not None: + __body["cursor"] = cursor + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, + ignore_deprecated_options={"request_timeout"}, + ) + def query( + self, + *, + columnar: Optional[bool] = None, + cursor: Optional[str] = None, + error_trace: Optional[bool] = None, + fetch_size: Optional[int] = None, + field_multi_value_leniency: Optional[bool] = None, + filter: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + format: Optional[str] = None, + human: Optional[bool] = None, + page_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + query: Optional[str] = None, + request_timeout: Optional[Any] = None, + time_zone: Optional[str] = None, + ) -> Any: """ Executes a SQL request - ``_ - - :arg body: Use the `query` element to start a query. Use the - `cursor` element to continue a query. - :arg format: a short version of the Accept header, e.g. json, - yaml + ``_ + + :param columnar: + :param cursor: + :param fetch_size: The maximum number of rows (or entries) to return in one response + :param field_multi_value_leniency: Throw an exception when encountering multiple + values for a field (default) or be lenient and return the first value from + the list (without any guarantees of what that will be - typically the first + in natural ascending order). + :param filter: Optional Elasticsearch query DSL for additional filtering. + :param format: a short version of the Accept header, e.g. json, yaml + :param page_timeout: The timeout before a pagination request fails. + :param query: SQL query to execute + :param request_timeout: The timeout before the request fails. + :param time_zone: Time-zone in ISO 8601 used for executing the query on the server. + More information available here. """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return client._perform_request( - "POST", "/_sql", params=params, headers=headers, body=body - ) - - @query_params() - def translate(self, body, params=None, headers=None): + __path = "/_sql" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if columnar is not None: + __body["columnar"] = columnar + if cursor is not None: + __body["cursor"] = cursor + if error_trace is not None: + __query["error_trace"] = error_trace + if fetch_size is not None: + __body["fetch_size"] = fetch_size + if field_multi_value_leniency is not None: + __body["field_multi_value_leniency"] = field_multi_value_leniency + if filter is not None: + __body["filter"] = filter + if filter_path is not None: + __query["filter_path"] = filter_path + if format is not None: + __query["format"] = format + if human is not None: + __query["human"] = human + if page_timeout is not None: + __body["page_timeout"] = page_timeout + if pretty is not None: + __query["pretty"] = pretty + if query is not None: + __body["query"] = query + if request_timeout is not None: + __body["request_timeout"] = request_timeout + if time_zone is not None: + __body["time_zone"] = time_zone + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, + ) + def translate( + self, + *, + query: str, + error_trace: Optional[bool] = None, + fetch_size: Optional[int] = None, + filter: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + time_zone: Optional[str] = None, + ) -> Any: """ Translates SQL into Elasticsearch queries - ``_ + ``_ - :arg body: Specify the query in the `query` element. + :param query: + :param fetch_size: + :param filter: + :param time_zone: """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return client._perform_request( - "POST", "/_sql/translate", params=params, headers=headers, body=body - ) - - @query_params() - def delete_async(self, id, params=None, headers=None): - """ - Deletes an async SQL search or a stored synchronous SQL search. If the search - is still running, the API cancels it. - - ``_ - - :arg id: The async search ID - """ - client, params = _deprecated_options(self, params) - if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'id'.") - - return client._perform_request( - "DELETE", - _make_path("_sql", "async", "delete", id), - params=params, - headers=headers, - ) - - @query_params("delimiter", "format", "keep_alive", "wait_for_completion_timeout") - def get_async(self, id, params=None, headers=None): - """ - Returns the current status and available results for an async SQL search or - stored synchronous SQL search - - ``_ - - :arg id: The async search ID - :arg delimiter: Separator for CSV results Default: , - :arg format: Short version of the Accept header, e.g. json, yaml - :arg keep_alive: Retention period for the search and its results - Default: 5d - :arg wait_for_completion_timeout: Duration to wait for complete - results - """ - client, params = _deprecated_options(self, params) - if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'id'.") - - return client._perform_request( - "GET", _make_path("_sql", "async", id), params=params, headers=headers - ) - - @query_params() - def get_async_status(self, id, params=None, headers=None): - """ - Returns the current status of an async SQL search or a stored synchronous SQL - search - - ``_ - - :arg id: The async search ID - """ - client, params = _deprecated_options(self, params) - if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'id'.") - - return client._perform_request( - "GET", - _make_path("_sql", "async", "status", id), - params=params, - headers=headers, - ) + if query is None: + raise ValueError("Empty value passed for parameter 'query'") + __path = "/_sql/translate" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if query is not None: + __body["query"] = query + if error_trace is not None: + __query["error_trace"] = error_trace + if fetch_size is not None: + __body["fetch_size"] = fetch_size + if filter is not None: + __body["filter"] = filter + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if time_zone is not None: + __body["time_zone"] = time_zone + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("POST", __target, headers=__headers, body=__body) diff --git a/elasticsearch/_sync/client/sql.pyi b/elasticsearch/_sync/client/sql.pyi deleted file mode 100644 index 948214b82..000000000 --- a/elasticsearch/_sync/client/sql.pyi +++ /dev/null @@ -1,129 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class SqlClient(NamespacedClient): - def clear_cursor( - self, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def query( - self, - *, - body: Any, - format: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def translate( - self, - *, - body: Any, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def delete_async( - self, - id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_async( - self, - id: Any, - *, - delimiter: Optional[Any] = ..., - format: Optional[Any] = ..., - keep_alive: Optional[Any] = ..., - wait_for_completion_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_async_status( - self, - id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_sync/client/ssl.py b/elasticsearch/_sync/client/ssl.py index 78f73ab2a..c335ed9a3 100644 --- a/elasticsearch/_sync/client/ssl.py +++ b/elasticsearch/_sync/client/ssl.py @@ -15,20 +15,41 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import _deprecated_options, query_params +from .utils import _quote_query, _rewrite_parameters class SslClient(NamespacedClient): - @query_params() - def certificates(self, params=None, headers=None): + @_rewrite_parameters() + def certificates( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ - Retrieves information about the X.509 certificates used to encrypt - communications in the cluster. + Retrieves information about the X.509 certificates used to encrypt communications + in the cluster. - ``_ + ``_ """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", "/_ssl/certificates", params=params, headers=headers - ) + __path = "/_ssl/certificates" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) diff --git a/elasticsearch/_sync/client/ssl.pyi b/elasticsearch/_sync/client/ssl.pyi deleted file mode 100644 index d96b47520..000000000 --- a/elasticsearch/_sync/client/ssl.pyi +++ /dev/null @@ -1,40 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class SslClient(NamespacedClient): - def certificates( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_sync/client/tasks.py b/elasticsearch/_sync/client/tasks.py index fbb257093..cff374015 100644 --- a/elasticsearch/_sync/client/tasks.py +++ b/elasticsearch/_sync/client/tasks.py @@ -15,103 +15,177 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params +from .utils import SKIP_IN_PATH, _quote, _quote_query, _rewrite_parameters class TasksClient(NamespacedClient): - @query_params( - "actions", - "detailed", - "group_by", - "nodes", - "parent_task_id", - "timeout", - "wait_for_completion", - ) - def list(self, params=None, headers=None): + @_rewrite_parameters() + def cancel( + self, + *, + task_id: Optional[Any] = None, + actions: Optional[Union[List[str], str]] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + nodes: Optional[List[str]] = None, + parent_task_id: Optional[str] = None, + pretty: Optional[bool] = None, + wait_for_completion: Optional[bool] = None, + ) -> Any: """ - Returns a list of tasks. + Cancels a task, if it can be cancelled through an API. ``_ - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - - :arg actions: A comma-separated list of actions that should be - returned. Leave empty to return all. - :arg detailed: Return detailed task information (default: false) - :arg group_by: Group tasks by nodes or parent/child - relationships Valid choices: nodes, parents, none Default: nodes - :arg nodes: 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 parent_task_id: Return tasks with specified parent task id - (node_id:task_number). Set to -1 to return all. - :arg timeout: Explicit operation timeout - :arg wait_for_completion: Wait for the matching tasks to - complete (default: false) + :param task_id: Cancel the task with specified task id (node_id:task_number) + :param actions: A comma-separated list of actions that should be cancelled. Leave + empty to cancel all. + :param nodes: 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 + :param parent_task_id: Cancel tasks with specified parent task id (node_id:task_number). + Set to -1 to cancel all. + :param wait_for_completion: Should the request block until the cancellation of + the task and its descendant tasks is completed. Defaults to false """ - client, params = _deprecated_options(self, params) - return client._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): + if task_id not in SKIP_IN_PATH: + __path = f"/_tasks/{_quote(task_id)}/_cancel" + else: + __path = "/_tasks/_cancel" + __query: Dict[str, Any] = {} + if actions is not None: + __query["actions"] = actions + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if nodes is not None: + __query["nodes"] = nodes + if parent_task_id is not None: + __query["parent_task_id"] = parent_task_id + if pretty is not None: + __query["pretty"] = pretty + if wait_for_completion is not None: + __query["wait_for_completion"] = wait_for_completion + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters() + def get( + self, + *, + task_id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + wait_for_completion: Optional[bool] = None, + ) -> Any: """ - Cancels a task, if it can be cancelled through an API. + Returns information about a task. ``_ - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - - :arg task_id: Cancel the task with specified task id - (node_id:task_number) - :arg actions: A comma-separated list of actions that should be - cancelled. Leave empty to cancel all. - :arg nodes: 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 parent_task_id: Cancel tasks with specified parent task id - (node_id:task_number). Set to -1 to cancel all. - :arg wait_for_completion: Should the request block until the - cancellation of the task and its descendant tasks is completed. Defaults - to false + :param task_id: Return the task with specified id (node_id:task_number) + :param timeout: Explicit operation timeout + :param wait_for_completion: Wait for the matching tasks to complete (default: + false) """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "POST", - _make_path("_tasks", task_id, "_cancel"), - params=params, - headers=headers, - ) - - @query_params("timeout", "wait_for_completion") - def get(self, task_id, params=None, headers=None): + if task_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'task_id'") + __path = f"/_tasks/{_quote(task_id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if wait_for_completion is not None: + __query["wait_for_completion"] = wait_for_completion + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def list( + self, + *, + actions: Optional[Union[List[str], str]] = None, + detailed: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + group_by: Optional[Any] = None, + human: Optional[bool] = None, + nodes: Optional[List[str]] = None, + parent_task_id: Optional[Any] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + wait_for_completion: Optional[bool] = None, + ) -> Any: """ - Returns information about a task. + Returns a list of tasks. ``_ - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - - :arg task_id: Return the task with specified id - (node_id:task_number) - :arg timeout: Explicit operation timeout - :arg wait_for_completion: Wait for the matching tasks to - complete (default: false) + :param actions: A comma-separated list of actions that should be returned. Leave + empty to return all. + :param detailed: Return detailed task information (default: false) + :param group_by: Group tasks by nodes or parent/child relationships + :param nodes: 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 + :param parent_task_id: Return tasks with specified parent task id (node_id:task_number). + Set to -1 to return all. + :param timeout: Explicit operation timeout + :param wait_for_completion: Wait for the matching tasks to complete (default: + false) """ - client, params = _deprecated_options(self, params) - if task_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'task_id'.") - - return client._perform_request( - "GET", _make_path("_tasks", task_id), params=params, headers=headers - ) + __path = "/_tasks" + __query: Dict[str, Any] = {} + if actions is not None: + __query["actions"] = actions + if detailed is not None: + __query["detailed"] = detailed + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if group_by is not None: + __query["group_by"] = group_by + if human is not None: + __query["human"] = human + if nodes is not None: + __query["nodes"] = nodes + if parent_task_id is not None: + __query["parent_task_id"] = parent_task_id + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if wait_for_completion is not None: + __query["wait_for_completion"] = wait_for_completion + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) diff --git a/elasticsearch/_sync/client/tasks.pyi b/elasticsearch/_sync/client/tasks.pyi deleted file mode 100644 index 7524881f1..000000000 --- a/elasticsearch/_sync/client/tasks.pyi +++ /dev/null @@ -1,87 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class TasksClient(NamespacedClient): - def list( - self, - *, - actions: Optional[Any] = ..., - detailed: Optional[Any] = ..., - group_by: Optional[Any] = ..., - nodes: Optional[Any] = ..., - parent_task_id: Optional[Any] = ..., - timeout: Optional[Any] = ..., - wait_for_completion: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def cancel( - self, - *, - task_id: Optional[Any] = ..., - actions: Optional[Any] = ..., - nodes: Optional[Any] = ..., - parent_task_id: Optional[Any] = ..., - wait_for_completion: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get( - self, - task_id: Any, - *, - timeout: Optional[Any] = ..., - wait_for_completion: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_sync/client/text_structure.py b/elasticsearch/_sync/client/text_structure.py index a3b266c9d..694f75e19 100644 --- a/elasticsearch/_sync/client/text_structure.py +++ b/elasticsearch/_sync/client/text_structure.py @@ -15,76 +15,144 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, query_params +from .utils import _quote_query, _rewrite_parameters class TextStructureClient(NamespacedClient): - @query_params( - "charset", - "column_names", - "delimiter", - "explain", - "format", - "grok_pattern", - "has_header_row", - "line_merge_size_limit", - "lines_to_sample", - "quote", - "should_trim_fields", - "timeout", - "timestamp_field", - "timestamp_format", + @_rewrite_parameters( + body_name="text_files", ) - def find_structure(self, body, params=None, headers=None): + def find_structure( + self, + *, + text_files: List[Any], + charset: Optional[str] = None, + column_names: Optional[str] = None, + delimiter: Optional[str] = None, + explain: Optional[bool] = None, + format: Optional[str] = None, + grok_pattern: Optional[str] = None, + has_header_row: Optional[bool] = None, + line_merge_size_limit: Optional[int] = None, + lines_to_sample: Optional[int] = None, + quote: Optional[str] = None, + should_trim_fields: Optional[bool] = None, + timeout: Optional[Any] = None, + timestamp_field: Optional[Any] = None, + timestamp_format: Optional[str] = None, + ) -> Any: """ - Finds the structure of a text file. The text file must contain data that is - suitable to be ingested into Elasticsearch. + 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 + :param text_files: + :param charset: The text’s character set. It must be a character set that is + supported by the JVM that Elasticsearch uses. For example, UTF-8, UTF-16LE, + windows-1252, or EUC-JP. If this parameter is not specified, the structure + finder chooses an appropriate character set. + :param column_names: If you have set format to delimited, you can specify the + column names in a comma-separated list. If this parameter is not specified, + the structure finder uses the column names from the header row of the text. + If the text does not have a header role, columns are named "column1", "column2", + "column3", etc. + :param delimiter: If you have set format to delimited, you can specify the character + used to delimit the values in each row. Only a single character is supported; + the delimiter cannot have multiple characters. By default, the API considers + the following possibilities: comma, tab, semi-colon, and pipe (|). In this + default scenario, all rows must have the same number of fields for the delimited + format to be detected. If you specify a delimiter, up to 10% of the rows + can have a different number of columns than the first row. + :param explain: If this parameter is set to true, the response includes a field + named explanation, which is an array of strings that indicate how the structure + finder produced its result. + :param format: The high level structure of the text. Valid values are ndjson, + xml, delimited, and semi_structured_text. By default, the API chooses the + format. In this default scenario, all rows must have the same number of fields + for a delimited format to be detected. If the format is set to delimited + and the delimiter is not set, however, the API tolerates up to 5% of rows + that have a different number of columns than the first row. + :param grok_pattern: If you have set format to semi_structured_text, you can + specify a Grok pattern that is used to extract fields from every message + in the text. The name of the timestamp field in the Grok pattern must match + what is specified in the timestamp_field parameter. If that parameter is + not specified, the name of the timestamp field in the Grok pattern must match + "timestamp". If grok_pattern is not specified, the structure finder creates + a Grok pattern. + :param has_header_row: If you have set format to delimited, you can use this + parameter to indicate whether the column names are in the first row of the + text. If this parameter is not specified, the structure finder guesses based + on the similarity of the first row of the text to other rows. + :param line_merge_size_limit: The maximum number of characters in a message when + lines are merged to form messages while analyzing semi-structured text. If + you have extremely long messages you may need to increase this, but be aware + that this may lead to very long processing times if the way to group lines + into messages is misdetected. + :param lines_to_sample: The number of lines to include in the structural analysis, + starting from the beginning of the text. The minimum is 2; If the value of + this parameter is greater than the number of lines in the text, the analysis + proceeds (as long as there are at least two lines in the text) for all of + the lines. + :param quote: If you have set format to delimited, you can specify the character + used to quote the values in each row if they contain newlines or the delimiter + character. Only a single character is supported. If this parameter is not + specified, the default value is a double quote ("). If your delimited text + format does not use quoting, a workaround is to set this argument to a character + that does not appear anywhere in the sample. + :param should_trim_fields: If you have set format to delimited, you can specify + whether values between delimiters should have whitespace trimmed from them. + If this parameter is not specified and the delimiter is pipe (|), the default + value is true. Otherwise, the default value is false. + :param timeout: Sets the maximum amount of time that the structure analysis make + take. If the analysis is still running when the timeout expires then it will + be aborted. + :param timestamp_field: Optional parameter to specify the timestamp field in the file - :arg column_names: Optional parameter containing a comma - separated list of the column names for a delimited file - :arg delimiter: Optional parameter to specify the delimiter - character for a delimited file - must be a single character - :arg explain: Whether to include a commentary on how the - structure was derived - :arg format: Optional parameter to specify the high level file - format Valid choices: ndjson, xml, delimited, semi_structured_text - :arg grok_pattern: Optional parameter to specify the Grok - pattern that should be used to extract fields from messages in a semi- - structured text file - :arg has_header_row: Optional parameter to specify whether a - delimited file includes the column names in its first row - :arg line_merge_size_limit: Maximum number of characters - permitted in a single message when lines are merged to create messages. - Default: 10000 - :arg lines_to_sample: How many lines of the file should be - included in the analysis Default: 1000 - :arg quote: Optional parameter to specify the quote character - for a delimited file - must be a single character - :arg should_trim_fields: Optional parameter to specify whether - the values between delimiters in a delimited file should have whitespace - trimmed from them - :arg timeout: Timeout after which the analysis will be aborted - Default: 25s - :arg timestamp_field: Optional parameter to specify the - timestamp field in the file - :arg timestamp_format: Optional parameter to specify the - timestamp format in the file - may be either a Joda or Java time format + :param timestamp_format: The Java time format of the timestamp field in the text. """ - client, params = _deprecated_options(self, params) - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - headers["content-type"] = "application/x-ndjson" - return client._perform_request( - "POST", - "/_text_structure/find_structure", - params=params, - headers=headers, - body=body, - ) + if text_files is None: + raise ValueError("Empty value passed for parameter 'text_files'") + __path = "/_text_structure/find_structure" + __query: Dict[str, Any] = {} + if charset is not None: + __query["charset"] = charset + if column_names is not None: + __query["column_names"] = column_names + if delimiter is not None: + __query["delimiter"] = delimiter + if explain is not None: + __query["explain"] = explain + if format is not None: + __query["format"] = format + if grok_pattern is not None: + __query["grok_pattern"] = grok_pattern + if has_header_row is not None: + __query["has_header_row"] = has_header_row + if line_merge_size_limit is not None: + __query["line_merge_size_limit"] = line_merge_size_limit + if lines_to_sample is not None: + __query["lines_to_sample"] = lines_to_sample + if quote is not None: + __query["quote"] = quote + if should_trim_fields is not None: + __query["should_trim_fields"] = should_trim_fields + if timeout is not None: + __query["timeout"] = timeout + if timestamp_field is not None: + __query["timestamp_field"] = timestamp_field + if timestamp_format is not None: + __query["timestamp_format"] = timestamp_format + __body = text_files + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = { + "accept": "application/json", + "content-type": "application/x-ndjson", + } + return self._perform_request("POST", __target, headers=__headers, body=__body) diff --git a/elasticsearch/_sync/client/text_structure.pyi b/elasticsearch/_sync/client/text_structure.pyi deleted file mode 100644 index c9c4cff75..000000000 --- a/elasticsearch/_sync/client/text_structure.pyi +++ /dev/null @@ -1,54 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class TextStructureClient(NamespacedClient): - def find_structure( - self, - *, - body: Any, - charset: Optional[Any] = ..., - column_names: Optional[Any] = ..., - delimiter: Optional[Any] = ..., - explain: Optional[Any] = ..., - format: Optional[Any] = ..., - grok_pattern: Optional[Any] = ..., - has_header_row: Optional[Any] = ..., - line_merge_size_limit: Optional[Any] = ..., - lines_to_sample: Optional[Any] = ..., - quote: Optional[Any] = ..., - should_trim_fields: Optional[Any] = ..., - timeout: Optional[Any] = ..., - timestamp_field: Optional[Any] = ..., - timestamp_format: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_sync/client/transform.py b/elasticsearch/_sync/client/transform.py index 24d9456a1..2996342bd 100644 --- a/elasticsearch/_sync/client/transform.py +++ b/elasticsearch/_sync/client/transform.py @@ -15,243 +15,523 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params +from .utils import SKIP_IN_PATH, _quote, _quote_query, _rewrite_parameters class TransformClient(NamespacedClient): - @query_params("force") - def delete_transform(self, transform_id, params=None, headers=None): + @_rewrite_parameters() + def delete_transform( + self, + *, + transform_id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + force: Optional[bool] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Deletes an existing transform. - ``_ + ``_ - :arg transform_id: The id of the transform to delete - :arg force: When `true`, the transform is deleted regardless of - its current state. The default value is `false`, meaning that the - transform must be `stopped` before it can be deleted. + :param transform_id: The id of the transform to delete + :param force: When `true`, the transform is deleted regardless of its current + state. The default value is `false`, meaning that the transform must be `stopped` + before it can be deleted. """ - client, params = _deprecated_options(self, params) if transform_id in SKIP_IN_PATH: - raise ValueError( - "Empty value passed for a required argument 'transform_id'." - ) - - return client._perform_request( - "DELETE", - _make_path("_transform", transform_id), - params=params, - headers=headers, - ) - - @query_params("allow_no_match", "exclude_generated", "from_", "size") - def get_transform(self, transform_id=None, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'transform_id'") + __path = f"/_transform/{_quote(transform_id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if force is not None: + __query["force"] = force + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters( + parameter_aliases={"from": "from_"}, + ) + def get_transform( + self, + *, + transform_id: Optional[Any] = None, + allow_no_match: Optional[bool] = None, + error_trace: Optional[bool] = None, + exclude_generated: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + from_: Optional[int] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + size: Optional[int] = None, + ) -> Any: """ 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 - 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 exclude_generated: Omits fields that are illegal to set on - transform PUT - :arg from\\_: skips a number of transform configs, defaults to 0 - :arg size: specifies a max number of transforms to get, defaults - to 100 + :param transform_id: The id or comma delimited list of id expressions of the + transforms to get, '_all' or '*' implies get all transforms + :param allow_no_match: Whether to ignore if a wildcard expression matches no + transforms. (This includes `_all` string or when no transforms have been + specified) + :param exclude_generated: Omits fields that are illegal to set on transform PUT + :param from_: skips a number of transform configs, defaults to 0 + :param size: specifies a max number of transforms to get, defaults to 100 """ - client, params = _deprecated_options(self, params) - if params and "from_" in params: - params["from"] = params.pop("from_") - - return client._perform_request( - "GET", - _make_path("_transform", transform_id), - params=params, - headers=headers, - ) - - @query_params("allow_no_match", "from_", "size") - def get_transform_stats(self, transform_id, params=None, headers=None): + if transform_id not in SKIP_IN_PATH: + __path = f"/_transform/{_quote(transform_id)}" + else: + __path = "/_transform" + __query: Dict[str, Any] = {} + if allow_no_match is not None: + __query["allow_no_match"] = allow_no_match + if error_trace is not None: + __query["error_trace"] = error_trace + if exclude_generated is not None: + __query["exclude_generated"] = exclude_generated + if filter_path is not None: + __query["filter_path"] = filter_path + if from_ is not None: + __query["from"] = from_ + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if size is not None: + __query["size"] = size + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + parameter_aliases={"from": "from_"}, + ) + def get_transform_stats( + self, + *, + transform_id: Any, + allow_no_match: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + from_: Optional[int] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + size: Optional[int] = None, + ) -> Any: """ 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 size: specifies a max number of transform stats to get, - defaults to 100 + :param transform_id: The id of the transform for which to get stats. '_all' or + '*' implies all transforms + :param allow_no_match: Whether to ignore if a wildcard expression matches no + transforms. (This includes `_all` string or when no transforms have been + specified) + :param from_: skips a number of transform stats, defaults to 0 + :param size: specifies a max number of transform stats to get, defaults to 100 """ - client, params = _deprecated_options(self, params) - if params and "from_" in params: - params["from"] = params.pop("from_") - if transform_id in SKIP_IN_PATH: - raise ValueError( - "Empty value passed for a required argument 'transform_id'." - ) - - return client._perform_request( - "GET", - _make_path("_transform", transform_id, "_stats"), - params=params, - headers=headers, - ) - - @query_params() + raise ValueError("Empty value passed for parameter 'transform_id'") + __path = f"/_transform/{_quote(transform_id)}/_stats" + __query: Dict[str, Any] = {} + if allow_no_match is not None: + __query["allow_no_match"] = allow_no_match + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if from_ is not None: + __query["from"] = from_ + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if size is not None: + __query["size"] = size + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) def preview_transform( - self, body=None, transform_id=None, params=None, headers=None - ): + self, + *, + transform_id: Optional[Any] = None, + description: Optional[str] = None, + dest: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + frequency: Optional[Any] = None, + human: Optional[bool] = None, + latest: Optional[Any] = None, + pivot: Optional[Any] = None, + pretty: Optional[bool] = None, + retention_policy: Optional[Any] = None, + settings: Optional[Any] = None, + source: Optional[Any] = None, + sync: Optional[Any] = None, + ) -> Any: """ Previews a transform. - ``_ - - :arg body: The definition for the transform to preview - :arg transform_id: The id of the transform to preview. + ``_ + + :param transform_id: The id of the transform to preview. + :param description: Free text description of the transform. + :param dest: The destination for the transform. + :param frequency: The interval between checks for changes in the source indices + when the transform is running continuously. Also determines the retry interval + in the event of transient failures while the transform is searching or indexing. + The minimum value is 1s and the maximum is 1h. + :param latest: The latest method transforms the data by finding the latest document + for each unique key. + :param pivot: The pivot method transforms the data by aggregating and grouping + it. These objects define the group by fields and the aggregation to reduce + the data. + :param retention_policy: Defines a retention policy for the transform. Data that + meets the defined criteria is deleted from the destination index. + :param settings: Defines optional transform settings. + :param source: The source of the data for the transform. + :param sync: Defines the properties transforms require to run continuously. """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "POST", - _make_path("_transform", transform_id, "_preview"), - params=params, - headers=headers, - body=body, - ) - - @query_params("defer_validation") - def put_transform(self, transform_id, body, params=None, headers=None): + if transform_id not in SKIP_IN_PATH: + __path = f"/_transform/{_quote(transform_id)}/_preview" + else: + __path = "/_transform/_preview" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if description is not None: + __body["description"] = description + if dest is not None: + __body["dest"] = dest + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if frequency is not None: + __body["frequency"] = frequency + if human is not None: + __query["human"] = human + if latest is not None: + __body["latest"] = latest + if pivot is not None: + __body["pivot"] = pivot + if pretty is not None: + __query["pretty"] = pretty + if retention_policy is not None: + __body["retention_policy"] = retention_policy + if settings is not None: + __body["settings"] = settings + if source is not None: + __body["source"] = source + if sync is not None: + __body["sync"] = sync + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, + ) + def put_transform( + self, + *, + transform_id: Any, + dest: Any, + source: Any, + defer_validation: Optional[bool] = None, + description: Optional[str] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + frequency: Optional[Any] = None, + human: Optional[bool] = None, + latest: Optional[Any] = None, + pivot: Optional[Any] = None, + pretty: Optional[bool] = None, + retention_policy: Optional[Any] = None, + settings: Optional[Any] = None, + sync: Optional[Any] = None, + ) -> Any: """ Instantiates a transform. - ``_ - - :arg transform_id: The id of the new transform. - :arg body: The transform definition - :arg defer_validation: If validations should be deferred until - transform starts, defaults to false. + ``_ + + :param transform_id: Identifier for the transform. This identifier can contain + lowercase alphanumeric characters (a-z and 0-9), hyphens, and underscores. + It must start and end with alphanumeric characters. + :param dest: The destination for the transform. + :param source: The source of the data for the transform. + :param defer_validation: When true, deferrable validations are not run. This + behavior may be desired if the source index does not exist until after the + transform is created. + :param description: Free text description of the transform. + :param frequency: The interval between checks for changes in the source indices + when the transform is running continuously. Also determines the retry interval + in the event of transient failures while the transform is searching or indexing. + The minimum value is 1s and the maximum is 1h. + :param latest: The latest method transforms the data by finding the latest document + for each unique key. + :param pivot: The pivot method transforms the data by aggregating and grouping + it. These objects define the group by fields and the aggregation to reduce + the data. + :param retention_policy: Defines a retention policy for the transform. Data that + meets the defined criteria is deleted from the destination index. + :param settings: Defines optional transform settings. + :param sync: Defines the properties transforms require to run continuously. """ - client, params = _deprecated_options(self, params) - for param in (transform_id, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "PUT", - _make_path("_transform", transform_id), - params=params, - headers=headers, - body=body, - ) - - @query_params("timeout") - def start_transform(self, transform_id, params=None, headers=None): + if transform_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'transform_id'") + if dest is None: + raise ValueError("Empty value passed for parameter 'dest'") + if source is None: + raise ValueError("Empty value passed for parameter 'source'") + __path = f"/_transform/{_quote(transform_id)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if dest is not None: + __body["dest"] = dest + if source is not None: + __body["source"] = source + if defer_validation is not None: + __query["defer_validation"] = defer_validation + if description is not None: + __body["description"] = description + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if frequency is not None: + __body["frequency"] = frequency + if human is not None: + __query["human"] = human + if latest is not None: + __body["latest"] = latest + if pivot is not None: + __body["pivot"] = pivot + if pretty is not None: + __query["pretty"] = pretty + if retention_policy is not None: + __body["retention_policy"] = retention_policy + if settings is not None: + __body["settings"] = settings + if sync is not None: + __body["sync"] = sync + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("PUT", __target, headers=__headers, body=__body) + + @_rewrite_parameters() + def start_transform( + self, + *, + transform_id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + ) -> Any: """ 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 - start + :param transform_id: The id of the transform to start + :param timeout: Controls the time to wait for the transform to start """ - client, params = _deprecated_options(self, params) if transform_id in SKIP_IN_PATH: - raise ValueError( - "Empty value passed for a required argument 'transform_id'." - ) - - return client._perform_request( - "POST", - _make_path("_transform", transform_id, "_start"), - params=params, - headers=headers, - ) - - @query_params( - "allow_no_match", - "force", - "timeout", - "wait_for_checkpoint", - "wait_for_completion", - ) - def stop_transform(self, transform_id, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'transform_id'") + __path = f"/_transform/{_quote(transform_id)}/_start" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters() + def stop_transform( + self, + *, + transform_id: Any, + allow_no_match: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + force: Optional[bool] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + timeout: Optional[Any] = None, + wait_for_checkpoint: Optional[bool] = None, + wait_for_completion: Optional[bool] = None, + ) -> Any: """ 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 - matches no transforms. (This includes `_all` string or when no - transforms have been specified) - :arg force: Whether to force stop a failed transform or not. - Default to false - :arg timeout: Controls the time to wait until the transform has - stopped. Default to 30 seconds - :arg wait_for_checkpoint: Whether to wait for the transform to - reach a checkpoint before stopping. Default to false - :arg wait_for_completion: Whether to wait for the transform to - fully stop before returning or not. Default to false + ``_ + + :param transform_id: The id of the transform to stop + :param allow_no_match: Whether to ignore if a wildcard expression matches no + transforms. (This includes `_all` string or when no transforms have been + specified) + :param force: Whether to force stop a failed transform or not. Default to false + :param timeout: Controls the time to wait until the transform has stopped. Default + to 30 seconds + :param wait_for_checkpoint: Whether to wait for the transform to reach a checkpoint + before stopping. Default to false + :param wait_for_completion: Whether to wait for the transform to fully stop before + returning or not. Default to false """ - client, params = _deprecated_options(self, params) if transform_id in SKIP_IN_PATH: - raise ValueError( - "Empty value passed for a required argument 'transform_id'." - ) - - return client._perform_request( - "POST", - _make_path("_transform", transform_id, "_stop"), - params=params, - headers=headers, - ) - - @query_params("defer_validation") - def update_transform(self, transform_id, body, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'transform_id'") + __path = f"/_transform/{_quote(transform_id)}/_stop" + __query: Dict[str, Any] = {} + if allow_no_match is not None: + __query["allow_no_match"] = allow_no_match + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if force is not None: + __query["force"] = force + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if timeout is not None: + __query["timeout"] = timeout + if wait_for_checkpoint is not None: + __query["wait_for_checkpoint"] = wait_for_checkpoint + if wait_for_completion is not None: + __query["wait_for_completion"] = wait_for_completion + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + def update_transform( + self, + *, + transform_id: Any, + defer_validation: Optional[bool] = None, + description: Optional[str] = None, + dest: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + frequency: Optional[Any] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + retention_policy: Optional[Any] = None, + settings: Optional[Any] = None, + source: Optional[Any] = None, + sync: Optional[Any] = None, + ) -> Any: """ Updates certain properties of a transform. - ``_ - - :arg transform_id: The id of the transform. - :arg body: The update transform definition - :arg defer_validation: If validations should be deferred until - transform starts, defaults to false. - """ - client, params = _deprecated_options(self, params) - for param in (transform_id, body): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - return client._perform_request( - "POST", - _make_path("_transform", transform_id, "_update"), - params=params, - headers=headers, - body=body, - ) - - @query_params("dry_run") - def upgrade_transforms(self, params=None, headers=None): + ``_ + + :param transform_id: Identifier for the transform. This identifier can contain + lowercase alphanumeric characters (a-z and 0-9), hyphens, and underscores. + It must start and end with alphanumeric characters. + :param defer_validation: When true, deferrable validations are not run. This + behavior may be desired if the source index does not exist until after the + transform is created. + :param description: Free text description of the transform. + :param dest: The destination for the transform. + :param frequency: The interval between checks for changes in the source indices + when the transform is running continuously. Also determines the retry interval + in the event of transient failures while the transform is searching or indexing. + The minimum value is 1s and the maximum is 1h. + :param retention_policy: Defines a retention policy for the transform. Data that + meets the defined criteria is deleted from the destination index. + :param settings: Defines optional transform settings. + :param source: The source of the data for the transform. + :param sync: Defines the properties transforms require to run continuously. """ - Upgrades all transforms. - - ``_ - - :arg dry_run: Whether to only check for updates but don't - execute - """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "POST", "/_transform/_upgrade", params=params, headers=headers - ) + if transform_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'transform_id'") + __path = f"/_transform/{_quote(transform_id)}/_update" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if defer_validation is not None: + __query["defer_validation"] = defer_validation + if description is not None: + __body["description"] = description + if dest is not None: + __body["dest"] = dest + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if frequency is not None: + __body["frequency"] = frequency + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if retention_policy is not None: + __body["retention_policy"] = retention_policy + if settings is not None: + __body["settings"] = settings + if source is not None: + __body["source"] = source + if sync is not None: + __body["sync"] = sync + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("POST", __target, headers=__headers, body=__body) diff --git a/elasticsearch/_sync/client/transform.pyi b/elasticsearch/_sync/client/transform.pyi deleted file mode 100644 index 19dda59de..000000000 --- a/elasticsearch/_sync/client/transform.pyi +++ /dev/null @@ -1,196 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class TransformClient(NamespacedClient): - def delete_transform( - self, - transform_id: Any, - *, - force: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_transform( - self, - *, - transform_id: Optional[Any] = ..., - allow_no_match: Optional[Any] = ..., - exclude_generated: Optional[Any] = ..., - from_: Optional[Any] = ..., - size: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_transform_stats( - self, - transform_id: Any, - *, - allow_no_match: Optional[Any] = ..., - from_: Optional[Any] = ..., - size: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def preview_transform( - self, - *, - body: Optional[Any] = ..., - transform_id: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def put_transform( - self, - transform_id: Any, - *, - body: Any, - defer_validation: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def start_transform( - self, - transform_id: Any, - *, - timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def stop_transform( - self, - transform_id: Any, - *, - allow_no_match: Optional[Any] = ..., - force: Optional[Any] = ..., - timeout: Optional[Any] = ..., - wait_for_checkpoint: Optional[Any] = ..., - wait_for_completion: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def update_transform( - self, - transform_id: Any, - *, - body: Any, - defer_validation: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def upgrade_transforms( - self, - *, - dry_run: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_sync/client/utils.py b/elasticsearch/_sync/client/utils.py index 71ddccfb7..2148d7dae 100644 --- a/elasticsearch/_sync/client/utils.py +++ b/elasticsearch/_sync/client/utils.py @@ -26,10 +26,11 @@ Awaitable, Callable, Collection, + Dict, List, Mapping, - MutableMapping, Optional, + Set, Tuple, Type, TypeVar, @@ -41,15 +42,14 @@ DEFAULT, client_meta_version, parse_cloud_id, + percent_encode, url_to_node_config, ) from ..._version import __versionstr__ -from ...compat import quote, string_types, to_bytes, to_str, warn_stacklevel -from ...serializer import Serializer +from ...compat import to_bytes, to_str, warn_stacklevel if TYPE_CHECKING: - from ... import Elasticsearch from ._base import NamespacedClient # parts of URL to be omitted @@ -65,9 +65,19 @@ ] _TYPE_SYNC_SNIFF_CALLBACK = Callable[[Transport, SniffOptions], List[NodeConfig]] +_TRANSPORT_OPTIONS = { + "api_key", + "http_auth", + "request_timeout", + "opaque_id", + "headers", +} + +RT = TypeVar("RT") + def client_node_configs( - hosts: _TYPE_HOSTS, cloud_id: str, **kwargs: Any + hosts: Optional[_TYPE_HOSTS], cloud_id: Optional[str], **kwargs: Any ) -> List[NodeConfig]: if cloud_id is not None: if hosts is not None: @@ -76,6 +86,7 @@ def client_node_configs( ) node_configs = cloud_id_to_node_configs(cloud_id) else: + assert hosts is not None node_configs = hosts_to_node_configs(hosts) # Remove all values which are 'DEFAULT' to avoid overwriting actual defaults. @@ -185,7 +196,17 @@ def cloud_id_to_node_configs(cloud_id: str) -> List[NodeConfig]: ] -def _escape(value: Any) -> Union[bytes, str]: +def _base64_auth_header(auth_value: Union[str, List[str], Tuple[str, str]]) -> str: + """Takes either a 2-tuple or a base64-encoded string + and returns a base64-encoded string to be used + as an HTTP authorization header. + """ + if isinstance(auth_value, (list, tuple)): + return base64.b64encode(to_bytes(":".join(auth_value))).decode("ascii") + return to_str(auth_value) + + +def _escape(value: Any) -> str: """ 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. @@ -193,7 +214,7 @@ def _escape(value: Any) -> Union[bytes, str]: # make sequences into comma-separated stings if isinstance(value, (list, tuple)): - value = ",".join(value) + value = ",".join([_escape(item) for item in value]) # dates and datetimes into isoformat elif isinstance(value, (date, datetime)): @@ -204,176 +225,136 @@ def _escape(value: Any) -> Union[bytes, str]: value = str(value).lower() elif isinstance(value, bytes): - return value + return value.decode("utf-8", "surrogatepass") - # encode strings to utf-8 if not isinstance(value, str): - return str(value).encode("utf-8") - return value.encode("utf-8") - - -def _make_path(*parts: Any) -> str: - """ - 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: Tuple[str, ...] = ( - "pretty", - "human", - "error_trace", - "format", - "filter_path", -) -T = TypeVar("T") - - -def query_params( - *es_query_params: str, -) -> Callable[[T], T]: - """ - Decorator that pops all accepted parameters from method's kwargs and puts - them in the params argument. - """ - - def _wrapper(func: Any) -> Any: - @wraps(func) - def _wrapped(*args: Any, **kwargs: Any) -> Any: - 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") - - http_auth = kwargs.pop("http_auth", None) - api_key = kwargs.pop("api_key", None) - - if http_auth is not None and api_key is not None: - raise ValueError( - "Only one of 'http_auth' and 'api_key' may be passed at a time" - ) - elif http_auth is not None: - headers["authorization"] = f"Basic {_base64_auth_header(http_auth)}" - elif api_key is not None: - headers["authorization"] = f"ApiKey {_base64_auth_header(api_key)}" - - 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 + return str(value) + return value -def _bulk_body( - serializer: Serializer, body: Union[str, bytes, Collection[Any]] -) -> Union[str, bytes]: - # if not passed in a string, serialize items and join by newline - if not isinstance(body, string_types): - body = b"\n".join(map(serializer.dumps, body)) +def _quote(value: Any) -> str: + return percent_encode(_escape(value), ",*") - # bulk body must end with a newline - if isinstance(body, bytes): - if not body.endswith(b"\n"): - body += b"\n" - elif isinstance(body, str) and not body.endswith("\n"): - body += "\n" - return body - - -def _base64_auth_header( - auth_value: Union[List[str], Tuple[str, ...], str, bytes] -) -> str: - """Takes either a 2-tuple or a base64-encoded string - and returns a base64-encoded string to be used - as an HTTP authorization header. - """ - if isinstance(auth_value, (list, tuple)): - auth_value = base64.b64encode(to_bytes(":".join(auth_value))) - return to_str(auth_value) +def _quote_query(query: Dict[str, Any]) -> str: + return "&".join([f"{k}={percent_encode(_escape(v), ',*')}" for k, v in query.items()]) -def _deprecated_options( - client: Union["Elasticsearch", "NamespacedClient"], - params: Optional[MutableMapping[str, Any]], -) -> Tuple[Union["Elasticsearch", "NamespacedClient"], Optional[Mapping[str, Any]]]: - """Applies the deprecated logic for per-request options. When passed deprecated options - this function will convert them into a Elasticsearch.options() or encoded params""" - - if params: - options_kwargs = {} - opaque_id = params.pop("opaque_id", None) - api_key = params.pop("api_key", None) - http_auth = params.pop("http_auth", None) - headers = {} - if opaque_id is not None: - headers["x-opaque-id"] = opaque_id - if http_auth is not None and api_key is not None: +def _merge_kwargs_no_duplicates(kwargs: Dict[str, Any], values: Dict[str, Any]) -> None: + for key, val in values.items(): + if key in kwargs: raise ValueError( - "Only one of 'http_auth' and 'api_key' may be passed at a time" + f"Received multiple values for '{key}', specify parameters " + "directly instead of using 'body' or 'params'" ) - elif api_key is not None: - options_kwargs["api_key"] = api_key - elif http_auth is not None: - options_kwargs["basic_auth"] = http_auth - if headers: - options_kwargs["headers"] = headers - - request_timeout = params.pop("request_timeout", None) - if request_timeout is not None: - options_kwargs["request_timeout"] = request_timeout - - ignore = params.pop("ignore", None) - if ignore is not None: - options_kwargs["ignore_status"] = ignore - - if options_kwargs: - warnings.warn( - "Passing transport options in the API method is deprecated. Use 'Elasticsearch.options()' instead.", - category=DeprecationWarning, - stacklevel=warn_stacklevel(), - ) - - # Namespaced clients need to unwrapped. - namespaced_client: Optional[Type["NamespacedClient"]] = None - if hasattr(client, "_client"): - namespaced_client = type(client) # type: ignore[assignment] - client = client._client # type: ignore[attr-defined,assignment,union-attr] - - client = client.options(**options_kwargs) - - # Re-wrap the client if we unwrapped due to being namespaced. - if namespaced_client is not None: - client = namespaced_client(client) - - # If there are any query params left we warn about API parameters. - if params: - warnings.warn( - "Passing options via 'params' is deprecated, instead use API parameters directly.", - category=DeprecationWarning, - stacklevel=warn_stacklevel(), - ) - - return client, params or None + kwargs[key] = val + + +def _rewrite_parameters( + body_name: Optional[str] = None, + body_fields: bool = False, + parameter_aliases: Optional[Dict[str, str]] = None, + ignore_deprecated_options: Optional[Union[bool, Set[str]]] = None, +) -> Callable[[Callable[..., RT]], Callable[..., RT]]: + def wrapper(api: Callable[..., RT]) -> Callable[..., RT]: + @wraps(api) + def wrapped(*args: Any, **kwargs: Any) -> RT: + nonlocal api, body_name, body_fields + + # We merge 'params' first as transport options can be specified using params. + if "params" in kwargs and ( + ignore_deprecated_options is not True + or ignore_deprecated_options is not None + or "params" not in ignore_deprecated_options + ): + params = kwargs.pop("params") + if params: + if not hasattr(params, "items"): + raise ValueError( + "Couldn't merge 'params' with other parameters as it wasn't a mapping. " + "Instead of using 'params' use individual API parameters" + ) + _merge_kwargs_no_duplicates(kwargs, params) + + if ignore_deprecated_options is not True: + transport_options = {} + options_to_skip: Set[str] = ( + ignore_deprecated_options + if isinstance(ignore_deprecated_options, set) + else set() + ) + for option in _TRANSPORT_OPTIONS: + if option in options_to_skip: + continue + try: + transport_options[option] = kwargs.pop(option) + except KeyError: + pass + if transport_options: + warnings.warn( + "Passing transport options in the API method is deprecated. Use 'Elasticsearch.options()' instead.", + category=DeprecationWarning, + stacklevel=warn_stacklevel(), + ) + client = args[0] + + # Namespaced clients need to unwrapped. + namespaced_client: Optional[Type["NamespacedClient"]] = None + if hasattr(client, "_client"): + namespaced_client = type(client) + client = client._client + + client = client.options(**transport_options) + + # Re-wrap the client if we unwrapped due to being namespaced. + if namespaced_client is not None: + client = namespaced_client(client) + args = (client,) + args[1:] + + if "body" in kwargs and ignore_deprecated_options is not True: + body = kwargs.pop("body") + if body is not None: + if body_name: + if body_name in kwargs: + raise TypeError( + "Can't use '%s' and 'body' parameters together because '%s' " + "is an alias for 'body'. Instead you should only use the " + "'%s' parameter. See https://github.com/elastic/elasticsearch-py/" + "issues/1698 for more information" + % ( + body_name, + body_name, + body_name, + ) + ) + + warnings.warn( + "The 'body' parameter is deprecated for the '%s' API and " + "will be removed in a future version. Instead use the '%s' parameter. " + "See https://github.com/elastic/elasticsearch-py/issues/1698 " + "for more information" % (str(api.__name__), body_name), + category=DeprecationWarning, + stacklevel=warn_stacklevel(), + ) + kwargs[body_name] = body + + elif body_fields: + if not hasattr(body, "items"): + raise ValueError( + "Couldn't merge 'body' with other parameters as it wasn't a mapping. " + "Instead of using 'body' use individual API parameters" + ) + _merge_kwargs_no_duplicates(kwargs, body) + + if parameter_aliases: + for alias, rename_to in parameter_aliases.items(): + try: + kwargs[rename_to] = kwargs.pop(alias) + except KeyError: + pass + + return api(*args, **kwargs) + + return wrapped + + return wrapper diff --git a/elasticsearch/_sync/client/watcher.py b/elasticsearch/_sync/client/watcher.py index a92a0f0a1..1f12a89b7 100644 --- a/elasticsearch/_sync/client/watcher.py +++ b/elasticsearch/_sync/client/watcher.py @@ -15,218 +15,525 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _deprecated_options, _make_path, query_params +from .utils import SKIP_IN_PATH, _quote, _quote_query, _rewrite_parameters class WatcherClient(NamespacedClient): - @query_params() - def ack_watch(self, watch_id, action_id=None, params=None, headers=None): + @_rewrite_parameters() + def ack_watch( + self, + *, + watch_id: Any, + action_id: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ 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 - acked + :param watch_id: Watch ID + :param action_id: A comma-separated list of the action ids to be acked """ - client, params = _deprecated_options(self, params) if watch_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'watch_id'.") - - return client._perform_request( - "PUT", - _make_path("_watcher", "watch", watch_id, "_ack", action_id), - params=params, - headers=headers, - ) - - @query_params() - def activate_watch(self, watch_id, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'watch_id'") + if watch_id not in SKIP_IN_PATH and action_id not in SKIP_IN_PATH: + __path = f"/_watcher/watch/{_quote(watch_id)}/_ack/{_quote(action_id)}" + elif watch_id not in SKIP_IN_PATH: + __path = f"/_watcher/watch/{_quote(watch_id)}/_ack" + else: + raise ValueError("Couldn't find a path for the given parameters") + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("PUT", __target, headers=__headers) + + @_rewrite_parameters() + def activate_watch( + self, + *, + watch_id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Activates a currently inactive watch. - ``_ + ``_ - :arg watch_id: Watch ID + :param watch_id: Watch ID """ - client, params = _deprecated_options(self, params) if watch_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'watch_id'.") - - return client._perform_request( - "PUT", - _make_path("_watcher", "watch", watch_id, "_activate"), - params=params, - headers=headers, - ) - - @query_params() - def deactivate_watch(self, watch_id, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'watch_id'") + __path = f"/_watcher/watch/{_quote(watch_id)}/_activate" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("PUT", __target, headers=__headers) + + @_rewrite_parameters() + def deactivate_watch( + self, + *, + watch_id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Deactivates a currently active watch. - ``_ + ``_ - :arg watch_id: Watch ID + :param watch_id: Watch ID """ - client, params = _deprecated_options(self, params) if watch_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'watch_id'.") - - return client._perform_request( - "PUT", - _make_path("_watcher", "watch", watch_id, "_deactivate"), - params=params, - headers=headers, - ) - - @query_params() - def delete_watch(self, id, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'watch_id'") + __path = f"/_watcher/watch/{_quote(watch_id)}/_deactivate" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("PUT", __target, headers=__headers) + + @_rewrite_parameters() + def delete_watch( + self, + *, + id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Removes a watch from Watcher. - ``_ + ``_ - :arg id: Watch ID + :param id: Watch ID """ - client, params = _deprecated_options(self, params) if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'id'.") - - return client._perform_request( - "DELETE", - _make_path("_watcher", "watch", id), - params=params, - headers=headers, - ) - - @query_params("debug") - def execute_watch(self, body=None, id=None, params=None, headers=None): + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/_watcher/watch/{_quote(id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("DELETE", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + def execute_watch( + self, + *, + id: Optional[Any] = None, + action_modes: Optional[Dict[str, Any]] = None, + alternative_input: Optional[Dict[str, Any]] = None, + debug: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + ignore_condition: Optional[bool] = None, + pretty: Optional[bool] = None, + record_execution: Optional[bool] = None, + simulated_actions: Optional[Any] = None, + trigger_data: Optional[Any] = None, + watch: Optional[Any] = None, + ) -> Any: """ 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 + ``_ + + :param id: Watch ID + :param action_modes: + :param alternative_input: + :param debug: indicates whether the watch should execute in debug mode + :param ignore_condition: + :param record_execution: + :param simulated_actions: + :param trigger_data: + :param watch: """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "PUT", - _make_path("_watcher", "watch", id, "_execute"), - params=params, - headers=headers, - body=body, - ) - - @query_params() - def get_watch(self, id, params=None, headers=None): + if id not in SKIP_IN_PATH: + __path = f"/_watcher/watch/{_quote(id)}/_execute" + else: + __path = "/_watcher/watch/_execute" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if action_modes is not None: + __body["action_modes"] = action_modes + if alternative_input is not None: + __body["alternative_input"] = alternative_input + if debug is not None: + __query["debug"] = debug + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if ignore_condition is not None: + __body["ignore_condition"] = ignore_condition + if pretty is not None: + __query["pretty"] = pretty + if record_execution is not None: + __body["record_execution"] = record_execution + if simulated_actions is not None: + __body["simulated_actions"] = simulated_actions + if trigger_data is not None: + __body["trigger_data"] = trigger_data + if watch is not None: + __body["watch"] = watch + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("PUT", __target, headers=__headers, body=__body) + + @_rewrite_parameters() + def get_watch( + self, + *, + id: Any, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Retrieves a watch by its ID. - ``_ + ``_ - :arg id: Watch ID + :param id: Watch ID """ - client, params = _deprecated_options(self, params) if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'id'.") - - return client._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): + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/_watcher/watch/{_quote(id)}" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters( + body_fields=True, + ) + def put_watch( + self, + *, + id: Any, + actions: Optional[Dict[str, Any]] = None, + active: Optional[bool] = None, + condition: Optional[Any] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + if_primary_term: Optional[int] = None, + if_sequence_number: Optional[int] = None, + input: Optional[Any] = None, + metadata: Optional[Any] = None, + pretty: Optional[bool] = None, + throttle_period: Optional[str] = None, + transform: Optional[Any] = None, + trigger: Optional[Any] = None, + version: Optional[Any] = None, + ) -> Any: """ Creates a new watch, or updates an existing one. - ``_ - - :arg id: Watch ID - :arg body: The watch - :arg active: Specify whether the watch is in/active by default - :arg if_primary_term: only update the watch if the last - operation that has changed the watch has the specified primary term - :arg if_seq_no: only update the watch if the last operation that - has changed the watch has the specified sequence number - :arg version: Explicit version number for concurrency control + ``_ + + :param id: Watch ID + :param actions: + :param active: Specify whether the watch is in/active by default + :param condition: + :param if_primary_term: only update the watch if the last operation that has + changed the watch has the specified primary term + :param if_sequence_number: + :param input: + :param metadata: + :param throttle_period: + :param transform: + :param trigger: + :param version: Explicit version number for concurrency control """ - client, params = _deprecated_options(self, params) if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'id'.") + raise ValueError("Empty value passed for parameter 'id'") + __path = f"/_watcher/watch/{_quote(id)}" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if actions is not None: + __body["actions"] = actions + if active is not None: + __query["active"] = active + if condition is not None: + __body["condition"] = condition + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if if_primary_term is not None: + __query["if_primary_term"] = if_primary_term + if if_sequence_number is not None: + __query["if_sequence_number"] = if_sequence_number + if input is not None: + __body["input"] = input + if metadata is not None: + __body["metadata"] = metadata + if pretty is not None: + __query["pretty"] = pretty + if throttle_period is not None: + __body["throttle_period"] = throttle_period + if transform is not None: + __body["transform"] = transform + if trigger is not None: + __body["trigger"] = trigger + if version is not None: + __query["version"] = version + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("PUT", __target, headers=__headers, body=__body) + + @_rewrite_parameters( + body_fields=True, + parameter_aliases={"from": "from_"}, + ) + def query_watches( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + from_: Optional[int] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + query: Optional[Any] = None, + search_after: Optional[Any] = None, + size: Optional[int] = None, + sort: Optional[Any] = None, + ) -> Any: + """ + Retrieves stored watches. - return client._perform_request( - "PUT", - _make_path("_watcher", "watch", id), - params=params, - headers=headers, - body=body, - ) + ``_ - @query_params() - def start(self, params=None, headers=None): + :param from_: The offset from the first result to fetch. Needs to be non-negative. + :param query: Optional, query filter watches to be returned. + :param search_after: Optional search After to do pagination using last hit’s + sort values. + :param size: The number of hits to return. Needs to be non-negative. + :param sort: Optional sort definition. + """ + __path = "/_watcher/_query/watches" + __query: Dict[str, Any] = {} + __body: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if from_ is not None: + __body["from"] = from_ + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if query is not None: + __body["query"] = query + if search_after is not None: + __body["search_after"] = search_after + if size is not None: + __body["size"] = size + if sort is not None: + __body["sort"] = sort + if not __body: + __body = None # type: ignore[assignment] + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + if __body is not None: + __headers["content-type"] = "application/json" + return self._perform_request("POST", __target, headers=__headers, body=__body) + + @_rewrite_parameters() + def start( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Starts Watcher if it is not already running. - ``_ + ``_ """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "POST", "/_watcher/_start", params=params, headers=headers - ) - - @query_params("emit_stacktraces") - def stats(self, metric=None, params=None, headers=None): + __path = "/_watcher/_start" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) + + @_rewrite_parameters() + def stats( + self, + *, + metric: Optional[Union[Any, List[Any]]] = None, + emit_stacktraces: Optional[bool] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Retrieves the current Watcher metrics. - ``_ + ``_ - :arg metric: Controls what additional stat metrics should be - include in the response Valid choices: _all, queued_watches, - current_watches, pending_watches - :arg emit_stacktraces: Emits stack traces of currently running - watches + :param metric: Defines which additional metrics are included in the response. + :param emit_stacktraces: Defines whether stack traces are generated for each + watch that is running. """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", - _make_path("_watcher", "stats", metric), - params=params, - headers=headers, - ) - - @query_params() - def stop(self, params=None, headers=None): + if metric not in SKIP_IN_PATH: + __path = f"/_watcher/stats/{_quote(metric)}" + else: + __path = "/_watcher/stats" + __query: Dict[str, Any] = {} + if emit_stacktraces is not None: + __query["emit_stacktraces"] = emit_stacktraces + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) + + @_rewrite_parameters() + def stop( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Stops Watcher if it is running. - ``_ - """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "POST", "/_watcher/_stop", params=params, headers=headers - ) - - @query_params() - def query_watches(self, body=None, params=None, headers=None): - """ - Retrieves stored watches. - - ``_ - - :arg body: From, size, query, sort and search_after + ``_ """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "POST", - "/_watcher/_query/watches", - params=params, - headers=headers, - body=body, - ) + __path = "/_watcher/_stop" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("POST", __target, headers=__headers) diff --git a/elasticsearch/_sync/client/watcher.pyi b/elasticsearch/_sync/client/watcher.pyi deleted file mode 100644 index 01edd6b4a..000000000 --- a/elasticsearch/_sync/client/watcher.pyi +++ /dev/null @@ -1,218 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class WatcherClient(NamespacedClient): - def ack_watch( - self, - watch_id: Any, - *, - action_id: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def activate_watch( - self, - watch_id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def deactivate_watch( - self, - watch_id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def delete_watch( - self, - id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def execute_watch( - self, - *, - body: Optional[Any] = ..., - id: Optional[Any] = ..., - debug: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def get_watch( - self, - id: Any, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def put_watch( - self, - id: Any, - *, - body: Optional[Any] = ..., - active: Optional[Any] = ..., - if_primary_term: Optional[Any] = ..., - if_seq_no: Optional[Any] = ..., - version: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def start( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def stats( - self, - *, - metric: Optional[Any] = ..., - emit_stacktraces: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def stop( - self, - *, - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def query_watches( - self, - *, - body: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/_sync/client/xpack.py b/elasticsearch/_sync/client/xpack.py index 975adb035..62ab45d99 100644 --- a/elasticsearch/_sync/client/xpack.py +++ b/elasticsearch/_sync/client/xpack.py @@ -15,40 +15,87 @@ # specific language governing permissions and limitations # under the License. +from typing import Any, Dict, List, Optional, Union + from ._base import NamespacedClient -from .utils import _deprecated_options, query_params +from .utils import _quote_query, _rewrite_parameters class XPackClient(NamespacedClient): - def __getattr__(self, attr_name): + def __getattr__(self, attr_name: str) -> Any: return getattr(self.client, attr_name) # AUTO-GENERATED-API-DEFINITIONS # - @query_params("accept_enterprise", "categories") - def info(self, params=None, headers=None): + + @_rewrite_parameters() + def info( + self, + *, + categories: Optional[List[str]] = None, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Retrieves information about the installed X-Pack features. - ``_ + ``_ - :arg accept_enterprise: If this param is used it must be set to - true - :arg categories: Comma-separated list of info categories. Can be - any of: build, license, features + :param categories: Comma-separated list of info categories. Can be any of: build, + license, features """ - client, params = _deprecated_options(self, params) - return client._perform_request("GET", "/_xpack", params=params, headers=headers) + __path = "/_xpack" + __query: Dict[str, Any] = {} + if categories is not None: + __query["categories"] = categories + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) - @query_params("master_timeout") - def usage(self, params=None, headers=None): + @_rewrite_parameters() + def usage( + self, + *, + error_trace: Optional[bool] = None, + filter_path: Optional[Union[List[str], str]] = None, + human: Optional[bool] = None, + master_timeout: Optional[Any] = None, + pretty: Optional[bool] = None, + ) -> Any: """ Retrieves usage information about the installed X-Pack features. - ``_ + ``_ - :arg master_timeout: Specify timeout for watch write operation + :param master_timeout: Specify timeout for watch write operation """ - client, params = _deprecated_options(self, params) - return client._perform_request( - "GET", "/_xpack/usage", params=params, headers=headers - ) + __path = "/_xpack/usage" + __query: Dict[str, Any] = {} + if error_trace is not None: + __query["error_trace"] = error_trace + if filter_path is not None: + __query["filter_path"] = filter_path + if human is not None: + __query["human"] = human + if master_timeout is not None: + __query["master_timeout"] = master_timeout + if pretty is not None: + __query["pretty"] = pretty + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json"} + return self._perform_request("GET", __target, headers=__headers) diff --git a/elasticsearch/_sync/client/xpack.pyi b/elasticsearch/_sync/client/xpack.pyi deleted file mode 100644 index fde9262b8..000000000 --- a/elasticsearch/_sync/client/xpack.pyi +++ /dev/null @@ -1,62 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from typing import Any, Collection, MutableMapping, Optional, Tuple, Union - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient - -class XPackClient(NamespacedClient): - def __getattr__(self, attr_name: str) -> Any: - return getattr(self.client, attr_name) - # AUTO-GENERATED-API-DEFINITIONS # - def info( - self, - *, - accept_enterprise: Optional[Any] = ..., - categories: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... - def usage( - self, - *, - master_timeout: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - format: Optional[str] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - http_auth: Optional[Union[str, Tuple[str, str]]] = ..., - api_key: Optional[Union[str, Tuple[str, str]]] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ..., - ) -> ObjectApiResponse[None]: ... diff --git a/elasticsearch/compat.py b/elasticsearch/compat.py index 2f5faab99..c121828d0 100644 --- a/elasticsearch/compat.py +++ b/elasticsearch/compat.py @@ -18,19 +18,11 @@ import inspect import sys from pathlib import Path -from typing import Mapping, Tuple, Type, Union -from urllib.parse import quote -from urllib.parse import urlencode as _urlencode - -from elastic_transport.client_utils import percent_encode +from typing import Tuple, Type, Union string_types: Tuple[Type[str], Type[bytes]] = (str, bytes) -def urlencode(query: Mapping[str, str]) -> str: - return _urlencode(query, quote_via=percent_encode) - - def to_str(x: Union[str, bytes], encoding: str = "ascii") -> str: if not isinstance(x, str): return x.decode(encoding) @@ -83,7 +75,5 @@ def warn_stacklevel() -> int: "string_types", "to_str", "to_bytes", - "quote", - "urlencode", "warn_stacklevel", ] diff --git a/elasticsearch/helpers/actions.py b/elasticsearch/helpers/actions.py index c093e3b3e..834d6574b 100644 --- a/elasticsearch/helpers/actions.py +++ b/elasticsearch/helpers/actions.py @@ -690,7 +690,7 @@ def _change_doc_index(hits, index, op_type): try: # Verify if the target_index is data stream or index data_streams = target_client.indices.get_data_stream( - target_index, expand_wildcards="all" + name=target_index, expand_wildcards="all" ) is_data_stream = any( data_stream["name"] == target_index diff --git a/noxfile.py b/noxfile.py index 814e0b3a1..5c6f6c1c7 100644 --- a/noxfile.py +++ b/noxfile.py @@ -61,7 +61,7 @@ def format(session): session.run("python", "utils/run-unasync.py") session.run("isort", "--profile=black", *SOURCE_FILES) session.run("flynt", *SOURCE_FILES) - session.run("black", "--target-version=py36", *SOURCE_FILES) + session.run("python", "utils/run-black.py", *SOURCE_FILES) session.run("python", "utils/license-headers.py", "fix", *SOURCE_FILES) lint(session) @@ -72,7 +72,7 @@ def lint(session): session.install("flake8", "black", "mypy", "isort", "types-requests") session.run("isort", "--check", "--profile=black", *SOURCE_FILES) - session.run("black", "--target-version=py36", "--check", *SOURCE_FILES) + session.run("python", "utils/run-black.py", "--check", *SOURCE_FILES) session.run("flake8", *SOURCE_FILES) session.run("python", "utils/license-headers.py", "check", *SOURCE_FILES) diff --git a/setup.cfg b/setup.cfg index a635a95a0..f429aed7f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -6,7 +6,7 @@ ignore = E203, E266, E501, W503 [tool:pytest] junit_family=legacy -addopts = -vvv -p no:logging --cov-report=term-missing --cov=elasticsearch --cov-config=.coveragerc +addopts = -vvv --cov-report=term-missing --cov=elasticsearch --cov-config=.coveragerc [tool:isort] profile=black diff --git a/test_elasticsearch/test_async/test_transport.py b/test_elasticsearch/test_async/test_transport.py index 39b810840..87a025de9 100644 --- a/test_elasticsearch/test_async/test_transport.py +++ b/test_elasticsearch/test_async/test_transport.py @@ -243,16 +243,22 @@ async def test_client_meta_header_not_sent(self): calls = client.transport.node_pool.get().calls assert 1 == len(calls) - assert calls[0][1]["headers"] == {"content-type": "application/json"} + assert calls[0][1]["headers"] == { + "accept": "application/json", + "content-type": "application/json", + } async def test_body_surrogates_replaced_encoded_into_bytes(self): client = AsyncElasticsearch("http://localhost:9200", node_class=DummyNode) - await client.search(body="你好\uda6a") + await client.search(query={"match": "你好\uda6a"}) calls = client.transport.node_pool.get().calls assert 1 == len(calls) - assert calls[0][1]["body"] == b"\xe4\xbd\xa0\xe5\xa5\xbd\xed\xa9\xaa" + assert ( + calls[0][1]["body"] + == b'{"query":{"match":"\xe4\xbd\xa0\xe5\xa5\xbd\xed\xa9\xaa"}}' + ) def test_kwargs_passed_on_to_node_pool(self): dt = object() @@ -265,11 +271,12 @@ class MyConnection(object): def __init__(self, *_, **__): pass + async def perform_request(*_, **__): + pass + client = AsyncElasticsearch("http://localhost:9200", node_class=MyConnection) - assert 1 == len(client.transport.node_pool.all_nodes) - assert isinstance( - client.transport.node_pool.all_nodes.popitem()[1], MyConnection - ) + assert 1 == len(client.transport.node_pool) + assert isinstance(client.transport.node_pool.all()[0], MyConnection) async def test_request_will_fail_after_x_retries(self): client = AsyncElasticsearch( @@ -317,7 +324,7 @@ async def test_failed_connection_will_be_marked_as_dead(self): with pytest.raises(ConnectionError): await client.info() - assert 0 == len(client.transport.node_pool.alive_nodes) + assert 0 == len(client.transport.node_pool._alive_nodes) async def test_resurrected_connection_will_be_marked_as_live_on_success(self): client = AsyncElasticsearch( @@ -332,12 +339,12 @@ async def test_resurrected_connection_will_be_marked_as_live_on_success(self): assert node1 is not node2 client.transport.node_pool.mark_dead(node1) client.transport.node_pool.mark_dead(node2) - assert len(client.transport.node_pool.alive_nodes) == 0 + assert len(client.transport.node_pool._alive_nodes) == 0 await client.info() - assert len(client.transport.node_pool.alive_nodes) == 1 - assert len(client.transport.node_pool.dead_consecutive_failures) == 1 + assert len(client.transport.node_pool._alive_nodes) == 1 + assert len(client.transport.node_pool._dead_consecutive_failures) == 1 @pytest.mark.parametrize( ["nodes_info_response", "node_host"], @@ -379,8 +386,7 @@ async def test_sniff_on_start_ignores_sniff_timeout(self): assert client.transport._sniffing_task is not None await client.transport._sniffing_task - node_config = client.transport.node_pool.seed_nodes[0] - calls = client.transport.node_pool.all_nodes[node_config].calls + calls = client.transport.node_pool.all()[0].calls assert len(calls) == 1 assert calls[0] == ( @@ -406,15 +412,17 @@ async def test_sniff_uses_sniff_timeout(self): assert client.transport._sniffing_task is not None await client.transport._sniffing_task - node_config = client.transport.node_pool.seed_nodes[0] - calls = client.transport.node_pool.all_nodes[node_config].calls + calls = client.transport.node_pool.all()[0].calls assert len(calls) == 2 assert calls[0] == ( ("GET", "/"), { "body": None, - "headers": {"content-type": "application/json"}, + "headers": { + "accept": "application/json", + "content-type": "application/json", + }, "request_timeout": DEFAULT, }, ) @@ -438,8 +446,7 @@ async def test_sniff_on_start_awaits_before_request(self): await client.info() - node_config = client.transport.node_pool.seed_nodes[0] - calls = client.transport.node_pool.all_nodes[node_config].calls + calls = client.transport.node_pool.all()[0].calls assert len(calls) == 2 # The sniff request happens first. @@ -453,18 +460,18 @@ async def test_sniff_reuses_node_instances(self): sniff_on_start=True, ) - assert len(client.transport.node_pool.all_nodes) == 1 + assert len(client.transport.node_pool) == 1 await client.info() - assert len(client.transport.node_pool.all_nodes) == 1 + assert len(client.transport.node_pool) == 1 @pytest.mark.parametrize( - "bad_node_extras", - [{"exception": ConnectionError("Abandon ship!")}, {"status": 500}], + ["extra_key", "extra_value"], + [("exception", ConnectionError("Abandon ship!")), ("status", 500)], ) - async def test_sniff_on_node_failure_triggers(self, bad_node_extras): + async def test_sniff_on_node_failure_triggers(self, extra_key, extra_value): client = AsyncElasticsearch( [ - NodeConfig("http", "localhost", 9200, _extras=bad_node_extras), + NodeConfig("http", "localhost", 9200, _extras={extra_key: extra_value}), NodeConfig("http", "localhost", 9201, _extras={"data": CLUSTER_NODES}), ], node_class=DummyNode, @@ -483,7 +490,7 @@ async def test_sniff_on_node_failure_triggers(self, bad_node_extras): await client.transport._sniffing_task assert request_failed_in_error - assert len(client.transport.node_pool.all_nodes) == 3 + assert len(client.transport.node_pool) == 3 async def test_sniff_after_n_seconds(self, event_loop): client = AsyncElasticsearch( # noqa: F821 @@ -499,14 +506,14 @@ async def test_sniff_after_n_seconds(self, event_loop): await client.info() await asyncio.sleep(0) - assert 1 == len(client.transport.node_pool.all_nodes) + assert 1 == len(client.transport.node_pool) client.transport._last_sniffed_at = event_loop.time() - 5.1 await client.info() await client.transport._sniffing_task # Need to wait for the sniffing task to complete - assert 2 == len(client.transport.node_pool.all_nodes) + assert 2 == len(client.transport.node_pool) assert "http://1.1.1.1:123" in ( node.base_url for node in client.transport.node_pool.all() ) @@ -586,7 +593,7 @@ async def test_sniffing_master_only_filtered_by_default(self): ) await client.transport._async_call() - assert len(client.transport.node_pool.all_nodes) == 2 + assert len(client.transport.node_pool) == 2 async def test_sniff_node_callback(self): def sniffed_node_callback( @@ -613,7 +620,7 @@ def sniffed_node_callback( ) await client.transport._async_call() - assert len(client.transport.node_pool.all_nodes) == 2 + assert len(client.transport.node_pool) == 2 ports = {node.config.port for node in client.transport.node_pool.all()} assert ports == {9200, 124} @@ -649,7 +656,7 @@ def host_info_callback( == "The 'host_info_callback' parameter is deprecated in favor of 'sniffed_node_callback'" ) - assert len(client.transport.node_pool.all_nodes) == 2 + assert len(client.transport.node_pool) == 2 ports = {node.config.port for node in client.transport.node_pool.all()} assert ports == {9200, 124} @@ -676,7 +683,10 @@ async def test_unsupported_product_error(headers): ("GET", "/"), { "body": None, - "headers": {"content-type": "application/json"}, + "headers": { + "accept": "application/json", + "content-type": "application/json", + }, "request_timeout": DEFAULT, }, ) diff --git a/test_elasticsearch/test_client/test_cluster.py b/test_elasticsearch/test_client/test_cluster.py index a623f03ea..4e2acaf65 100644 --- a/test_elasticsearch/test_client/test_cluster.py +++ b/test_elasticsearch/test_client/test_cluster.py @@ -24,7 +24,7 @@ def test_stats_without_node_id(self): self.assert_url_called("GET", "/_cluster/stats") def test_stats_with_node_id(self): - self.client.cluster.stats("node-1") + self.client.cluster.stats(node_id="node-1") self.assert_url_called("GET", "/_cluster/stats/nodes/node-1") self.client.cluster.stats(node_id="node-2") diff --git a/test_elasticsearch/test_client/test_indices.py b/test_elasticsearch/test_client/test_indices.py index 2d71593bd..3cce6a0a2 100644 --- a/test_elasticsearch/test_client/test_indices.py +++ b/test_elasticsearch/test_client/test_indices.py @@ -22,15 +22,15 @@ class TestIndices(DummyTransportTestCase): def test_create_one_index(self): - self.client.indices.create("test-index") + self.client.indices.create(index="test-index") self.assert_url_called("PUT", "/test-index") def test_delete_multiple_indices(self): - self.client.indices.delete(["test-index", "second.index", "third/index"]) + self.client.indices.delete(index=["test-index", "second.index", "third/index"]) self.assert_url_called("DELETE", "/test-index,second.index,third%2Findex") def test_exists_index(self): - self.client.indices.exists("second.index,third/index") + self.client.indices.exists(index="second.index,third/index") self.assert_url_called("HEAD", "/second.index,third%2Findex") def test_passing_empty_value_for_required_param_raises_exception(self): @@ -40,3 +40,7 @@ def test_passing_empty_value_for_required_param_raises_exception(self): self.client.indices.exists(index=[]) with pytest.raises(ValueError): self.client.indices.exists(index="") + + def test_query_params(self): + self.client.indices.delete(index=["test1", "test*"], expand_wildcards=["open", "closed"]) + self.assert_url_called("DELETE", "/test1,test*?expand_wildcards=open,closed") diff --git a/test_elasticsearch/test_client/test_options.py b/test_elasticsearch/test_client/test_options.py index bd2b0eb1c..e35b69e82 100644 --- a/test_elasticsearch/test_client/test_options.py +++ b/test_elasticsearch/test_client/test_options.py @@ -136,7 +136,13 @@ def test_options_passed_to_perform_request(self): assert call.pop("retry_on_timeout") is DEFAULT assert call.pop("retry_on_status") is DEFAULT assert call.pop("client_meta") is DEFAULT - assert call == {"headers": {"content-type": "application/json"}, "body": None} + assert call == { + "headers": { + "accept": "application/json", + "content-type": "application/json", + }, + "body": None, + } # Can be overwritten with .options() client.options( @@ -150,7 +156,10 @@ def test_options_passed_to_perform_request(self): call = calls[("GET", "/test")][1] assert call.pop("client_meta") is DEFAULT assert call == { - "headers": {"content-type": "application/json"}, + "headers": { + "accept": "application/json", + "content-type": "application/json", + }, "body": None, "request_timeout": 1, "max_retries": 2, @@ -173,7 +182,10 @@ def test_options_passed_to_perform_request(self): call = calls[("GET", "/test")][0] assert call.pop("client_meta") is DEFAULT assert call == { - "headers": {"content-type": "application/json"}, + "headers": { + "accept": "application/json", + "content-type": "application/json", + }, "body": None, "request_timeout": 1, "max_retries": 2, @@ -197,7 +209,13 @@ async def test_options_passed_to_async_perform_request(self): assert call.pop("retry_on_timeout") is DEFAULT assert call.pop("retry_on_status") is DEFAULT assert call.pop("client_meta") is DEFAULT - assert call == {"headers": {"content-type": "application/json"}, "body": None} + assert call == { + "headers": { + "accept": "application/json", + "content-type": "application/json", + }, + "body": None, + } # Can be overwritten with .options() await client.options( @@ -211,7 +229,10 @@ async def test_options_passed_to_async_perform_request(self): call = calls[("GET", "/test")][1] assert call.pop("client_meta") is DEFAULT assert call == { - "headers": {"content-type": "application/json"}, + "headers": { + "accept": "application/json", + "content-type": "application/json", + }, "body": None, "request_timeout": 1, "max_retries": 2, @@ -234,7 +255,10 @@ async def test_options_passed_to_async_perform_request(self): call = calls[("GET", "/test")][0] assert call.pop("client_meta") is DEFAULT assert call == { - "headers": {"content-type": "application/json"}, + "headers": { + "accept": "application/json", + "content-type": "application/json", + }, "body": None, "request_timeout": 1, "max_retries": 2, diff --git a/test_elasticsearch/test_client/test_overrides.py b/test_elasticsearch/test_client/test_overrides.py index bc3ea2ef3..cb415ea24 100644 --- a/test_elasticsearch/test_client/test_overrides.py +++ b/test_elasticsearch/test_client/test_overrides.py @@ -24,34 +24,21 @@ def test_create(self): self.client.create(index="test-index", id="test-id", body={}) self.assert_url_called("PUT", "/test-index/_create/test-id") - self.client.create( - index="test-index", doc_type="test-type", id="test-id", body={} - ) - self.assert_url_called("PUT", "/test-index/test-type/test-id/_create") - def test_delete(self): self.client.delete(index="test-index", id="test-id") self.assert_url_called("DELETE", "/test-index/_doc/test-id") - self.client.delete(index="test-index", doc_type="test-type", id="test-id") - self.assert_url_called("DELETE", "/test-index/test-type/test-id") - def test_index(self): - self.client.index(index="test-index", body={}) + self.client.index(index="test-index", document={}) self.assert_url_called("POST", "/test-index/_doc") - self.client.index(index="test-index", id="test-id", body={}) + self.client.index(index="test-index", id="test-id", document={}) self.assert_url_called("PUT", "/test-index/_doc/test-id") def test_update(self): self.client.update(index="test-index", id="test-id", body={}) self.assert_url_called("POST", "/test-index/_update/test-id") - self.client.update( - index="test-index", doc_type="test-type", id="test-id", body={} - ) - self.assert_url_called("POST", "/test-index/test-type/test-id/_update") - def test_cluster_state(self): self.client.cluster.state() self.assert_url_called("GET", "/_cluster/state") diff --git a/test_elasticsearch/test_client/test_utils.py b/test_elasticsearch/test_client/test_utils.py index e2c353397..3c245f397 100644 --- a/test_elasticsearch/test_client/test_utils.py +++ b/test_elasticsearch/test_client/test_utils.py @@ -18,143 +18,23 @@ from __future__ import unicode_literals -import pytest +from elasticsearch._sync.client.utils import _quote -from elasticsearch._sync.client.utils import ( - _bulk_body, - _escape, - _make_path, - query_params, -) +def test_handles_ascii(): + string = "abc123" + assert "abc123" == _quote(string) -class TestQueryParams: - def setup_method(self, _): - self.calls = [] - @query_params("simple_param") - def func_to_wrap(self, *args, **kwargs): - self.calls.append((args, kwargs)) +def test_handles_bytestring(): + string = b"celery-task-meta-c4f1201f-eb7b-41d5-9318-a75a8cfbdaa0" + assert string.decode() == _quote(string) - def test_handles_params(self): - self.func_to_wrap(params={"simple_param_2": "2"}, simple_param="3") - assert self.calls == [ - ( - (), - { - "params": {"simple_param": b"3", "simple_param_2": "2"}, - "headers": {}, - }, - ) - ] - def test_handles_headers(self): - self.func_to_wrap(headers={"X-Opaque-Id": "app-1"}) - assert self.calls == [((), {"params": {}, "headers": {"x-opaque-id": "app-1"}})] +def test_handles_unicode(): + assert "some-index-type-%E4%B8%AD%E6%96%87" == _quote("some-index-type-中文") - def test_handles_opaque_id(self): - self.func_to_wrap(opaque_id="request-id") - assert self.calls == [ - ((), {"params": {}, "headers": {"x-opaque-id": "request-id"}}) - ] - def test_handles_empty_none_and_normalization(self): - self.func_to_wrap(params=None) - assert self.calls[-1] == ((), {"params": {}, "headers": {}}) - - self.func_to_wrap(headers=None) - assert self.calls[-1] == ((), {"params": {}, "headers": {}}) - - self.func_to_wrap(headers=None, params=None) - assert self.calls[-1] == ((), {"params": {}, "headers": {}}) - - self.func_to_wrap(headers={}, params={}) - assert self.calls[-1] == ((), {"params": {}, "headers": {}}) - - self.func_to_wrap(headers={"X": "y"}) - assert self.calls[-1] == ((), {"params": {}, "headers": {"x": "y"}}) - - def test_per_call_authentication(self): - self.func_to_wrap(api_key=("name", "key")) - assert self.calls[-1] == ( - (), - {"headers": {"authorization": "ApiKey bmFtZTprZXk="}, "params": {}}, - ) - - self.func_to_wrap(http_auth=("user", "password")) - assert self.calls[-1] == ( - (), - { - "headers": {"authorization": "Basic dXNlcjpwYXNzd29yZA=="}, - "params": {}, - }, - ) - - self.func_to_wrap(http_auth="abcdef") - assert self.calls[-1] == ( - (), - {"headers": {"authorization": "Basic abcdef"}, "params": {}}, - ) - - # If one or the other is 'None' it's all good! - self.func_to_wrap(http_auth=None, api_key=None) - assert self.calls[-1] == ((), {"headers": {}, "params": {}}) - - self.func_to_wrap(http_auth="abcdef", api_key=None) - assert self.calls[-1] == ( - (), - {"headers": {"authorization": "Basic abcdef"}, "params": {}}, - ) - - # If both are given values an error is raised. - with pytest.raises(ValueError) as e: - self.func_to_wrap(http_auth="key", api_key=("1", "2")) - assert ( - str(e.value) - == "Only one of 'http_auth' and 'api_key' may be passed at a time" - ) - - -class TestMakePath: - def test_handles_unicode(self): - id = "中文" - assert "/some-index/type/%E4%B8%AD%E6%96%87" == _make_path( - "some-index", "type", id - ) - - -class TestEscape: - def test_handles_ascii(self): - string = "abc123" - assert b"abc123" == _escape(string) - - def test_handles_unicode(self): - string = "中文" - assert b"\xe4\xb8\xad\xe6\x96\x87" == _escape(string) - - def test_handles_bytestring(self): - string = b"celery-task-meta-c4f1201f-eb7b-41d5-9318-a75a8cfbdaa0" - assert string == _escape(string) - - -class TestBulkBody: - def test_proper_bulk_body_as_string_is_not_modified(self): - string_body = '"{"index":{ "_index" : "test"}}\n{"field1": "value1"}"\n' - assert string_body == _bulk_body(None, string_body) - - def test_proper_bulk_body_as_bytestring_is_not_modified(self): - bytestring_body = b'"{"index":{ "_index" : "test"}}\n{"field1": "value1"}"\n' - assert bytestring_body == _bulk_body(None, bytestring_body) - - def test_bulk_body_as_string_adds_trailing_newline(self): - string_body = '"{"index":{ "_index" : "test"}}\n{"field1": "value1"}"' - assert '"{"index":{ "_index" : "test"}}\n{"field1": "value1"}"\n' == _bulk_body( - None, string_body - ) - - def test_bulk_body_as_bytestring_adds_trailing_newline(self): - bytestring_body = b'"{"index":{ "_index" : "test"}}\n{"field1": "value1"}"' - assert ( - b'"{"index":{ "_index" : "test"}}\n{"field1": "value1"}"\n' - == _bulk_body(None, bytestring_body) - ) +def test_handles_unicode2(): + string = "中*文," + assert "%E4%B8%AD*%E6%96%87," == _quote(string) diff --git a/test_elasticsearch/test_server/test_clients.py b/test_elasticsearch/test_server/test_clients.py index df5145b01..e7c2a78e6 100644 --- a/test_elasticsearch/test_server/test_clients.py +++ b/test_elasticsearch/test_server/test_clients.py @@ -16,11 +16,12 @@ # specific language governing permissions and limitations # under the License. -from __future__ import unicode_literals +import pytest -def test_indices_analyze_unicode(sync_client): - resp = sync_client.indices.analyze(body='{"text": "привет"}') +@pytest.mark.parametrize("kwargs", [{"body": {"text": "привет"}}, {"text": "привет"}]) +def test_indices_analyze_unicode(sync_client, kwargs): + resp = sync_client.indices.analyze(**kwargs) assert resp == { "tokens": [ { diff --git a/test_elasticsearch/test_server/test_helpers.py b/test_elasticsearch/test_server/test_helpers.py index b21bf3e83..6b6742f01 100644 --- a/test_elasticsearch/test_server/test_helpers.py +++ b/test_elasticsearch/test_server/test_helpers.py @@ -279,11 +279,9 @@ def test_stats_only_reports_numbers(sync_client): def test_errors_are_reported_correctly(sync_client): sync_client.indices.create( - "i", - { - "mappings": {"properties": {"a": {"type": "integer"}}}, - "settings": {"number_of_shards": 1, "number_of_replicas": 0}, - }, + index="i", + mappings={"properties": {"a": {"type": "integer"}}}, + settings={"number_of_shards": 1, "number_of_replicas": 0}, ) sync_client.cluster.health(wait_for_status="yellow") @@ -306,11 +304,9 @@ def test_errors_are_reported_correctly(sync_client): def test_error_is_raised(sync_client): sync_client.indices.create( - "i", - { - "mappings": {"properties": {"a": {"type": "integer"}}}, - "settings": {"number_of_shards": 1, "number_of_replicas": 0}, - }, + index="i", + mappings={"properties": {"a": {"type": "integer"}}}, + settings={"number_of_shards": 1, "number_of_replicas": 0}, ) sync_client.cluster.health(wait_for_status="yellow") @@ -355,11 +351,9 @@ def test_ignore_error_if_raised(sync_client): def test_errors_are_collected_properly(sync_client): sync_client.indices.create( - "i", - { - "mappings": {"properties": {"a": {"type": "integer"}}}, - "settings": {"number_of_shards": 1, "number_of_replicas": 0}, - }, + index="i", + mappings={"properties": {"a": {"type": "integer"}}}, + settings={"number_of_shards": 1, "number_of_replicas": 0}, ) sync_client.cluster.health(wait_for_status="yellow") @@ -406,7 +400,7 @@ def test_order_can_be_preserved(sync_client): for x in range(100): bulk.append({"index": {"_index": "test_index", "_id": x}}) bulk.append({"answer": x, "correct": x == 42}) - sync_client.bulk(body=bulk, refresh=True) + sync_client.bulk(operations=bulk, refresh=True) docs = list( helpers.scan( @@ -428,7 +422,7 @@ def test_all_documents_are_read(sync_client): for x in range(100): bulk.append({"index": {"_index": "test_index", "_id": x}}) bulk.append({"answer": x, "correct": x == 42}) - sync_client.bulk(body=bulk, refresh=True) + sync_client.bulk(operations=bulk, refresh=True) docs = list(helpers.scan(sync_client, index="test_index", size=2)) @@ -443,7 +437,7 @@ def test_scroll_error(sync_client): for x in range(4): bulk.append({"index": {"_index": "test_index"}}) bulk.append({"value": x}) - sync_client.bulk(body=bulk, refresh=True) + sync_client.bulk(operations=bulk, refresh=True) with patch.object(sync_client, "options", return_value=sync_client), patch.object( sync_client, "scroll" @@ -667,7 +661,7 @@ def test_log_warning_on_shard_failures(sync_client): for x in range(4): bulk.append({"index": {"_index": "test_index"}}) bulk.append({"value": x}) - sync_client.bulk(bulk, refresh=True) + sync_client.bulk(operations=bulk, refresh=True) with patch("elasticsearch.helpers.actions.logger") as logger_mock, patch.object( sync_client, "options", return_value=sync_client @@ -705,7 +699,7 @@ def test_clear_scroll(sync_client): for x in range(4): bulk.append({"index": {"_index": "test_index"}}) bulk.append({"value": x}) - sync_client.bulk(bulk, refresh=True) + sync_client.bulk(operations=bulk, refresh=True) with patch.object(sync_client, "options", return_value=sync_client), patch.object( sync_client, "clear_scroll", wraps=sync_client.clear_scroll @@ -775,7 +769,7 @@ def reindex_setup(sync_client): "type": "answers" if x % 2 == 0 else "questions", } ) - sync_client.bulk(bulk, refresh=True) + sync_client.bulk(operations=bulk, refresh=True) @pytest.mark.usefixtures("reindex_setup") @@ -788,7 +782,7 @@ def test_reindex_passes_kwargs_to_scan_and_bulk(sync_client): bulk_kwargs={"refresh": True}, ) - assert sync_client.indices.exists("prod_index") + assert sync_client.indices.exists(index="prod_index") assert 50 == sync_client.count(index="prod_index", q="type:answers")["count"] assert {"answer": 42, "correct": True, "type": "answers"} == sync_client.get( @@ -806,7 +800,7 @@ def test_reindex_accepts_a_query(sync_client): ) sync_client.indices.refresh() - assert sync_client.indices.exists("prod_index") + assert sync_client.indices.exists(index="prod_index") assert 50 == sync_client.count(index="prod_index", q="type:answers")["count"] assert {"answer": 42, "correct": True, "type": "answers"} == sync_client.get( @@ -819,7 +813,7 @@ def test_all_documents_get_moved(sync_client): helpers.reindex(sync_client, "test_index", "prod_index") sync_client.indices.refresh() - assert sync_client.indices.exists("prod_index") + assert sync_client.indices.exists(index="prod_index") assert 50 == sync_client.count(index="prod_index", q="type:questions")["count"] assert 50 == sync_client.count(index="prod_index", q="type:answers")["count"] @@ -898,7 +892,7 @@ def reindex_data_stream_setup(sync_client): "@timestamp": (dt - timedelta(days=x)).isoformat(), } ) - sync_client.bulk(bulk, refresh=True) + sync_client.bulk(operations=bulk, refresh=True) sync_client.indices.put_index_template( name="my-index-template", body={ diff --git a/test_elasticsearch/test_transport.py b/test_elasticsearch/test_transport.py index c8fc1dbc0..7a744b1c7 100644 --- a/test_elasticsearch/test_transport.py +++ b/test_elasticsearch/test_transport.py @@ -16,8 +16,6 @@ # specific language governing permissions and limitations # under the License. -from __future__ import unicode_literals - import re import time import warnings @@ -250,7 +248,10 @@ def test_client_meta_header_not_sent(self): calls = client.transport.node_pool.get().calls assert 1 == len(calls) - assert calls[0][1]["headers"] == {"content-type": "application/json"} + assert calls[0][1]["headers"] == { + "accept": "application/json", + "content-type": "application/json", + } def test_meta_header_type_error(self): with pytest.raises(TypeError) as e: @@ -259,11 +260,14 @@ def test_meta_header_type_error(self): def test_body_surrogates_replaced_encoded_into_bytes(self): client = Elasticsearch("http://localhost:9200", node_class=DummyNode) - client.search(body="你好\uda6a") + client.search(query={"match": "你好\uda6a"}) calls = client.transport.node_pool.get().calls assert 1 == len(calls) - assert calls[0][1]["body"] == b"\xe4\xbd\xa0\xe5\xa5\xbd\xed\xa9\xaa" + assert ( + calls[0][1]["body"] + == b'{"query":{"match":"\xe4\xbd\xa0\xe5\xa5\xbd\xed\xa9\xaa"}}' + ) def test_kwargs_passed_on_to_node_pool(self): dt = object() @@ -275,11 +279,12 @@ class MyConnection(object): def __init__(self, *_, **__): pass + def perform_request(*_, **__): + pass + client = Elasticsearch("http://localhost:9200", node_class=MyConnection) - assert 1 == len(client.transport.node_pool.all_nodes) - assert isinstance( - client.transport.node_pool.all_nodes.popitem()[1], MyConnection - ) + assert 1 == len(client.transport.node_pool) + assert isinstance(client.transport.node_pool.all()[0], MyConnection) def test_request_will_fail_after_x_retries(self): client = Elasticsearch( @@ -327,7 +332,7 @@ def test_failed_connection_will_be_marked_as_dead(self): with pytest.raises(ConnectionError): client.info() - assert 0 == len(client.transport.node_pool.alive_nodes) + assert 0 == len(client.transport.node_pool._alive_nodes) def test_resurrected_connection_will_be_marked_as_live_on_success(self): client = Elasticsearch( @@ -342,12 +347,12 @@ def test_resurrected_connection_will_be_marked_as_live_on_success(self): assert node1 is not node2 client.transport.node_pool.mark_dead(node1) client.transport.node_pool.mark_dead(node2) - assert len(client.transport.node_pool.alive_nodes) == 0 + assert len(client.transport.node_pool._alive_nodes) == 0 client.info() - assert len(client.transport.node_pool.alive_nodes) == 1 - assert len(client.transport.node_pool.dead_consecutive_failures) == 1 + assert len(client.transport.node_pool._alive_nodes) == 1 + assert len(client.transport.node_pool._dead_consecutive_failures) == 1 @pytest.mark.parametrize( ["nodes_info_response", "node_host"], @@ -377,8 +382,7 @@ def test_sniff_on_start_ignores_sniff_timeout(self): meta_header=False, ) - node_config = client.transport.node_pool.seed_nodes[0] - calls = client.transport.node_pool.all_nodes[node_config].calls + calls = client.transport.node_pool.all()[0].calls assert len(calls) == 1 assert calls[0] == ( @@ -400,8 +404,7 @@ def test_sniff_uses_sniff_timeout(self): ) client.info() - node_config = client.transport.node_pool.seed_nodes[0] - calls = client.transport.node_pool.all_nodes[node_config].calls + calls = client.transport.node_pool.all()[0].calls assert len(calls) == 2 assert calls[0] == ( @@ -416,7 +419,10 @@ def test_sniff_uses_sniff_timeout(self): ("GET", "/"), { "body": None, - "headers": {"content-type": "application/json"}, + "headers": { + "accept": "application/json", + "content-type": "application/json", + }, "request_timeout": DEFAULT, }, ) @@ -428,9 +434,9 @@ def test_sniff_reuses_node_instances(self): sniff_on_start=True, ) - assert len(client.transport.node_pool.all_nodes) == 1 + assert len(client.transport.node_pool) == 1 client.info() - assert len(client.transport.node_pool.all_nodes) == 1 + assert len(client.transport.node_pool) == 1 def test_sniff_after_n_seconds(self): client = Elasticsearch( # noqa: F821 @@ -444,13 +450,13 @@ def test_sniff_after_n_seconds(self): for _ in range(4): client.info() - assert 1 == len(client.transport.node_pool.all_nodes) + assert 1 == len(client.transport.node_pool) client.transport._last_sniffed_at = time.time() - 5.1 client.info() - assert 2 == len(client.transport.node_pool.all_nodes) + assert 2 == len(client.transport.node_pool) assert "http://1.1.1.1:123" in ( node.base_url for node in client.transport.node_pool.all() ) @@ -493,7 +499,7 @@ def test_sniffing_master_only_filtered_by_default(self): sniff_on_start=True, ) - assert len(client.transport.node_pool.all_nodes) == 2 + assert len(client.transport.node_pool) == 2 def test_sniff_node_callback(self): def sniffed_node_callback( @@ -519,7 +525,7 @@ def sniffed_node_callback( sniffed_node_callback=sniffed_node_callback, ) - assert len(client.transport.node_pool.all_nodes) == 2 + assert len(client.transport.node_pool) == 2 ports = {node.config.port for node in client.transport.node_pool.all()} assert ports == {9200, 124} @@ -554,7 +560,7 @@ def host_info_callback( == "The 'host_info_callback' parameter is deprecated in favor of 'sniffed_node_callback'" ) - assert len(client.transport.node_pool.all_nodes) == 2 + assert len(client.transport.node_pool) == 2 ports = {node.config.port for node in client.transport.node_pool.all()} assert ports == {9200, 124} @@ -581,7 +587,10 @@ def test_unsupported_product_error(headers): ("GET", "/"), { "body": None, - "headers": {"content-type": "application/json"}, + "headers": { + "accept": "application/json", + "content-type": "application/json", + }, "request_timeout": DEFAULT, }, ) diff --git a/test_elasticsearch/utils.py b/test_elasticsearch/utils.py index ae848d34d..5489fff6d 100644 --- a/test_elasticsearch/utils.py +++ b/test_elasticsearch/utils.py @@ -182,7 +182,7 @@ def wipe_snapshots(client): """Deletes all the snapshots and repositories from the cluster""" in_progress_snapshots = [] - repos = client.snapshot.get_repository(repository="_all") + repos = client.snapshot.get_repository(name="_all") for repo_name, repo in repos.items(): if repo_name in {"found-snapshots"}: continue @@ -284,7 +284,7 @@ def wipe_ilm_policies(client): ".fleet-actions-results-ilm-policy", ".deprecation-indexing-ilm-policy", }: - client.ilm.delete_lifecycle(policy=policy) + client.ilm.delete_lifecycle(name=policy) def wipe_slm_policies(client): diff --git a/utils/generate-api.py b/utils/generate-api.py deleted file mode 100644 index de9f42d2b..000000000 --- a/utils/generate-api.py +++ /dev/null @@ -1,416 +0,0 @@ -#!/usr/bin/env python -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - - -import contextlib -import io -import json -import os -import re -import shutil -import sys -import tempfile -import zipfile -from functools import lru_cache -from itertools import chain -from pathlib import Path - -import black -import urllib3 -from click.testing import CliRunner -from jinja2 import Environment, FileSystemLoader, TemplateNotFound - -http = urllib3.PoolManager() - -# line to look for in the original source file -SEPARATOR = " # AUTO-GENERATED-API-DEFINITIONS #" -# global substitutions for python keywords -SUBSTITUTIONS = {"type": "doc_type", "from": "from_"} -# api path(s) -BRANCH_NAME = "master" -CODE_ROOT = Path(__file__).absolute().parent.parent -GLOBAL_QUERY_PARAMS = { - "pretty": "Optional[bool]", - "human": "Optional[bool]", - "error_trace": "Optional[bool]", - "format": "Optional[str]", - "filter_path": "Optional[Union[str, Collection[str]]]", - "request_timeout": "Optional[Union[int, float]]", - "ignore": "Optional[Union[int, Collection[int]]]", - "opaque_id": "Optional[str]", - "http_auth": "Optional[Union[str, Tuple[str, str]]]", - "api_key": "Optional[Union[str, Tuple[str, str]]]", -} - -jinja_env = Environment( - loader=FileSystemLoader([CODE_ROOT / "utils" / "templates"]), - trim_blocks=True, - lstrip_blocks=True, -) - - -def blacken(filename): - runner = CliRunner() - result = runner.invoke(black.main, [str(filename)]) - assert result.exit_code == 0, result.output - - -@lru_cache() -def is_valid_url(url): - return True - return 200 <= http.request("HEAD", url).status < 400 - - -class Module: - def __init__(self, namespace, is_pyi=False): - self.namespace = namespace - self.is_pyi = is_pyi - self._apis = [] - self.parse_orig() - - if not is_pyi: - self.pyi = Module(namespace, is_pyi=True) - self.pyi.orders = self.orders[:] - - def add(self, api): - self._apis.append(api) - - def parse_orig(self): - self.orders = [] - self.header = "class C:" - if os.path.exists(self.filepath): - with open(self.filepath) as f: - content = f.read() - header_lines = [] - for line in content.split("\n"): - header_lines.append(line) - if line == SEPARATOR: - break - # no separator found - else: - header_lines = [] - for line in content.split("\n"): - header_lines.append(line) - if line.startswith("class"): - break - self.header = "\n".join(header_lines) - self.orders = re.findall( - r"\n (?:async )?def ([a-z_]+)\(", content, re.MULTILINE - ) - - def _position(self, api): - try: - return self.orders.index(api.name) - except ValueError: - return len(self.orders) - - def sort(self): - self._apis.sort(key=self._position) - - def dump(self): - self.sort() - with open(self.filepath, "w") as f: - f.write(self.header) - for api in self._apis: - f.write(api.to_python()) - - if not self.is_pyi: - self.pyi.dump() - - @property - def filepath(self): - return ( - CODE_ROOT - / f"elasticsearch/_async/client/{self.namespace}.py{'i' if self.is_pyi else ''}" - ) - - -class API: - def __init__(self, namespace, name, definition, is_pyi=False): - self.namespace = namespace - self.name = name - self.is_pyi = is_pyi - - # overwrite the dict to maintain key order - definition["params"] = { - SUBSTITUTIONS.get(p, p): v for p, v in definition.get("params", {}).items() - } - - self._def = definition - self.description = "" - self.doc_url = "" - self.stability = self._def.get("stability", "stable") - - if isinstance(definition["documentation"], str): - self.doc_url = definition["documentation"] - else: - # set as attribute so it may be overridden by Module.add - self.description = ( - definition["documentation"].get("description", "").strip() - ) - self.doc_url = definition["documentation"].get("url", "") - - # Filter out bad URL refs like 'TODO' - # and serve all docs over HTTPS. - if self.doc_url: - if not self.doc_url.startswith("http"): - self.doc_url = "" - if self.doc_url.startswith("http://"): - self.doc_url = self.doc_url.replace("http://", "https://") - - # Try setting doc refs like 'current' and 'master' to our branches ref. - if BRANCH_NAME is not None: - revised_url = re.sub( - "/elasticsearch/reference/[^/]+/", - f"/elasticsearch/reference/{BRANCH_NAME}/", - self.doc_url, - ) - if is_valid_url(revised_url): - self.doc_url = revised_url - else: - print(f"URL {revised_url!r}, falling back on {self.doc_url!r}") - - @property - def response_type(self) -> str: - if self.method == "HEAD": - return "HeadApiResponse" - - types = [] - accept_headers = self._def["headers"].get("accept", ()) - if "application/json" in accept_headers: - types.append("ObjectApiResponse[None]") - if "application/mapbox-vector-tile" in accept_headers: - types.append("BinaryApiResponse") - if any(mimetype.startswith("text/") for mimetype in accept_headers): - types.append("TextApiResponse") - if not types: - return "Any" - if len(types) == 1: - return types[0] - return f"Union[{', '.join(sorted(types))}]" - - @property - def all_parts(self): - parts = {} - for url in self._def["url"]["paths"]: - parts.update(url.get("parts", {})) - - for p in parts: - parts[p]["required"] = all( - p in url.get("parts", {}) for url in self._def["url"]["paths"] - ) - parts[p]["type"] = "Any" - - for k, sub in SUBSTITUTIONS.items(): - if k in parts: - parts[sub] = parts.pop(k) - - dynamic, components = self.url_parts - - def ind(item): - try: - return components.index(item[0]) - except ValueError: - return len(components) - - parts = dict(sorted(parts.items(), key=ind)) - return parts - - @property - def params(self): - parts = self.all_parts - params = self._def.get("params", {}) - return chain( - ((p, parts[p]) for p in parts if parts[p]["required"]), - (("body", self.body),) if self.body else (), - ( - (p, parts[p]) - for p in parts - if not parts[p]["required"] and p not in params - ), - sorted(params.items(), key=lambda x: (x[0] not in parts, x[0])), - ) - - @property - def body(self): - b = self._def.get("body", {}) - if b: - b.setdefault("required", False) - return b - - @property - def query_params(self): - return ( - k - for k in sorted(self._def.get("params", {}).keys()) - if k not in self.all_parts - ) - - @property - def all_func_params(self): - """Parameters that will be in the '@query_params' decorator list - and parameters that will be in the function signature. - This doesn't include - """ - params = list(self._def.get("params", {}).keys()) - for url in self._def["url"]["paths"]: - params.extend(url.get("parts", {}).keys()) - if self.body: - params.append("body") - return params - - @property - def path(self): - return max( - (path for path in self._def["url"]["paths"]), - key=lambda p: len(re.findall(r"\{([^}]+)\}", p["path"])), - ) - - @property - def method(self): - # To adhere to the HTTP RFC we shouldn't send - # bodies in GET requests. - default_method = self.path["methods"][0] - if self.body and default_method == "GET" and "POST" in self.path["methods"]: - return "POST" - return default_method - - @property - def url_parts(self): - path = self.path["path"] - - dynamic = "{" in path - if not dynamic: - return dynamic, path - - parts = [] - for part in path.split("/"): - if not part: - continue - - if part[0] == "{": - part = part[1:-1] - parts.append(SUBSTITUTIONS.get(part, part)) - else: - parts.append(f"'{part}'") - - return dynamic, parts - - @property - def required_parts(self): - parts = self.all_parts - required = [p for p in parts if parts[p]["required"]] - if self.body.get("required"): - required.append("body") - return required - - def to_python(self): - if self.is_pyi: - t = jinja_env.get_template("base_pyi") - else: - try: - t = jinja_env.get_template(f"overrides/{self.namespace}/{self.name}") - except TemplateNotFound: - t = jinja_env.get_template("base") - - return t.render( - api=self, - substitutions={v: k for k, v in SUBSTITUTIONS.items()}, - global_query_params=GLOBAL_QUERY_PARAMS, - ) - - -@contextlib.contextmanager -def download_artifact(version): - # Download the list of all artifacts for a version - # and find the latest build URL for 'rest-resources-zip-*.zip' - resp = http.request( - "GET", f"https://artifacts-api.elastic.co/v1/versions/{version}" - ) - packages = json.loads(resp.data)["version"]["builds"][0]["projects"][ - "elasticsearch" - ]["packages"] - for package in packages: - if re.match(r"^rest-resources-zip-.*\.zip$", package): - zip_url = packages[package]["url"] - break - else: - raise RuntimeError( - "Could not find the package 'rest-resources-zip-*.zip' in build" - ) - - # Download the .jar file and unzip only the API - # .json files into a temporary directory - resp = http.request("GET", zip_url) - - tmp = Path(tempfile.mkdtemp()) - zip = zipfile.ZipFile(io.BytesIO(resp.data)) - for name in zip.namelist(): - if not name.endswith(".json") or name == "schema.json": - continue - # Compatibility APIs/tests should be skipped - if "/compatApi" in name or "/compatTest" in name: - continue - with (tmp / name.replace("rest-api-spec/api/", "")).open("wb") as f: - f.write(zip.read(name)) - - yield tmp - shutil.rmtree(tmp) - - -def read_modules(version): - modules = {} - - with download_artifact(version) as path: - for f in sorted(os.listdir(path)): - name, ext = f.rsplit(".", 1) - - if ext != "json" or name == "_common": - continue - - with open(path / f) as api_def: - api = json.load(api_def)[name] - - namespace = "__init__" - if "." in name: - namespace, name = name.rsplit(".", 1) - - # The data_frame API has been changed to transform. - if namespace == "data_frame_transform_deprecated": - continue - - if namespace not in modules: - modules[namespace] = Module(namespace) - - modules[namespace].add(API(namespace, name, api)) - modules[namespace].pyi.add(API(namespace, name, api, is_pyi=True)) - - return modules - - -def dump_modules(modules): - for mod in modules.values(): - mod.dump() - - os.system("python utils/run-unasync.py") - blacken(CODE_ROOT / "elasticsearch") - - -if __name__ == "__main__": - version = sys.argv[1] - dump_modules(read_modules(version)) diff --git a/utils/run-black.py b/utils/run-black.py new file mode 100644 index 000000000..de2b00553 --- /dev/null +++ b/utils/run-black.py @@ -0,0 +1,86 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +import os +import re +import subprocess +import sys +import time + + +def sleep_if_hot() -> None: + def is_hot() -> bool: + try: + return ( + max( + map( + int, + re.findall( + r"\s\+([0-9]{2})\.[0-9]", + subprocess.check_output("sensors", shell=True).decode( + "utf-8" + ), + ), + ) + ) + > 80 + ) + except subprocess.CalledProcessError: + return False + + while is_hot(): + time.sleep(0.1) + + +def run_on_directory(dir: str, check: bool) -> None: + for root, _, filenames in os.walk(dir): + for filename in filenames: + if filename.endswith(".py") or filename.endswith(".pyi"): + run_on_file(os.path.join(root, filename), check) + + +def run_on_file(file: str, check: bool) -> None: + try: + subprocess.check_call( + f"black --target-version=py36 {'--check ' if check else ''}{file}", + shell=True, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + ) + except subprocess.CalledProcessError as e: + print(e.output) + exit(e.returncode) + sleep_if_hot() + + +def main() -> None: + cwd = os.getcwd() + check = ["--check"] == sys.argv[1:2] + targets = [ + os.path.expanduser(os.path.join(cwd, target)) + for target in sys.argv[1:] + if target != "--check" + ] + for target in targets: + if os.path.isdir(target): + run_on_directory(target, check) + else: + run_on_file(target, check) + + +if __name__ == "__main__": + main() diff --git a/utils/templates/base b/utils/templates/base deleted file mode 100644 index 257e66e2b..000000000 --- a/utils/templates/base +++ /dev/null @@ -1,38 +0,0 @@ - - @query_params({{ api.query_params|map("tojson")|join(", ")}}) - async def {{ api.name }}(self, {% include "func_params" %}): - """ - {% if api.description %} - {{ api.description|replace("\n", " ")|wordwrap(wrapstring="\n ") }} - {% endif %} - {% if api.doc_url %} - - `<{{ api.doc_url }}>`_ - {% endif %} - {% if api.stability != "stable" %} - - .. warning:: - - This API is **{{ api.stability }}** so may include breaking changes - or be removed in a future version - {% endif %} - {% if api.params|list|length %} - - {% for p, info in api.params %} - {% filter wordwrap(72, wrapstring="\n ") %} - :arg {{ 'from\\\\_' if p == 'from_' else p }}: {{ info.description }}{% if info.options %} Valid choices: {{ info.options|join(", ") }}{% endif %}{% if info.default %} Default: {{ info.default }}{% endif %} - {% endfilter %} - - {% endfor %} - {% endif %} - """ - client, params = _deprecated_options(self, params) - {% include "substitutions" %} - {% include "required" %} - {% if api.body.serialize == "bulk" %} - headers["content-type"] = "application/x-ndjson" - {% endif %} - {% block request %} - return await client._perform_request("{{ api.method }}", {% include "url" %}, params=params, headers=headers{% if api.body %}, body=body{% endif %}) - {% endblock %} - diff --git a/utils/templates/base_pyi b/utils/templates/base_pyi deleted file mode 100644 index 84cebeffc..000000000 --- a/utils/templates/base_pyi +++ /dev/null @@ -1,2 +0,0 @@ - - async def {{ api.name }}(self, {% include "func_params_pyi" %}) -> {{ api.response_type }}: ... diff --git a/utils/templates/example b/utils/templates/example deleted file mode 100644 index e39eca931..000000000 --- a/utils/templates/example +++ /dev/null @@ -1,12 +0,0 @@ -{% for src in parsed_sources %} -resp = client.{{ src.api }}( -{% for key, val in src.params.items() %} - {{ key }}={{ val }}, -{% endfor %} -{% if src.body %} - body={{ src.body }}, -{% endif %} -) -print(resp) - -{% endfor %} \ No newline at end of file diff --git a/utils/templates/func_params b/utils/templates/func_params deleted file mode 100644 index 067e8f128..000000000 --- a/utils/templates/func_params +++ /dev/null @@ -1,14 +0,0 @@ -{% for p, info in api.all_parts.items() %} - {% if info.required %}{{ p }}, {% endif %} -{% endfor %} - -{% if api.body %} - body{% if not api.body.required %}=None{% endif %}, -{% endif %} - -{% for p, info in api.all_parts.items() %} - {% if not info.required %}{{ p }}=None, {% endif %} -{% endfor %} - -params=None, -headers=None diff --git a/utils/templates/func_params_pyi b/utils/templates/func_params_pyi deleted file mode 100644 index cd48f9a6d..000000000 --- a/utils/templates/func_params_pyi +++ /dev/null @@ -1,26 +0,0 @@ -{% for p, info in api.all_parts.items() %} - {% if info.required %}{{ p }}: {{ info.type }}, {% endif %} -{% endfor %} - -*, - -{% if api.body %} - body{% if not api.body.required %}: Optional[Any]=...{% else %}: Any{% endif %}, -{% endif %} - -{% for p, info in api.all_parts.items() %} - {% if not info.required %}{{ p }}: Optional[{{ info.type }}]=..., {% endif %} -{% endfor %} - -{% for p in api.query_params %} - {{ p }}: Optional[Any]=..., -{% endfor %} - -{% for p, p_type in global_query_params.items() %} - {% if p not in api.all_func_params %} - {{ p }}: {{ p_type }}=..., - {% endif %} -{% endfor %} - -params: Optional[MutableMapping[str, Any]]=..., -headers: Optional[MutableMapping[str, str]]=..., diff --git a/utils/templates/overrides/__init__/clear_scroll b/utils/templates/overrides/__init__/clear_scroll deleted file mode 100644 index a79d2e6ab..000000000 --- a/utils/templates/overrides/__init__/clear_scroll +++ /dev/null @@ -1,12 +0,0 @@ -{% extends "base" %} -{% block request %} - if scroll_id in SKIP_IN_PATH and body in SKIP_IN_PATH: - raise ValueError("You need to supply scroll_id or body.") - elif scroll_id and not body: - body = {"scroll_id": [scroll_id]} - elif scroll_id: - params["scroll_id"] = scroll_id - - return await client._perform_request("{{ api.method }}", "/_search/scroll", params=params, headers=headers, body=body) -{% endblock %} - diff --git a/utils/templates/overrides/__init__/create b/utils/templates/overrides/__init__/create deleted file mode 100644 index 1eafc0e72..000000000 --- a/utils/templates/overrides/__init__/create +++ /dev/null @@ -1,10 +0,0 @@ -{% extends "base" %} -{% block request %} - if doc_type in SKIP_IN_PATH: - path = _make_path(index, "_create", id) - else: - path = _make_path(index, doc_type, id, "_create") - - return await client._perform_request("POST" if id in SKIP_IN_PATH else "PUT", path, params=params, headers=headers, body=body) -{% endblock %} - diff --git a/utils/templates/overrides/__init__/delete b/utils/templates/overrides/__init__/delete deleted file mode 100644 index 8189fec7f..000000000 --- a/utils/templates/overrides/__init__/delete +++ /dev/null @@ -1,8 +0,0 @@ -{% extends "base" %} -{% block request %} - if doc_type in SKIP_IN_PATH: - doc_type = "_doc" - - {{ super()|trim }} -{% endblock %} - diff --git a/utils/templates/overrides/__init__/index b/utils/templates/overrides/__init__/index deleted file mode 100644 index b93fa4a17..000000000 --- a/utils/templates/overrides/__init__/index +++ /dev/null @@ -1,11 +0,0 @@ -{% extends "base" %} -{% block request %} - return await client._perform_request( - "POST" if id in SKIP_IN_PATH else "PUT", - _make_path(index, "_doc", id), - params=params, - headers=headers, - body=body, - ) -{% endblock %} - diff --git a/utils/templates/overrides/__init__/ping b/utils/templates/overrides/__init__/ping deleted file mode 100644 index 565335e6e..000000000 --- a/utils/templates/overrides/__init__/ping +++ /dev/null @@ -1,9 +0,0 @@ -{% extends "base" %} -{% block request %} - try: - await client._perform_request("{{ api.method }}", {% include "url" %}, params=params, headers=headers{% if api.body %}, body=body{% endif %}) - return True - except TransportError: - return False -{% endblock %} - diff --git a/utils/templates/overrides/__init__/scroll b/utils/templates/overrides/__init__/scroll deleted file mode 100644 index 3bd098cc8..000000000 --- a/utils/templates/overrides/__init__/scroll +++ /dev/null @@ -1,12 +0,0 @@ -{% extends "base" %} -{% block request %} - if scroll_id in SKIP_IN_PATH and body in SKIP_IN_PATH: - raise ValueError("You need to supply scroll_id or body.") - elif scroll_id and not body: - body = {"scroll_id": scroll_id} - elif scroll_id: - params["scroll_id"] = scroll_id - - return await client._perform_request("{{ api.method }}", "/_search/scroll", params=params, headers=headers, body=body) -{% endblock %} - diff --git a/utils/templates/overrides/__init__/update b/utils/templates/overrides/__init__/update deleted file mode 100644 index 628def7e9..000000000 --- a/utils/templates/overrides/__init__/update +++ /dev/null @@ -1,10 +0,0 @@ -{% extends "base" %} -{% block request %} - if doc_type in SKIP_IN_PATH: - path = _make_path(index, "_update", id) - else: - path = _make_path(index, doc_type, id, "_update") - - return await client._perform_request("{{ api.method }}", path, params=params, headers=headers, body=body) -{% endblock %} - diff --git a/utils/templates/overrides/cluster/state b/utils/templates/overrides/cluster/state deleted file mode 100644 index 27d599cbf..000000000 --- a/utils/templates/overrides/cluster/state +++ /dev/null @@ -1,8 +0,0 @@ -{% extends "base" %} -{% block request %} - if index and metric in SKIP_IN_PATH: - metric = "_all" - - {{ super()|trim }} -{% endblock %} - diff --git a/utils/templates/overrides/cluster/stats b/utils/templates/overrides/cluster/stats deleted file mode 100644 index c4cc47b8e..000000000 --- a/utils/templates/overrides/cluster/stats +++ /dev/null @@ -1,5 +0,0 @@ -{% extends "base" %} -{% block request %} - return await client._perform_request("{{ api.method }}", "/_cluster/stats" if node_id in SKIP_IN_PATH else _make_path("_cluster", "stats", "nodes", node_id), params=params, headers=headers) -{% endblock%} - diff --git a/utils/templates/required b/utils/templates/required deleted file mode 100644 index c1fb503c5..000000000 --- a/utils/templates/required +++ /dev/null @@ -1,11 +0,0 @@ - {% if api.required_parts.1 %} - for param in ({{ api.required_parts|join(", ")}}): - if param in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument.") - - {% elif api.required_parts %} - if {{ api.required_parts.0 }} in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument '{{ api.required_parts.0 }}'.") - - {% endif %} - diff --git a/utils/templates/substitutions b/utils/templates/substitutions deleted file mode 100644 index 7e83e9883..000000000 --- a/utils/templates/substitutions +++ /dev/null @@ -1,8 +0,0 @@ -{% for p, info in api.params %} - {% if p in substitutions and p not in api.url_parts.1 %} - if params and "{{ p }}" in params: - params["{{ substitutions[p] }}"] = params.pop("{{ p }}") - - {% endif %} -{% endfor %} - diff --git a/utils/templates/url b/utils/templates/url deleted file mode 100644 index e89df4907..000000000 --- a/utils/templates/url +++ /dev/null @@ -1 +0,0 @@ -{% if api.url_parts.0 %}_make_path({{ api.url_parts.1|join(", ")}}){% else %}{{ api.url_parts.1|tojson }}{% endif %} From cd2452175d5737c84dc0db5a5a68913093956210 Mon Sep 17 00:00:00 2001 From: Seth Michael Larson Date: Tue, 16 Nov 2021 07:57:47 -0600 Subject: [PATCH 2/6] Add aliased parameters --- elasticsearch/_async/client/__init__.py | 4 ++ elasticsearch/_async/client/async_search.py | 4 ++ elasticsearch/_async/client/ml.py | 6 +++ elasticsearch/_async/client/rollup.py | 4 ++ elasticsearch/_async/helpers.py | 2 +- elasticsearch/_sync/client/__init__.py | 4 ++ elasticsearch/_sync/client/async_search.py | 4 ++ elasticsearch/_sync/client/ml.py | 6 +++ elasticsearch/_sync/client/rollup.py | 4 ++ elasticsearch/_sync/client/utils.py | 8 ++- elasticsearch/helpers/actions.py | 2 +- setup.cfg | 2 +- .../test_async/test_server/conftest.py | 2 +- .../test_async/test_server/test_clients.py | 51 ++++++++++++------- .../test_async/test_server/test_helpers.py | 14 ++--- .../test_server/test_rest_api_spec.py | 18 ++++++- .../test_client/test_indices.py | 4 +- .../test_server/test_rest_api_spec.py | 28 ++++++++-- test_elasticsearch/utils.py | 4 +- 19 files changed, 129 insertions(+), 42 deletions(-) diff --git a/elasticsearch/_async/client/__init__.py b/elasticsearch/_async/client/__init__.py index fabcd509c..31679acb7 100644 --- a/elasticsearch/_async/client/__init__.py +++ b/elasticsearch/_async/client/__init__.py @@ -3069,6 +3069,7 @@ async def search( *, index: Optional[Any] = None, aggregations: Optional[Dict[str, Any]] = None, + aggs: Optional[Dict[str, Any]] = None, allow_no_indices: Optional[bool] = None, allow_partial_search_results: Optional[bool] = None, analyze_wildcard: Optional[bool] = None, @@ -3140,6 +3141,7 @@ async def search( :param index: A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices :param aggregations: + :param aggs: :param 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) @@ -3266,6 +3268,8 @@ async def search( __query: Dict[str, Any] = {} if aggregations is not None: __body["aggregations"] = aggregations + if aggs is not None: + __body["aggs"] = aggs if allow_no_indices is not None: __query["allow_no_indices"] = allow_no_indices if allow_partial_search_results is not None: diff --git a/elasticsearch/_async/client/async_search.py b/elasticsearch/_async/client/async_search.py index f13c64089..30f9eb392 100644 --- a/elasticsearch/_async/client/async_search.py +++ b/elasticsearch/_async/client/async_search.py @@ -162,6 +162,7 @@ async def submit( *, index: Optional[Any] = None, aggregations: Optional[Dict[str, Any]] = None, + aggs: Optional[Dict[str, Any]] = None, allow_no_indices: Optional[bool] = None, allow_partial_search_results: Optional[bool] = None, analyze_wildcard: Optional[bool] = None, @@ -236,6 +237,7 @@ async def submit( :param index: A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices :param aggregations: + :param aggs: :param 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) @@ -359,6 +361,8 @@ async def submit( __query: Dict[str, Any] = {} if aggregations is not None: __body["aggregations"] = aggregations + if aggs is not None: + __body["aggs"] = aggs if allow_no_indices is not None: __query["allow_no_indices"] = allow_no_indices if allow_partial_search_results is not None: diff --git a/elasticsearch/_async/client/ml.py b/elasticsearch/_async/client/ml.py index 7c45927e1..a8030d24e 100644 --- a/elasticsearch/_async/client/ml.py +++ b/elasticsearch/_async/client/ml.py @@ -2614,6 +2614,7 @@ async def put_datafeed( human: Optional[bool] = None, ignore_throttled: Optional[bool] = None, ignore_unavailable: Optional[bool] = None, + indexes: Optional[List[str]] = None, indices: Optional[List[str]] = None, indices_options: Optional[Any] = None, job_id: Optional[Any] = None, @@ -2663,6 +2664,9 @@ async def put_datafeed( :param ignore_throttled: Ignore indices that are marked as throttled (default: true) :param ignore_unavailable: Ignore unavailable indexes (default: false) + :param indexes: An array of index names. Wildcards are supported. If any of the + indices are in remote clusters, the machine learning nodes must have the + `remote_cluster_client` role. :param indices: An array of index names. Wildcards are supported. If any of the indices are in remote clusters, the machine learning nodes must have the `remote_cluster_client` role. @@ -2719,6 +2723,8 @@ async def put_datafeed( __query["ignore_throttled"] = ignore_throttled if ignore_unavailable is not None: __query["ignore_unavailable"] = ignore_unavailable + if indexes is not None: + __body["indexes"] = indexes if indices is not None: __body["indices"] = indices if indices_options is not None: diff --git a/elasticsearch/_async/client/rollup.py b/elasticsearch/_async/client/rollup.py index 4779a7d18..3918ab5df 100644 --- a/elasticsearch/_async/client/rollup.py +++ b/elasticsearch/_async/client/rollup.py @@ -296,6 +296,7 @@ async def rollup_search( index: Any, type: Optional[Any] = None, aggregations: Optional[Dict[str, Any]] = None, + aggs: Optional[Dict[str, Any]] = None, error_trace: Optional[bool] = None, filter_path: Optional[Union[List[str], str]] = None, human: Optional[bool] = None, @@ -314,6 +315,7 @@ async def rollup_search( that should be searched :param type: The doc type inside the index :param aggregations: + :param aggs: :param query: :param rest_total_hits_as_int: Indicates whether hits.total should be rendered as an integer or an object in the rest search response @@ -333,6 +335,8 @@ async def rollup_search( __query: Dict[str, Any] = {} if aggregations is not None: __body["aggregations"] = aggregations + if aggs is not None: + __body["aggs"] = aggs if error_trace is not None: __query["error_trace"] = error_trace if filter_path is not None: diff --git a/elasticsearch/_async/helpers.py b/elasticsearch/_async/helpers.py index 489c9b8aa..56f07dd3d 100644 --- a/elasticsearch/_async/helpers.py +++ b/elasticsearch/_async/helpers.py @@ -66,7 +66,7 @@ async def _process_bulk_chunk( try: # send the actual request - resp = await client.bulk(*args, body=bulk_actions, **kwargs) + resp = await client.bulk(*args, operations=bulk_actions, **kwargs) except TransportError as e: gen = _process_bulk_chunk_error( error=e, diff --git a/elasticsearch/_sync/client/__init__.py b/elasticsearch/_sync/client/__init__.py index 9a654c10c..99438840a 100644 --- a/elasticsearch/_sync/client/__init__.py +++ b/elasticsearch/_sync/client/__init__.py @@ -3029,6 +3029,7 @@ def search( *, index: Optional[Any] = None, aggregations: Optional[Dict[str, Any]] = None, + aggs: Optional[Dict[str, Any]] = None, allow_no_indices: Optional[bool] = None, allow_partial_search_results: Optional[bool] = None, analyze_wildcard: Optional[bool] = None, @@ -3100,6 +3101,7 @@ def search( :param index: A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices :param aggregations: + :param aggs: :param 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) @@ -3226,6 +3228,8 @@ def search( __query: Dict[str, Any] = {} if aggregations is not None: __body["aggregations"] = aggregations + if aggs is not None: + __body["aggs"] = aggs if allow_no_indices is not None: __query["allow_no_indices"] = allow_no_indices if allow_partial_search_results is not None: diff --git a/elasticsearch/_sync/client/async_search.py b/elasticsearch/_sync/client/async_search.py index f560aed92..09a0835e1 100644 --- a/elasticsearch/_sync/client/async_search.py +++ b/elasticsearch/_sync/client/async_search.py @@ -162,6 +162,7 @@ def submit( *, index: Optional[Any] = None, aggregations: Optional[Dict[str, Any]] = None, + aggs: Optional[Dict[str, Any]] = None, allow_no_indices: Optional[bool] = None, allow_partial_search_results: Optional[bool] = None, analyze_wildcard: Optional[bool] = None, @@ -236,6 +237,7 @@ def submit( :param index: A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices :param aggregations: + :param aggs: :param 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) @@ -359,6 +361,8 @@ def submit( __query: Dict[str, Any] = {} if aggregations is not None: __body["aggregations"] = aggregations + if aggs is not None: + __body["aggs"] = aggs if allow_no_indices is not None: __query["allow_no_indices"] = allow_no_indices if allow_partial_search_results is not None: diff --git a/elasticsearch/_sync/client/ml.py b/elasticsearch/_sync/client/ml.py index b37fbd6bb..dc2a613ea 100644 --- a/elasticsearch/_sync/client/ml.py +++ b/elasticsearch/_sync/client/ml.py @@ -2576,6 +2576,7 @@ def put_datafeed( human: Optional[bool] = None, ignore_throttled: Optional[bool] = None, ignore_unavailable: Optional[bool] = None, + indexes: Optional[List[str]] = None, indices: Optional[List[str]] = None, indices_options: Optional[Any] = None, job_id: Optional[Any] = None, @@ -2625,6 +2626,9 @@ def put_datafeed( :param ignore_throttled: Ignore indices that are marked as throttled (default: true) :param ignore_unavailable: Ignore unavailable indexes (default: false) + :param indexes: An array of index names. Wildcards are supported. If any of the + indices are in remote clusters, the machine learning nodes must have the + `remote_cluster_client` role. :param indices: An array of index names. Wildcards are supported. If any of the indices are in remote clusters, the machine learning nodes must have the `remote_cluster_client` role. @@ -2681,6 +2685,8 @@ def put_datafeed( __query["ignore_throttled"] = ignore_throttled if ignore_unavailable is not None: __query["ignore_unavailable"] = ignore_unavailable + if indexes is not None: + __body["indexes"] = indexes if indices is not None: __body["indices"] = indices if indices_options is not None: diff --git a/elasticsearch/_sync/client/rollup.py b/elasticsearch/_sync/client/rollup.py index 8f409c608..86505b4bc 100644 --- a/elasticsearch/_sync/client/rollup.py +++ b/elasticsearch/_sync/client/rollup.py @@ -292,6 +292,7 @@ def rollup_search( index: Any, type: Optional[Any] = None, aggregations: Optional[Dict[str, Any]] = None, + aggs: Optional[Dict[str, Any]] = None, error_trace: Optional[bool] = None, filter_path: Optional[Union[List[str], str]] = None, human: Optional[bool] = None, @@ -310,6 +311,7 @@ def rollup_search( that should be searched :param type: The doc type inside the index :param aggregations: + :param aggs: :param query: :param rest_total_hits_as_int: Indicates whether hits.total should be rendered as an integer or an object in the rest search response @@ -329,6 +331,8 @@ def rollup_search( __query: Dict[str, Any] = {} if aggregations is not None: __body["aggregations"] = aggregations + if aggs is not None: + __body["aggs"] = aggs if error_trace is not None: __query["error_trace"] = error_trace if filter_path is not None: diff --git a/elasticsearch/_sync/client/utils.py b/elasticsearch/_sync/client/utils.py index 2148d7dae..6d296f946 100644 --- a/elasticsearch/_sync/client/utils.py +++ b/elasticsearch/_sync/client/utils.py @@ -71,6 +71,7 @@ "request_timeout", "opaque_id", "headers", + "ignore", } RT = TypeVar("RT") @@ -237,7 +238,7 @@ def _quote(value: Any) -> str: def _quote_query(query: Dict[str, Any]) -> str: - return "&".join([f"{k}={percent_encode(_escape(v), ',*')}" for k, v in query.items()]) + return "&".join([f"{k}={_quote(v)}" for k, v in query.items()]) def _merge_kwargs_no_duplicates(kwargs: Dict[str, Any], values: Dict[str, Any]) -> None: @@ -287,7 +288,10 @@ def wrapped(*args: Any, **kwargs: Any) -> RT: if option in options_to_skip: continue try: - transport_options[option] = kwargs.pop(option) + option_rename = option + if option == "ignore": + option_rename = "ignore_status" + transport_options[option_rename] = kwargs.pop(option) except KeyError: pass if transport_options: diff --git a/elasticsearch/helpers/actions.py b/elasticsearch/helpers/actions.py index 834d6574b..9478e8a9a 100644 --- a/elasticsearch/helpers/actions.py +++ b/elasticsearch/helpers/actions.py @@ -237,7 +237,7 @@ def _process_bulk_chunk( try: # send the actual request - resp = client.bulk(*args, body=bulk_actions, **kwargs) + resp = client.bulk(*args, operations=bulk_actions, **kwargs) except TransportError as e: gen = _process_bulk_chunk_error( error=e, diff --git a/setup.cfg b/setup.cfg index f429aed7f..a635a95a0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -6,7 +6,7 @@ ignore = E203, E266, E501, W503 [tool:pytest] junit_family=legacy -addopts = -vvv --cov-report=term-missing --cov=elasticsearch --cov-config=.coveragerc +addopts = -vvv -p no:logging --cov-report=term-missing --cov=elasticsearch --cov-config=.coveragerc [tool:isort] profile=black diff --git a/test_elasticsearch/test_async/test_server/conftest.py b/test_elasticsearch/test_async/test_server/conftest.py index 3a90fd17d..21ef7a38d 100644 --- a/test_elasticsearch/test_async/test_server/conftest.py +++ b/test_elasticsearch/test_async/test_server/conftest.py @@ -38,7 +38,7 @@ async def async_client(elasticsearch_url): client = None try: client = elasticsearch.AsyncElasticsearch( - elasticsearch_url, timeout=3, ca_certs=CA_CERTS + elasticsearch_url, request_timeout=3, ca_certs=CA_CERTS ) yield client finally: diff --git a/test_elasticsearch/test_async/test_server/test_clients.py b/test_elasticsearch/test_async/test_server/test_clients.py index be0515aa3..04035f3df 100644 --- a/test_elasticsearch/test_async/test_server/test_clients.py +++ b/test_elasticsearch/test_async/test_server/test_clients.py @@ -23,22 +23,35 @@ pytestmark = pytest.mark.asyncio -class TestUnicode: - async def test_indices_analyze(self, async_client): - await async_client.indices.analyze(body='{"text": "привет"}') - - -class TestBulk: - async def test_bulk_works_with_string_body(self, async_client): - docs = '{ "index" : { "_index" : "bulk_test_index", "_id" : "1" } }\n{"answer": 42}' - response = await async_client.bulk(body=docs) - - assert response["errors"] is False - assert len(response["items"]) == 1 - - async def test_bulk_works_with_bytestring_body(self, async_client): - docs = b'{ "index" : { "_index" : "bulk_test_index", "_id" : "2" } }\n{"answer": 42}' - response = await async_client.bulk(body=docs) - - assert response["errors"] is False - assert len(response["items"]) == 1 +@pytest.mark.parametrize("kwargs", [{"body": {"text": "привет"}}, {"text": "привет"}]) +async def test_indices_analyze_unicode(async_client, kwargs): + resp = await async_client.indices.analyze(**kwargs) + assert resp == { + "tokens": [ + { + "end_offset": 6, + "position": 0, + "start_offset": 0, + "token": "привет", + "type": "", + } + ] + } + + +async def test_bulk_works_with_string_body(self, async_client): + docs = '{ "index" : { "_index" : "bulk_test_index", "_id" : "1" } }\n{"answer": 42}' + response = await async_client.bulk(body=docs) + + assert response["errors"] is False + assert len(response["items"]) == 1 + + +async def test_bulk_works_with_bytestring_body(self, async_client): + docs = ( + b'{ "index" : { "_index" : "bulk_test_index", "_id" : "2" } }\n{"answer": 42}' + ) + response = await async_client.bulk(body=docs) + + assert response["errors"] is False + assert len(response["items"]) == 1 diff --git a/test_elasticsearch/test_async/test_server/test_helpers.py b/test_elasticsearch/test_async/test_server/test_helpers.py index e9acfebb8..cc099d5ff 100644 --- a/test_elasticsearch/test_async/test_server/test_helpers.py +++ b/test_elasticsearch/test_async/test_server/test_helpers.py @@ -476,7 +476,7 @@ async def test_order_can_be_preserved(self, async_client, scan_teardown): for x in range(100): bulk.append({"index": {"_index": "test_index", "_id": x}}) bulk.append({"answer": x, "correct": x == 42}) - await async_client.bulk(bulk, refresh=True) + await async_client.bulk(operations=bulk, refresh=True) docs = [ doc @@ -497,7 +497,7 @@ async def test_all_documents_are_read(self, async_client, scan_teardown): for x in range(100): bulk.append({"index": {"_index": "test_index", "_id": x}}) bulk.append({"answer": x, "correct": x == 42}) - await async_client.bulk(bulk, refresh=True) + await async_client.bulk(operations=bulk, refresh=True) docs = [ x @@ -513,7 +513,7 @@ async def test_scroll_error(self, async_client, scan_teardown): for x in range(4): bulk.append({"index": {"_index": "test_index"}}) bulk.append({"value": x}) - await async_client.bulk(bulk, refresh=True) + await async_client.bulk(operations=bulk, refresh=True) with patch.object( async_client, "options", return_value=async_client @@ -632,7 +632,7 @@ async def test_logger(self, logger_mock, async_client, scan_teardown): for x in range(4): bulk.append({"index": {"_index": "test_index"}}) bulk.append({"value": x}) - await async_client.bulk(bulk, refresh=True) + await async_client.bulk(operations=bulk, refresh=True) with patch.object( async_client, "options", return_value=async_client @@ -677,7 +677,7 @@ async def test_clear_scroll(self, async_client, scan_teardown): for x in range(4): bulk.append({"index": {"_index": "test_index"}}) bulk.append({"value": x}) - await async_client.bulk(bulk, refresh=True) + await async_client.bulk(operations=bulk, refresh=True) with patch.object( async_client, "options", return_value=async_client @@ -851,7 +851,7 @@ async def reindex_setup(async_client): "type": "answers" if x % 2 == 0 else "questions", } ) - await async_client.bulk(bulk, refresh=True) + await async_client.bulk(operations=bulk, refresh=True) yield @@ -992,7 +992,7 @@ async def reindex_data_stream_setup(async_client): "@timestamp": (dt - timedelta(days=x)).isoformat(), } ) - await async_client.bulk(bulk, refresh=True) + await async_client.bulk(operations=bulk, refresh=True) await async_client.indices.put_index_template( name="my-index-template", body={ 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 978e93474..13fa0227d 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 @@ -21,6 +21,7 @@ clients. """ import inspect +import json import warnings import pytest @@ -28,6 +29,7 @@ from elasticsearch import ElasticsearchWarning, RequestError from ...test_server.test_rest_api_spec import ( + API_PARAMS_RENAMES, IMPLEMENTED_FEATURES, PARAMS_RENAMES, RUN_ASYNC_REST_API_TESTS, @@ -134,11 +136,23 @@ async def run_do(self, action): assert hasattr(api, m) api = getattr(api, m) + # Sometimes the 'body' parameter is encoded as a string instead of raw. + if "body" in args: + try: + args["body"] = json.loads(args["body"]) + except (TypeError, ValueError): + pass + if isinstance(args["body"], dict): + body = args.pop("body") + args.update(body) + # some parameters had to be renamed to not clash with python builtins, # compensate - for k in PARAMS_RENAMES: + renames = PARAMS_RENAMES.copy() + renames.update(API_PARAMS_RENAMES.get(method, {})) + for k in renames: if k in args: - args[PARAMS_RENAMES[k]] = args.pop(k) + args[renames[k]] = args.pop(k) # resolve vars for k in args: diff --git a/test_elasticsearch/test_client/test_indices.py b/test_elasticsearch/test_client/test_indices.py index 3cce6a0a2..9b7c86388 100644 --- a/test_elasticsearch/test_client/test_indices.py +++ b/test_elasticsearch/test_client/test_indices.py @@ -42,5 +42,7 @@ def test_passing_empty_value_for_required_param_raises_exception(self): self.client.indices.exists(index="") def test_query_params(self): - self.client.indices.delete(index=["test1", "test*"], expand_wildcards=["open", "closed"]) + self.client.indices.delete( + index=["test1", "test*"], expand_wildcards=["open", "closed"] + ) self.assert_url_called("DELETE", "/test1,test*?expand_wildcards=open,closed") diff --git a/test_elasticsearch/test_server/test_rest_api_spec.py b/test_elasticsearch/test_server/test_rest_api_spec.py index bedade6bd..38ed3f75f 100644 --- a/test_elasticsearch/test_server/test_rest_api_spec.py +++ b/test_elasticsearch/test_server/test_rest_api_spec.py @@ -41,6 +41,16 @@ # some params had to be changed in python, keep track of them so we can rename # those in the tests accordingly PARAMS_RENAMES = {"type": "doc_type", "from": "from_"} +API_PARAMS_RENAMES = { + "snapshot.create_repository": {"repository": "name"}, + "snapshot.delete_repository": {"repository": "name"}, + "snapshot.get_repository": {"repository": "name"}, + "snapshot.cleanup_repository": {"repository": "name"}, + "snapshot.verify_repository": {"repository": "name"}, + "ilm.delete_lifecycle": {"policy", "name"}, + "ilm.get_lifecycle": {"policy": "name"}, + "ilm.put_lifecycle": {"policy": "name"}, +} # mapping from catch values to http status codes CATCH_CODES = {"missing": 404, "conflict": 409, "unauthorized": 401} @@ -228,11 +238,20 @@ def run_do(self, action): assert hasattr(api, m) api = getattr(api, m) + # Sometimes the 'body' parameter is encoded as a string instead of raw. + if "body" in args: + try: + args["body"] = json.loads(args["body"]) + except (TypeError, ValueError): + pass + # some parameters had to be renamed to not clash with python builtins, # compensate - for k in PARAMS_RENAMES: + renames = PARAMS_RENAMES.copy() + renames.update(API_PARAMS_RENAMES.get(method, {})) + for k in renames: if k in args: - args[PARAMS_RENAMES[k]] = args.pop(k) + args[renames[k]] = args.pop(k) # resolve vars for k in args: @@ -269,8 +288,9 @@ def run_do(self, action): ) def run_catch(self, catch, exception): - if catch == "param": + if catch == "param" or isinstance(exception, TypeError): assert isinstance(exception, TypeError) + self.last_response = None return assert isinstance(exception, ApiError) @@ -501,7 +521,7 @@ def remove_implicit_resolver(cls, tag_to_remove): try: # Construct the HTTP and Elasticsearch client http = urllib3.PoolManager(retries=10) - client = Elasticsearch(es_url(), timeout=3, ca_certs=CA_CERTS) + client = Elasticsearch(es_url(), request_timeout=3, ca_certs=CA_CERTS) # Make a request to Elasticsearch for the build hash, we'll be looking for # an artifact with this same hash to download test specs for. diff --git a/test_elasticsearch/utils.py b/test_elasticsearch/utils.py index 5489fff6d..502fcb2ac 100644 --- a/test_elasticsearch/utils.py +++ b/test_elasticsearch/utils.py @@ -200,9 +200,7 @@ def wipe_snapshots(client): snapshot=snapshot["snapshot"], ) - client.options(ignore_status=404).snapshot.delete_repository( - repository=repo_name - ) + client.options(ignore_status=404).snapshot.delete_repository(name=repo_name) assert in_progress_snapshots == [] From 7cf4cb94f658952917fdb8e9b2eb1c768df900d9 Mon Sep 17 00:00:00 2001 From: Seth Michael Larson Date: Tue, 16 Nov 2021 15:10:22 -0600 Subject: [PATCH 3/6] Fixes for REST API tests --- elasticsearch/_async/client/__init__.py | 12 ++--- elasticsearch/_async/client/ml.py | 45 +++++++++---------- elasticsearch/_sync/client/__init__.py | 12 ++--- elasticsearch/_sync/client/ml.py | 45 +++++++++---------- elasticsearch/_sync/client/utils.py | 34 +++++++------- .../test_server/test_rest_api_spec.py | 16 ++++++- .../test_server/test_rest_api_spec.py | 17 ++++++- 7 files changed, 103 insertions(+), 78 deletions(-) diff --git a/elasticsearch/_async/client/__init__.py b/elasticsearch/_async/client/__init__.py index 31679acb7..84450d632 100644 --- a/elasticsearch/_async/client/__init__.py +++ b/elasticsearch/_async/client/__init__.py @@ -34,14 +34,15 @@ from elastic_transport import ( AsyncTransport, BaseNode, + HeadApiResponse, NodeConfig, NodePool, NodeSelector, Serializer, - TransportError, ) from elastic_transport.client_utils import DEFAULT, DefaultType +from ...exceptions import ApiError from ...serializer import DEFAULT_SERIALIZERS from ._base import ( BaseClient, @@ -456,7 +457,7 @@ async def ping( filter_path: Optional[Union[List[str], str]] = None, human: Optional[bool] = None, pretty: Optional[bool] = None, - ) -> bool: + ) -> Any: """ Returns basic information about the cluster. @@ -479,9 +480,9 @@ async def ping( __headers = {"accept": "application/json"} try: resp = await self._perform_request("HEAD", __target, headers=__headers) - return bool(resp) - except TransportError: - return False + return resp + except ApiError as e: + return HeadApiResponse(meta=e.meta) # AUTO-GENERATED-API-DEFINITIONS # @@ -2089,7 +2090,6 @@ async def info( @_rewrite_parameters( body_fields=True, parameter_aliases={"_source": "source"}, - ignore_deprecated_options=True, ) async def knn_search( self, diff --git a/elasticsearch/_async/client/ml.py b/elasticsearch/_async/client/ml.py index a8030d24e..850ef103e 100644 --- a/elasticsearch/_async/client/ml.py +++ b/elasticsearch/_async/client/ml.py @@ -960,6 +960,7 @@ async def get_buckets( filter_path: Optional[Union[List[str], str]] = None, from_: Optional[int] = None, human: Optional[bool] = None, + page: Optional[Any] = None, pretty: Optional[bool] = None, size: Optional[int] = None, sort: Optional[Any] = None, @@ -973,18 +974,18 @@ async def get_buckets( :param job_id: Identifier for the anomaly detection job. :param timestamp: The timestamp of a single bucket result. If you do not specify this parameter, the API returns information about all buckets. - :param anomaly_score: Returns buckets with anomaly scores greater or equal than - this value. - :param desc: If `true`, the buckets are sorted in descending order. - :param end: Returns buckets with timestamps earlier than this time. `-1` means - it is unset and results are not limited to specific timestamps. - :param exclude_interim: If `true`, the output excludes interim results. - :param expand: If true, the output includes anomaly records. + :param anomaly_score: Refer to the description for the `anomaly_score` query + parameter. + :param desc: Refer to the description for the `desc` query parameter. + :param end: Refer to the description for the `end` query parameter. + :param exclude_interim: Refer to the description for the `exclude_interim` query + parameter. + :param expand: Refer to the description for the `expand` query parameter. :param from_: Skips the specified number of buckets. + :param page: :param size: Specifies the maximum number of buckets to obtain. - :param sort: Specifies the sort field for the requested buckets. - :param start: Returns buckets with timestamps after this time. `-1` means it - is unset and results are not limited to specific timestamps. + :param sort: Refer to the desription for the `sort` query parameter. + :param start: Refer to the description for the `start` query parameter. """ if job_id in SKIP_IN_PATH: raise ValueError("Empty value passed for parameter 'job_id'") @@ -1014,6 +1015,8 @@ async def get_buckets( __query["from"] = from_ if human is not None: __query["human"] = human + if page is not None: + __body["page"] = page if pretty is not None: __query["pretty"] = pretty if size is not None: @@ -2812,10 +2815,10 @@ async def put_job( *, job_id: Any, analysis_config: Any, - background_persist_interval: Any, data_description: Any, allow_lazy_open: Optional[bool] = None, analysis_limits: Optional[Any] = None, + background_persist_interval: Optional[Any] = None, custom_settings: Optional[Any] = None, daily_model_snapshot_retention_after_days: Optional[int] = None, datafeed_config: Optional[Any] = None, @@ -2842,12 +2845,6 @@ async def put_job( :param analysis_config: Specifies how to analyze the data. After you create a job, you cannot change the analysis configuration; all the properties are informational. - :param background_persist_interval: Advanced configuration option. The time between - each periodic persistence of the model. The default value is a randomized - value between 3 to 4 hours, which avoids all jobs persisting at exactly the - same time. The smallest allowed value is 1 hour. For very large models (several - GB), persistence could take 10-20 minutes, so do not set the `background_persist_interval` - value too low. :param data_description: Defines the format of the input data when you send data to the job by using the post data API. Note that when configure a datafeed, these properties are automatically set. When data is received via the post @@ -2866,6 +2863,12 @@ async def put_job( the mathematical models in memory. These limits are approximate and can be set per job. They do not control the memory used by other processes, for example the Elasticsearch Java processes. + :param background_persist_interval: Advanced configuration option. The time between + each periodic persistence of the model. The default value is a randomized + value between 3 to 4 hours, which avoids all jobs persisting at exactly the + same time. The smallest allowed value is 1 hour. For very large models (several + GB), persistence could take 10-20 minutes, so do not set the `background_persist_interval` + value too low. :param custom_settings: Advanced configuration option. Contains custom meta data about the job. :param daily_model_snapshot_retention_after_days: Advanced configuration option, @@ -2913,10 +2916,6 @@ async def put_job( raise ValueError("Empty value passed for parameter 'job_id'") if analysis_config is None: raise ValueError("Empty value passed for parameter 'analysis_config'") - if background_persist_interval is None: - raise ValueError( - "Empty value passed for parameter 'background_persist_interval'" - ) if data_description is None: raise ValueError("Empty value passed for parameter 'data_description'") __path = f"/_ml/anomaly_detectors/{_quote(job_id)}" @@ -2924,14 +2923,14 @@ async def put_job( __query: Dict[str, Any] = {} if analysis_config is not None: __body["analysis_config"] = analysis_config - if background_persist_interval is not None: - __body["background_persist_interval"] = background_persist_interval if data_description is not None: __body["data_description"] = data_description if allow_lazy_open is not None: __body["allow_lazy_open"] = allow_lazy_open if analysis_limits is not None: __body["analysis_limits"] = analysis_limits + if background_persist_interval is not None: + __body["background_persist_interval"] = background_persist_interval if custom_settings is not None: __body["custom_settings"] = custom_settings if daily_model_snapshot_retention_after_days is not None: diff --git a/elasticsearch/_sync/client/__init__.py b/elasticsearch/_sync/client/__init__.py index 99438840a..52661b22c 100644 --- a/elasticsearch/_sync/client/__init__.py +++ b/elasticsearch/_sync/client/__init__.py @@ -33,15 +33,16 @@ from elastic_transport import ( BaseNode, + HeadApiResponse, NodeConfig, NodePool, NodeSelector, Serializer, Transport, - TransportError, ) from elastic_transport.client_utils import DEFAULT, DefaultType +from ...exceptions import ApiError from ...serializer import DEFAULT_SERIALIZERS from ._base import ( BaseClient, @@ -456,7 +457,7 @@ def ping( filter_path: Optional[Union[List[str], str]] = None, human: Optional[bool] = None, pretty: Optional[bool] = None, - ) -> bool: + ) -> Any: """ Returns basic information about the cluster. @@ -479,9 +480,9 @@ def ping( __headers = {"accept": "application/json"} try: resp = self._perform_request("HEAD", __target, headers=__headers) - return bool(resp) - except TransportError: - return False + return resp + except ApiError as e: + return HeadApiResponse(meta=e.meta) # AUTO-GENERATED-API-DEFINITIONS # @@ -2071,7 +2072,6 @@ def info( @_rewrite_parameters( body_fields=True, parameter_aliases={"_source": "source"}, - ignore_deprecated_options=True, ) def knn_search( self, diff --git a/elasticsearch/_sync/client/ml.py b/elasticsearch/_sync/client/ml.py index dc2a613ea..ceccb359d 100644 --- a/elasticsearch/_sync/client/ml.py +++ b/elasticsearch/_sync/client/ml.py @@ -948,6 +948,7 @@ def get_buckets( filter_path: Optional[Union[List[str], str]] = None, from_: Optional[int] = None, human: Optional[bool] = None, + page: Optional[Any] = None, pretty: Optional[bool] = None, size: Optional[int] = None, sort: Optional[Any] = None, @@ -961,18 +962,18 @@ def get_buckets( :param job_id: Identifier for the anomaly detection job. :param timestamp: The timestamp of a single bucket result. If you do not specify this parameter, the API returns information about all buckets. - :param anomaly_score: Returns buckets with anomaly scores greater or equal than - this value. - :param desc: If `true`, the buckets are sorted in descending order. - :param end: Returns buckets with timestamps earlier than this time. `-1` means - it is unset and results are not limited to specific timestamps. - :param exclude_interim: If `true`, the output excludes interim results. - :param expand: If true, the output includes anomaly records. + :param anomaly_score: Refer to the description for the `anomaly_score` query + parameter. + :param desc: Refer to the description for the `desc` query parameter. + :param end: Refer to the description for the `end` query parameter. + :param exclude_interim: Refer to the description for the `exclude_interim` query + parameter. + :param expand: Refer to the description for the `expand` query parameter. :param from_: Skips the specified number of buckets. + :param page: :param size: Specifies the maximum number of buckets to obtain. - :param sort: Specifies the sort field for the requested buckets. - :param start: Returns buckets with timestamps after this time. `-1` means it - is unset and results are not limited to specific timestamps. + :param sort: Refer to the desription for the `sort` query parameter. + :param start: Refer to the description for the `start` query parameter. """ if job_id in SKIP_IN_PATH: raise ValueError("Empty value passed for parameter 'job_id'") @@ -1002,6 +1003,8 @@ def get_buckets( __query["from"] = from_ if human is not None: __query["human"] = human + if page is not None: + __body["page"] = page if pretty is not None: __query["pretty"] = pretty if size is not None: @@ -2770,10 +2773,10 @@ def put_job( *, job_id: Any, analysis_config: Any, - background_persist_interval: Any, data_description: Any, allow_lazy_open: Optional[bool] = None, analysis_limits: Optional[Any] = None, + background_persist_interval: Optional[Any] = None, custom_settings: Optional[Any] = None, daily_model_snapshot_retention_after_days: Optional[int] = None, datafeed_config: Optional[Any] = None, @@ -2800,12 +2803,6 @@ def put_job( :param analysis_config: Specifies how to analyze the data. After you create a job, you cannot change the analysis configuration; all the properties are informational. - :param background_persist_interval: Advanced configuration option. The time between - each periodic persistence of the model. The default value is a randomized - value between 3 to 4 hours, which avoids all jobs persisting at exactly the - same time. The smallest allowed value is 1 hour. For very large models (several - GB), persistence could take 10-20 minutes, so do not set the `background_persist_interval` - value too low. :param data_description: Defines the format of the input data when you send data to the job by using the post data API. Note that when configure a datafeed, these properties are automatically set. When data is received via the post @@ -2824,6 +2821,12 @@ def put_job( the mathematical models in memory. These limits are approximate and can be set per job. They do not control the memory used by other processes, for example the Elasticsearch Java processes. + :param background_persist_interval: Advanced configuration option. The time between + each periodic persistence of the model. The default value is a randomized + value between 3 to 4 hours, which avoids all jobs persisting at exactly the + same time. The smallest allowed value is 1 hour. For very large models (several + GB), persistence could take 10-20 minutes, so do not set the `background_persist_interval` + value too low. :param custom_settings: Advanced configuration option. Contains custom meta data about the job. :param daily_model_snapshot_retention_after_days: Advanced configuration option, @@ -2871,10 +2874,6 @@ def put_job( raise ValueError("Empty value passed for parameter 'job_id'") if analysis_config is None: raise ValueError("Empty value passed for parameter 'analysis_config'") - if background_persist_interval is None: - raise ValueError( - "Empty value passed for parameter 'background_persist_interval'" - ) if data_description is None: raise ValueError("Empty value passed for parameter 'data_description'") __path = f"/_ml/anomaly_detectors/{_quote(job_id)}" @@ -2882,14 +2881,14 @@ def put_job( __query: Dict[str, Any] = {} if analysis_config is not None: __body["analysis_config"] = analysis_config - if background_persist_interval is not None: - __body["background_persist_interval"] = background_persist_interval if data_description is not None: __body["data_description"] = data_description if allow_lazy_open is not None: __body["allow_lazy_open"] = allow_lazy_open if analysis_limits is not None: __body["analysis_limits"] = analysis_limits + if background_persist_interval is not None: + __body["background_persist_interval"] = background_persist_interval if custom_settings is not None: __body["custom_settings"] = custom_settings if daily_model_snapshot_retention_after_days is not None: diff --git a/elasticsearch/_sync/client/utils.py b/elasticsearch/_sync/client/utils.py index 6d296f946..56b318cf5 100644 --- a/elasticsearch/_sync/client/utils.py +++ b/elasticsearch/_sync/client/utils.py @@ -74,7 +74,7 @@ "ignore", } -RT = TypeVar("RT") +F = TypeVar("F", bound=Callable[..., Any]) def client_node_configs( @@ -255,17 +255,16 @@ def _rewrite_parameters( body_name: Optional[str] = None, body_fields: bool = False, parameter_aliases: Optional[Dict[str, str]] = None, - ignore_deprecated_options: Optional[Union[bool, Set[str]]] = None, -) -> Callable[[Callable[..., RT]], Callable[..., RT]]: - def wrapper(api: Callable[..., RT]) -> Callable[..., RT]: + ignore_deprecated_options: Optional[Set[str]] = None, +) -> Callable[[F], F]: + def wrapper(api: F) -> F: @wraps(api) - def wrapped(*args: Any, **kwargs: Any) -> RT: + def wrapped(*args: Any, **kwargs: Any) -> Any: nonlocal api, body_name, body_fields # We merge 'params' first as transport options can be specified using params. if "params" in kwargs and ( - ignore_deprecated_options is not True - or ignore_deprecated_options is not None + not ignore_deprecated_options or "params" not in ignore_deprecated_options ): params = kwargs.pop("params") @@ -277,15 +276,14 @@ def wrapped(*args: Any, **kwargs: Any) -> RT: ) _merge_kwargs_no_duplicates(kwargs, params) - if ignore_deprecated_options is not True: + maybe_transport_options = _TRANSPORT_OPTIONS.intersection(kwargs) + if maybe_transport_options: transport_options = {} - options_to_skip: Set[str] = ( - ignore_deprecated_options - if isinstance(ignore_deprecated_options, set) - else set() - ) - for option in _TRANSPORT_OPTIONS: - if option in options_to_skip: + for option in maybe_transport_options: + if ( + ignore_deprecated_options + and option in ignore_deprecated_options + ): continue try: option_rename = option @@ -315,7 +313,9 @@ def wrapped(*args: Any, **kwargs: Any) -> RT: client = namespaced_client(client) args = (client,) + args[1:] - if "body" in kwargs and ignore_deprecated_options is not True: + if "body" in kwargs and ( + not ignore_deprecated_options or "body" not in ignore_deprecated_options + ): body = kwargs.pop("body") if body is not None: if body_name: @@ -359,6 +359,6 @@ def wrapped(*args: Any, **kwargs: Any) -> RT: return api(*args, **kwargs) - return wrapped + return wrapped # type: ignore[return-value] return wrapper 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 13fa0227d..08a628897 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 @@ -142,9 +142,21 @@ async def run_do(self, action): args["body"] = json.loads(args["body"]) except (TypeError, ValueError): pass + if isinstance(args["body"], dict): - body = args.pop("body") - args.update(body) + # Detect when there are duplicate options that aren't the same value. + # In this case the test isn't testing the client, it's testing Elasticsearch + # and its ability to reject multiple values so we either combine + # like values or skip the test entirely as unnecessary for the client. + duplicate_args = set(args["body"]).intersection(args) + if duplicate_args: + for arg in list(duplicate_args): + if args["body"][arg] == args[arg]: + args["body"].pop(arg) + else: + pytest.skip( + "Contains a duplicate parameter with a different value" + ) # some parameters had to be renamed to not clash with python builtins, # compensate diff --git a/test_elasticsearch/test_server/test_rest_api_spec.py b/test_elasticsearch/test_server/test_rest_api_spec.py index 38ed3f75f..63ea3760a 100644 --- a/test_elasticsearch/test_server/test_rest_api_spec.py +++ b/test_elasticsearch/test_server/test_rest_api_spec.py @@ -40,7 +40,7 @@ # some params had to be changed in python, keep track of them so we can rename # those in the tests accordingly -PARAMS_RENAMES = {"type": "doc_type", "from": "from_"} +PARAMS_RENAMES = {"from": "from_"} API_PARAMS_RENAMES = { "snapshot.create_repository": {"repository": "name"}, "snapshot.delete_repository": {"repository": "name"}, @@ -245,6 +245,21 @@ def run_do(self, action): except (TypeError, ValueError): pass + if isinstance(args["body"], dict): + # Detect when there are duplicate options that aren't the same value. + # In this case the test isn't testing the client, it's testing Elasticsearch + # and its ability to reject multiple values so we either combine + # like values or skip the test entirely as unnecessary for the client. + duplicate_args = set(args["body"]).intersection(args) + if duplicate_args: + for arg in list(duplicate_args): + if args["body"][arg] == args[arg]: + args["body"].pop(arg) + else: + pytest.skip( + "Contains a duplicate parameter with a different value" + ) + # some parameters had to be renamed to not clash with python builtins, # compensate renames = PARAMS_RENAMES.copy() From 39d800c5defde5fbc413b41ed423a220fffcb4f9 Mon Sep 17 00:00:00 2001 From: Seth Michael Larson Date: Wed, 17 Nov 2021 17:38:52 -0600 Subject: [PATCH 4/6] Skip tests where APIs are intentionally used incorrectly --- elasticsearch/_async/client/indices.py | 6 +- elasticsearch/_async/client/ml.py | 195 +++++++++++++++++- elasticsearch/_sync/client/indices.py | 6 +- elasticsearch/_sync/client/ml.py | 193 ++++++++++++++++- .../test_server/test_rest_api_spec.py | 4 +- .../test_server/test_rest_api_spec.py | 11 +- 6 files changed, 383 insertions(+), 32 deletions(-) diff --git a/elasticsearch/_async/client/indices.py b/elasticsearch/_async/client/indices.py index 703d17ea8..c67e671cc 100644 --- a/elasticsearch/_async/client/indices.py +++ b/elasticsearch/_async/client/indices.py @@ -2908,7 +2908,6 @@ async def simulate_index_template( async def simulate_template( self, *, - template: Any, name: Optional[Any] = None, create: Optional[bool] = None, error_trace: Optional[bool] = None, @@ -2916,13 +2915,13 @@ async def simulate_template( human: Optional[bool] = None, master_timeout: Optional[Any] = None, pretty: Optional[bool] = None, + template: Optional[Any] = None, ) -> Any: """ Simulate resolving the given template name or body ``_ - :param template: :param name: Name of the index template to simulate. To test a template configuration before you add it to the cluster, omit this parameter and specify the template configuration in the request body. @@ -2933,9 +2932,8 @@ async def simulate_template( :param master_timeout: Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. + :param template: """ - if template is None: - raise ValueError("Empty value passed for parameter 'template'") if name not in SKIP_IN_PATH: __path = f"/_index_template/_simulate/{_quote(name)}" else: diff --git a/elasticsearch/_async/client/ml.py b/elasticsearch/_async/client/ml.py index 850ef103e..8a57bd3fe 100644 --- a/elasticsearch/_async/client/ml.py +++ b/elasticsearch/_async/client/ml.py @@ -1724,6 +1724,7 @@ async def get_model_snapshots( filter_path: Optional[Union[List[str], str]] = None, from_: Optional[int] = None, human: Optional[bool] = None, + page: Optional[Any] = None, pretty: Optional[bool] = None, size: Optional[int] = None, sort: Optional[Any] = None, @@ -1736,16 +1737,17 @@ async def get_model_snapshots( :param job_id: Identifier for the anomaly detection job. :param snapshot_id: A numerical character string that uniquely identifies the - model snapshot. - :param desc: If true, the results are sorted in descending order. - :param end: Returns snapshots with timestamps earlier than this time. Defaults - to unset, which means results are not limited to specific timestamps. + model snapshot. You can get information for multiple snapshots by using a + comma-separated list or a wildcard expression. You can get all snapshots + by using `_all`, by specifying `*` as the snapshot ID, or by omitting the + snapshot ID. + :param desc: Refer to the description for the `desc` query parameter. + :param end: Refer to the description for the `end` query parameter. :param from_: Skips the specified number of snapshots. + :param page: :param size: Specifies the maximum number of snapshots to obtain. - :param sort: Specifies the sort field for the requested snapshots. By default, - the snapshots are sorted by their timestamp. - :param start: Returns snapshots with timestamps after this time. Defaults to - unset, which means results are not limited to specific timestamps. + :param sort: Refer to the description for the `sort` query parameter. + :param start: Refer to the description for the `start` query parameter. """ if job_id in SKIP_IN_PATH: raise ValueError("Empty value passed for parameter 'job_id'") @@ -1755,10 +1757,10 @@ async def get_model_snapshots( __path = f"/_ml/anomaly_detectors/{_quote(job_id)}/model_snapshots" else: raise ValueError("Couldn't find a path for the given parameters") - __query: Dict[str, Any] = {} __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} if desc is not None: - __query["desc"] = desc + __body["desc"] = desc if end is not None: __body["end"] = end if error_trace is not None: @@ -1769,12 +1771,14 @@ async def get_model_snapshots( __query["from"] = from_ if human is not None: __query["human"] = human + if page is not None: + __body["page"] = page if pretty is not None: __query["pretty"] = pretty if size is not None: __query["size"] = size if sort is not None: - __query["sort"] = sort + __body["sort"] = sort if start is not None: __body["start"] = start if not __body: @@ -3528,6 +3532,175 @@ async def update_data_frame_analytics( "POST", __target, headers=__headers, body=__body ) + @_rewrite_parameters( + body_fields=True, + ) + async def update_datafeed( + self, + *, + datafeed_id: Any, + aggregations: Optional[Dict[str, Any]] = None, + allow_no_indices: Optional[bool] = None, + chunking_config: Optional[Any] = None, + delayed_data_check_config: Optional[Any] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + frequency: Optional[Any] = None, + human: Optional[bool] = None, + ignore_throttled: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + indexes: Optional[List[str]] = None, + indices: Optional[List[str]] = None, + indices_options: Optional[Any] = None, + max_empty_searches: Optional[int] = None, + pretty: Optional[bool] = None, + query: Optional[Any] = None, + query_delay: Optional[Any] = None, + runtime_mappings: Optional[Any] = None, + script_fields: Optional[Dict[str, Any]] = None, + scroll_size: Optional[int] = None, + ) -> Any: + """ + Updates certain properties of a datafeed. + + ``_ + + :param datafeed_id: A numerical character string that uniquely identifies the + datafeed. This identifier can contain lowercase alphanumeric characters (a-z + and 0-9), hyphens, and underscores. It must start and end with alphanumeric + characters. + :param aggregations: If set, the datafeed performs aggregation searches. Support + for aggregations is limited and should be used only with low cardinality + data. + :param allow_no_indices: If `true`, wildcard indices expressions that resolve + into no concrete indices are ignored. This includes the `_all` string or + when no indices are specified. + :param chunking_config: Datafeeds might search over long time periods, for several + months or years. This search is split into time chunks in order to ensure + the load on Elasticsearch is managed. Chunking configuration controls how + the size of these time chunks are calculated; it is an advanced configuration + option. + :param delayed_data_check_config: Specifies whether the datafeed checks for missing + data and the size of the window. The datafeed can optionally search over + indices that have already been read in an effort to determine whether any + data has subsequently been added to the index. If missing data is found, + it is a good indication that the `query_delay` is set too low and the data + is being indexed after the datafeed has passed that moment in time. This + check runs only on real-time datafeeds. + :param expand_wildcards: Type of index that wildcard patterns can match. If the + request can target data streams, this argument determines whether wildcard + expressions match hidden data streams. Supports comma-separated values. Valid + values are: * `all`: Match any data stream or index, including hidden ones. + * `closed`: Match closed, non-hidden indices. Also matches any non-hidden + data stream. Data streams cannot be closed. * `hidden`: Match hidden data + streams and hidden indices. Must be combined with `open`, `closed`, or both. + * `none`: Wildcard patterns are not accepted. * `open`: Match open, non-hidden + indices. Also matches any non-hidden data stream. + :param frequency: The interval at which scheduled queries are made while the + datafeed runs in real time. The default value is either the bucket span for + short bucket spans, or, for longer bucket spans, a sensible fraction of the + bucket span. When `frequency` is shorter than the bucket span, interim results + for the last (partial) bucket are written then eventually overwritten by + the full bucket results. If the datafeed uses aggregations, this value must + be divisible by the interval of the date histogram aggregation. + :param ignore_throttled: If `true`, concrete, expanded or aliased indices are + ignored when frozen. + :param ignore_unavailable: If `true`, unavailable indices (missing or closed) + are ignored. + :param indexes: An array of index names. Wildcards are supported. If any of the + indices are in remote clusters, the machine learning nodes must have the + `remote_cluster_client` role. + :param indices: An array of index names. Wildcards are supported. If any of the + indices are in remote clusters, the machine learning nodes must have the + `remote_cluster_client` role. + :param indices_options: Specifies index expansion options that are used during + search. + :param max_empty_searches: If a real-time datafeed has never seen any data (including + during any initial training period), it automatically stops and closes the + associated job after this many real-time searches return no documents. In + other words, it stops after `frequency` times `max_empty_searches` of real-time + operation. If not set, a datafeed with no end time that sees no data remains + started until it is explicitly stopped. By default, it is not set. + :param query: The Elasticsearch query domain-specific language (DSL). This value + corresponds to the query object in an Elasticsearch search POST body. All + the options that are supported by Elasticsearch can be used, as this object + is passed verbatim to Elasticsearch. Note that if you change the query, the + analyzed data is also changed. Therefore, the time required to learn might + be long and the understandability of the results is unpredictable. If you + want to make significant changes to the source data, it is recommended that + you clone the job and datafeed and make the amendments in the clone. Let + both run in parallel and close one when you are satisfied with the results + of the job. + :param query_delay: The number of seconds behind real time that data is queried. + For example, if data from 10:04 a.m. might not be searchable in Elasticsearch + until 10:06 a.m., set this property to 120 seconds. The default value is + randomly selected between `60s` and `120s`. This randomness improves the + query performance when there are multiple jobs running on the same node. + :param runtime_mappings: Specifies runtime fields for the datafeed search. + :param script_fields: Specifies scripts that evaluate custom expressions and + returns script fields to the datafeed. The detector configuration objects + in a job can contain functions that use these script fields. + :param scroll_size: The size parameter that is used in Elasticsearch searches + when the datafeed does not use aggregations. The maximum value is the value + of `index.max_result_window`. + """ + if datafeed_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'datafeed_id'") + __path = f"/_ml/datafeeds/{_quote(datafeed_id)}/_update" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if aggregations is not None: + __body["aggregations"] = aggregations + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if chunking_config is not None: + __body["chunking_config"] = chunking_config + if delayed_data_check_config is not None: + __body["delayed_data_check_config"] = delayed_data_check_config + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if frequency is not None: + __body["frequency"] = frequency + if human is not None: + __query["human"] = human + if ignore_throttled is not None: + __query["ignore_throttled"] = ignore_throttled + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if indexes is not None: + __body["indexes"] = indexes + if indices is not None: + __body["indices"] = indices + if indices_options is not None: + __body["indices_options"] = indices_options + if max_empty_searches is not None: + __body["max_empty_searches"] = max_empty_searches + if pretty is not None: + __query["pretty"] = pretty + if query is not None: + __body["query"] = query + if query_delay is not None: + __body["query_delay"] = query_delay + if runtime_mappings is not None: + __body["runtime_mappings"] = runtime_mappings + if script_fields is not None: + __body["script_fields"] = script_fields + if scroll_size is not None: + __body["scroll_size"] = scroll_size + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return await self._perform_request( + "POST", __target, headers=__headers, body=__body + ) + @_rewrite_parameters( body_fields=True, ) diff --git a/elasticsearch/_sync/client/indices.py b/elasticsearch/_sync/client/indices.py index 1f3a14ce1..9a05979e9 100644 --- a/elasticsearch/_sync/client/indices.py +++ b/elasticsearch/_sync/client/indices.py @@ -2886,7 +2886,6 @@ def simulate_index_template( def simulate_template( self, *, - template: Any, name: Optional[Any] = None, create: Optional[bool] = None, error_trace: Optional[bool] = None, @@ -2894,13 +2893,13 @@ def simulate_template( human: Optional[bool] = None, master_timeout: Optional[Any] = None, pretty: Optional[bool] = None, + template: Optional[Any] = None, ) -> Any: """ Simulate resolving the given template name or body ``_ - :param template: :param name: Name of the index template to simulate. To test a template configuration before you add it to the cluster, omit this parameter and specify the template configuration in the request body. @@ -2911,9 +2910,8 @@ def simulate_template( :param master_timeout: Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. + :param template: """ - if template is None: - raise ValueError("Empty value passed for parameter 'template'") if name not in SKIP_IN_PATH: __path = f"/_index_template/_simulate/{_quote(name)}" else: diff --git a/elasticsearch/_sync/client/ml.py b/elasticsearch/_sync/client/ml.py index ceccb359d..0f9023e81 100644 --- a/elasticsearch/_sync/client/ml.py +++ b/elasticsearch/_sync/client/ml.py @@ -1704,6 +1704,7 @@ def get_model_snapshots( filter_path: Optional[Union[List[str], str]] = None, from_: Optional[int] = None, human: Optional[bool] = None, + page: Optional[Any] = None, pretty: Optional[bool] = None, size: Optional[int] = None, sort: Optional[Any] = None, @@ -1716,16 +1717,17 @@ def get_model_snapshots( :param job_id: Identifier for the anomaly detection job. :param snapshot_id: A numerical character string that uniquely identifies the - model snapshot. - :param desc: If true, the results are sorted in descending order. - :param end: Returns snapshots with timestamps earlier than this time. Defaults - to unset, which means results are not limited to specific timestamps. + model snapshot. You can get information for multiple snapshots by using a + comma-separated list or a wildcard expression. You can get all snapshots + by using `_all`, by specifying `*` as the snapshot ID, or by omitting the + snapshot ID. + :param desc: Refer to the description for the `desc` query parameter. + :param end: Refer to the description for the `end` query parameter. :param from_: Skips the specified number of snapshots. + :param page: :param size: Specifies the maximum number of snapshots to obtain. - :param sort: Specifies the sort field for the requested snapshots. By default, - the snapshots are sorted by their timestamp. - :param start: Returns snapshots with timestamps after this time. Defaults to - unset, which means results are not limited to specific timestamps. + :param sort: Refer to the description for the `sort` query parameter. + :param start: Refer to the description for the `start` query parameter. """ if job_id in SKIP_IN_PATH: raise ValueError("Empty value passed for parameter 'job_id'") @@ -1735,10 +1737,10 @@ def get_model_snapshots( __path = f"/_ml/anomaly_detectors/{_quote(job_id)}/model_snapshots" else: raise ValueError("Couldn't find a path for the given parameters") - __query: Dict[str, Any] = {} __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} if desc is not None: - __query["desc"] = desc + __body["desc"] = desc if end is not None: __body["end"] = end if error_trace is not None: @@ -1749,12 +1751,14 @@ def get_model_snapshots( __query["from"] = from_ if human is not None: __query["human"] = human + if page is not None: + __body["page"] = page if pretty is not None: __query["pretty"] = pretty if size is not None: __query["size"] = size if sort is not None: - __query["sort"] = sort + __body["sort"] = sort if start is not None: __body["start"] = start if not __body: @@ -3474,6 +3478,173 @@ def update_data_frame_analytics( __headers = {"accept": "application/json", "content-type": "application/json"} return self._perform_request("POST", __target, headers=__headers, body=__body) + @_rewrite_parameters( + body_fields=True, + ) + def update_datafeed( + self, + *, + datafeed_id: Any, + aggregations: Optional[Dict[str, Any]] = None, + allow_no_indices: Optional[bool] = None, + chunking_config: Optional[Any] = None, + delayed_data_check_config: Optional[Any] = None, + error_trace: Optional[bool] = None, + expand_wildcards: Optional[Any] = None, + filter_path: Optional[Union[List[str], str]] = None, + frequency: Optional[Any] = None, + human: Optional[bool] = None, + ignore_throttled: Optional[bool] = None, + ignore_unavailable: Optional[bool] = None, + indexes: Optional[List[str]] = None, + indices: Optional[List[str]] = None, + indices_options: Optional[Any] = None, + max_empty_searches: Optional[int] = None, + pretty: Optional[bool] = None, + query: Optional[Any] = None, + query_delay: Optional[Any] = None, + runtime_mappings: Optional[Any] = None, + script_fields: Optional[Dict[str, Any]] = None, + scroll_size: Optional[int] = None, + ) -> Any: + """ + Updates certain properties of a datafeed. + + ``_ + + :param datafeed_id: A numerical character string that uniquely identifies the + datafeed. This identifier can contain lowercase alphanumeric characters (a-z + and 0-9), hyphens, and underscores. It must start and end with alphanumeric + characters. + :param aggregations: If set, the datafeed performs aggregation searches. Support + for aggregations is limited and should be used only with low cardinality + data. + :param allow_no_indices: If `true`, wildcard indices expressions that resolve + into no concrete indices are ignored. This includes the `_all` string or + when no indices are specified. + :param chunking_config: Datafeeds might search over long time periods, for several + months or years. This search is split into time chunks in order to ensure + the load on Elasticsearch is managed. Chunking configuration controls how + the size of these time chunks are calculated; it is an advanced configuration + option. + :param delayed_data_check_config: Specifies whether the datafeed checks for missing + data and the size of the window. The datafeed can optionally search over + indices that have already been read in an effort to determine whether any + data has subsequently been added to the index. If missing data is found, + it is a good indication that the `query_delay` is set too low and the data + is being indexed after the datafeed has passed that moment in time. This + check runs only on real-time datafeeds. + :param expand_wildcards: Type of index that wildcard patterns can match. If the + request can target data streams, this argument determines whether wildcard + expressions match hidden data streams. Supports comma-separated values. Valid + values are: * `all`: Match any data stream or index, including hidden ones. + * `closed`: Match closed, non-hidden indices. Also matches any non-hidden + data stream. Data streams cannot be closed. * `hidden`: Match hidden data + streams and hidden indices. Must be combined with `open`, `closed`, or both. + * `none`: Wildcard patterns are not accepted. * `open`: Match open, non-hidden + indices. Also matches any non-hidden data stream. + :param frequency: The interval at which scheduled queries are made while the + datafeed runs in real time. The default value is either the bucket span for + short bucket spans, or, for longer bucket spans, a sensible fraction of the + bucket span. When `frequency` is shorter than the bucket span, interim results + for the last (partial) bucket are written then eventually overwritten by + the full bucket results. If the datafeed uses aggregations, this value must + be divisible by the interval of the date histogram aggregation. + :param ignore_throttled: If `true`, concrete, expanded or aliased indices are + ignored when frozen. + :param ignore_unavailable: If `true`, unavailable indices (missing or closed) + are ignored. + :param indexes: An array of index names. Wildcards are supported. If any of the + indices are in remote clusters, the machine learning nodes must have the + `remote_cluster_client` role. + :param indices: An array of index names. Wildcards are supported. If any of the + indices are in remote clusters, the machine learning nodes must have the + `remote_cluster_client` role. + :param indices_options: Specifies index expansion options that are used during + search. + :param max_empty_searches: If a real-time datafeed has never seen any data (including + during any initial training period), it automatically stops and closes the + associated job after this many real-time searches return no documents. In + other words, it stops after `frequency` times `max_empty_searches` of real-time + operation. If not set, a datafeed with no end time that sees no data remains + started until it is explicitly stopped. By default, it is not set. + :param query: The Elasticsearch query domain-specific language (DSL). This value + corresponds to the query object in an Elasticsearch search POST body. All + the options that are supported by Elasticsearch can be used, as this object + is passed verbatim to Elasticsearch. Note that if you change the query, the + analyzed data is also changed. Therefore, the time required to learn might + be long and the understandability of the results is unpredictable. If you + want to make significant changes to the source data, it is recommended that + you clone the job and datafeed and make the amendments in the clone. Let + both run in parallel and close one when you are satisfied with the results + of the job. + :param query_delay: The number of seconds behind real time that data is queried. + For example, if data from 10:04 a.m. might not be searchable in Elasticsearch + until 10:06 a.m., set this property to 120 seconds. The default value is + randomly selected between `60s` and `120s`. This randomness improves the + query performance when there are multiple jobs running on the same node. + :param runtime_mappings: Specifies runtime fields for the datafeed search. + :param script_fields: Specifies scripts that evaluate custom expressions and + returns script fields to the datafeed. The detector configuration objects + in a job can contain functions that use these script fields. + :param scroll_size: The size parameter that is used in Elasticsearch searches + when the datafeed does not use aggregations. The maximum value is the value + of `index.max_result_window`. + """ + if datafeed_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for parameter 'datafeed_id'") + __path = f"/_ml/datafeeds/{_quote(datafeed_id)}/_update" + __body: Dict[str, Any] = {} + __query: Dict[str, Any] = {} + if aggregations is not None: + __body["aggregations"] = aggregations + if allow_no_indices is not None: + __query["allow_no_indices"] = allow_no_indices + if chunking_config is not None: + __body["chunking_config"] = chunking_config + if delayed_data_check_config is not None: + __body["delayed_data_check_config"] = delayed_data_check_config + if error_trace is not None: + __query["error_trace"] = error_trace + if expand_wildcards is not None: + __query["expand_wildcards"] = expand_wildcards + if filter_path is not None: + __query["filter_path"] = filter_path + if frequency is not None: + __body["frequency"] = frequency + if human is not None: + __query["human"] = human + if ignore_throttled is not None: + __query["ignore_throttled"] = ignore_throttled + if ignore_unavailable is not None: + __query["ignore_unavailable"] = ignore_unavailable + if indexes is not None: + __body["indexes"] = indexes + if indices is not None: + __body["indices"] = indices + if indices_options is not None: + __body["indices_options"] = indices_options + if max_empty_searches is not None: + __body["max_empty_searches"] = max_empty_searches + if pretty is not None: + __query["pretty"] = pretty + if query is not None: + __body["query"] = query + if query_delay is not None: + __body["query_delay"] = query_delay + if runtime_mappings is not None: + __body["runtime_mappings"] = runtime_mappings + if script_fields is not None: + __body["script_fields"] = script_fields + if scroll_size is not None: + __body["scroll_size"] = scroll_size + if __query: + __target = f"{__path}?{_quote_query(__query)}" + else: + __target = __path + __headers = {"accept": "application/json", "content-type": "application/json"} + return self._perform_request("POST", __target, headers=__headers, body=__body) + @_rewrite_parameters( body_fields=True, ) 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 08a628897..7714608a7 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 @@ -133,7 +133,8 @@ async def run_do(self, action): # locate api endpoint for m in method.split("."): - assert hasattr(api, m) + if not hasattr(api, m): + pytest.skip("This API isn't implemented yet") api = getattr(api, m) # Sometimes the 'body' parameter is encoded as a string instead of raw. @@ -175,6 +176,7 @@ async def run_do(self, action): try: self.last_response = (await api(**args)).raw except Exception as e: + self._skip_intentional_type_errors(e) if not catch: raise self.run_catch(catch, e) diff --git a/test_elasticsearch/test_server/test_rest_api_spec.py b/test_elasticsearch/test_server/test_rest_api_spec.py index 63ea3760a..e86717cb9 100644 --- a/test_elasticsearch/test_server/test_rest_api_spec.py +++ b/test_elasticsearch/test_server/test_rest_api_spec.py @@ -235,7 +235,8 @@ def run_do(self, action): # locate api endpoint for m in method.split("."): - assert hasattr(api, m) + if not hasattr(api, m): + pytest.skip("This API isn't implemented yet") api = getattr(api, m) # Sometimes the 'body' parameter is encoded as a string instead of raw. @@ -277,6 +278,7 @@ def run_do(self, action): try: self.last_response = api(**args).raw except Exception as e: + self._skip_intentional_type_errors(e) if not catch: raise self.run_catch(catch, e) @@ -504,6 +506,13 @@ def _assert_match_equals(self, a, b): assert a == b, f"{a!r} does not match {b!r}" + def _skip_intentional_type_errors(self, e: Exception): + if isinstance(e, TypeError) and ( + "unexpected keyword argument" in str(e) + or "required keyword-only argument" in str(e) + ): + pytest.skip("API intentionally used incorrectly in test") + @pytest.fixture(scope="function") def sync_runner(sync_client): From 6a20625e2a35a4fe0fc79d0b6bc9bd769b015548 Mon Sep 17 00:00:00 2001 From: Seth Michael Larson Date: Thu, 18 Nov 2021 08:42:44 -0600 Subject: [PATCH 5/6] Fix async server tests --- .../test_async/test_server/test_clients.py | 4 +- .../test_async/test_server/test_helpers.py | 38 ++++++++----------- .../test_server/test_mapbox_vector_tile.py | 2 +- .../test_server/test_mapbox_vector_tile.py | 2 +- 4 files changed, 19 insertions(+), 27 deletions(-) diff --git a/test_elasticsearch/test_async/test_server/test_clients.py b/test_elasticsearch/test_async/test_server/test_clients.py index 04035f3df..8ae5726c1 100644 --- a/test_elasticsearch/test_async/test_server/test_clients.py +++ b/test_elasticsearch/test_async/test_server/test_clients.py @@ -39,7 +39,7 @@ async def test_indices_analyze_unicode(async_client, kwargs): } -async def test_bulk_works_with_string_body(self, async_client): +async def test_bulk_works_with_string_body(async_client): docs = '{ "index" : { "_index" : "bulk_test_index", "_id" : "1" } }\n{"answer": 42}' response = await async_client.bulk(body=docs) @@ -47,7 +47,7 @@ async def test_bulk_works_with_string_body(self, async_client): assert len(response["items"]) == 1 -async def test_bulk_works_with_bytestring_body(self, async_client): +async def test_bulk_works_with_bytestring_body(async_client): docs = ( b'{ "index" : { "_index" : "bulk_test_index", "_id" : "2" } }\n{"answer": 42}' ) diff --git a/test_elasticsearch/test_async/test_server/test_helpers.py b/test_elasticsearch/test_async/test_server/test_helpers.py index cc099d5ff..78e6929a6 100644 --- a/test_elasticsearch/test_async/test_server/test_helpers.py +++ b/test_elasticsearch/test_async/test_server/test_helpers.py @@ -123,11 +123,9 @@ def sync_gen(): async def test_all_errors_from_chunk_are_raised_on_failure(self, async_client): await async_client.indices.create( - "i", - { - "mappings": {"properties": {"a": {"type": "integer"}}}, - "settings": {"number_of_shards": 1, "number_of_replicas": 0}, - }, + index="i", + mappings={"properties": {"a": {"type": "integer"}}}, + settings={"number_of_shards": 1, "number_of_replicas": 0}, ) await async_client.cluster.health(wait_for_status="yellow") @@ -334,11 +332,9 @@ async def test_stats_only_reports_numbers(self, async_client): async def test_errors_are_reported_correctly(self, async_client): await async_client.indices.create( - "i", - { - "mappings": {"properties": {"a": {"type": "integer"}}}, - "settings": {"number_of_shards": 1, "number_of_replicas": 0}, - }, + index="i", + mappings={"properties": {"a": {"type": "integer"}}}, + settings={"number_of_shards": 1, "number_of_replicas": 0}, ) await async_client.cluster.health(wait_for_status="yellow") @@ -360,11 +356,9 @@ async def test_errors_are_reported_correctly(self, async_client): async def test_error_is_raised(self, async_client): await async_client.indices.create( - "i", - { - "mappings": {"properties": {"a": {"type": "integer"}}}, - "settings": {"number_of_shards": 1, "number_of_replicas": 0}, - }, + index="i", + mappings={"properties": {"a": {"type": "integer"}}}, + settings={"number_of_shards": 1, "number_of_replicas": 0}, ) await async_client.cluster.health(wait_for_status="yellow") @@ -406,11 +400,9 @@ async def test_ignore_error_if_raised(self, async_client): async def test_errors_are_collected_properly(self, async_client): await async_client.indices.create( - "i", - { - "mappings": {"properties": {"a": {"type": "integer"}}}, - "settings": {"number_of_shards": 1, "number_of_replicas": 0}, - }, + index="i", + mappings={"properties": {"a": {"type": "integer"}}}, + settings={"number_of_shards": 1, "number_of_replicas": 0}, ) await async_client.cluster.health(wait_for_status="yellow") @@ -867,7 +859,7 @@ async def test_reindex_passes_kwargs_to_scan_and_bulk( bulk_kwargs={"refresh": True}, ) - assert await async_client.indices.exists("prod_index") + assert await async_client.indices.exists(index="prod_index") assert ( 50 == (await async_client.count(index="prod_index", q="type:answers"))["count"] @@ -886,7 +878,7 @@ async def test_reindex_accepts_a_query(self, async_client, reindex_setup): ) await async_client.indices.refresh() - assert await async_client.indices.exists("prod_index") + assert await async_client.indices.exists(index="prod_index") assert ( 50 == (await async_client.count(index="prod_index", q="type:answers"))["count"] @@ -900,7 +892,7 @@ async def test_all_documents_get_moved(self, async_client, reindex_setup): await helpers.async_reindex(async_client, "test_index", "prod_index") await async_client.indices.refresh() - assert await async_client.indices.exists("prod_index") + assert await async_client.indices.exists(index="prod_index") assert ( 50 == (await async_client.count(index="prod_index", q="type:questions"))[ diff --git a/test_elasticsearch/test_async/test_server/test_mapbox_vector_tile.py b/test_elasticsearch/test_async/test_server/test_mapbox_vector_tile.py index bc0266939..ad7439b91 100644 --- a/test_elasticsearch/test_async/test_server/test_mapbox_vector_tile.py +++ b/test_elasticsearch/test_async/test_server/test_mapbox_vector_tile.py @@ -117,7 +117,7 @@ async def test_mapbox_vector_tile_response(elasticsearch_url, mvt_setup, ca_cert try: import mapbox_vector_tile except ImportError: - return pytest.skip(reason="Requires the 'mapbox-vector-tile' package") + return pytest.skip("Requires the 'mapbox-vector-tile' package") client = AsyncElasticsearch(elasticsearch_url, ca_certs=ca_certs) diff --git a/test_elasticsearch/test_server/test_mapbox_vector_tile.py b/test_elasticsearch/test_server/test_mapbox_vector_tile.py index a2bad25f4..c3c7095f3 100644 --- a/test_elasticsearch/test_server/test_mapbox_vector_tile.py +++ b/test_elasticsearch/test_server/test_mapbox_vector_tile.py @@ -119,7 +119,7 @@ def test_mapbox_vector_tile_response( try: import mapbox_vector_tile except ImportError: - return pytest.skip(reason="Requires the 'mapbox-vector-tile' package") + return pytest.skip("Requires the 'mapbox-vector-tile' package") client = Elasticsearch(elasticsearch_url, node_class=node_class, ca_certs=ca_certs) From 4a33d9ad0ee0e8da0579a8d89c6e47f3f37c70ce Mon Sep 17 00:00:00 2001 From: Seth Michael Larson Date: Fri, 19 Nov 2021 10:39:14 -0600 Subject: [PATCH 6/6] Add test cases for 'rewrite_parameters' decorator --- elasticsearch/_sync/client/utils.py | 23 +- .../test_client/test_rewrite_parameters.py | 214 ++++++++++++++++++ 2 files changed, 230 insertions(+), 7 deletions(-) create mode 100644 test_elasticsearch/test_client/test_rewrite_parameters.py diff --git a/elasticsearch/_sync/client/utils.py b/elasticsearch/_sync/client/utils.py index 56b318cf5..cade888f7 100644 --- a/elasticsearch/_sync/client/utils.py +++ b/elasticsearch/_sync/client/utils.py @@ -274,6 +274,13 @@ def wrapped(*args: Any, **kwargs: Any) -> Any: "Couldn't merge 'params' with other parameters as it wasn't a mapping. " "Instead of using 'params' use individual API parameters" ) + warnings.warn( + f"The 'params' parameter is deprecated for the '{api.__name__!s}' API and " + "will be removed in a future version. Instead use individual " + "parameters.", + category=DeprecationWarning, + stacklevel=warn_stacklevel(), + ) _merge_kwargs_no_duplicates(kwargs, params) maybe_transport_options = _TRANSPORT_OPTIONS.intersection(kwargs) @@ -321,15 +328,10 @@ def wrapped(*args: Any, **kwargs: Any) -> Any: if body_name: if body_name in kwargs: raise TypeError( - "Can't use '%s' and 'body' parameters together because '%s' " + f"Can't use '{body_name}' and 'body' parameters together because '{body_name}' " "is an alias for 'body'. Instead you should only use the " - "'%s' parameter. See https://github.com/elastic/elasticsearch-py/" + f"'{body_name}' parameter. See https://github.com/elastic/elasticsearch-py/" "issues/1698 for more information" - % ( - body_name, - body_name, - body_name, - ) ) warnings.warn( @@ -348,6 +350,13 @@ def wrapped(*args: Any, **kwargs: Any) -> Any: "Couldn't merge 'body' with other parameters as it wasn't a mapping. " "Instead of using 'body' use individual API parameters" ) + warnings.warn( + f"The 'body' parameter is deprecated for the '{api.__name__!s}' API and " + "will be removed in a future version. Instead use individual " + "parameters.", + category=DeprecationWarning, + stacklevel=warn_stacklevel(), + ) _merge_kwargs_no_duplicates(kwargs, body) if parameter_aliases: diff --git a/test_elasticsearch/test_client/test_rewrite_parameters.py b/test_elasticsearch/test_client/test_rewrite_parameters.py new file mode 100644 index 000000000..b6685d3b4 --- /dev/null +++ b/test_elasticsearch/test_client/test_rewrite_parameters.py @@ -0,0 +1,214 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +import warnings + +import pytest + +from elasticsearch._sync.client.utils import _rewrite_parameters + + +class TestRewriteParameters: + @property + def calls(self): + if not hasattr(self, "_calls"): + self._calls = [] + return self._calls + + def options(self, *args, **kwargs): + self.calls.append((args, kwargs)) + return self + + @_rewrite_parameters() + def wrapped_func_default(self, *args, **kwargs): + self.calls.append((args, kwargs)) + + @_rewrite_parameters(body_name="document") + def wrapped_func_body_name(self, *args, **kwargs): + self.calls.append((args, kwargs)) + + @_rewrite_parameters(body_fields=True) + def wrapped_func_body_fields(self, *args, **kwargs): + self.calls.append((args, kwargs)) + + @_rewrite_parameters( + body_fields=True, ignore_deprecated_options={"api_key", "body", "params"} + ) + def wrapped_func_ignore(self, *args, **kwargs): + self.calls.append((args, kwargs)) + + @_rewrite_parameters(body_fields=True, parameter_aliases={"_source": "source"}) + def wrapped_func_aliases(self, *args, **kwargs): + self.calls.append((args, kwargs)) + + def test_default(self): + with warnings.catch_warnings(record=True) as w: + self.wrapped_func_default( + api_key=("id", "api_key"), + query={"match_all": {}}, + params={"key": "value", "ignore": 404}, + ) + + assert len(w) == 2 + assert w[0].category == DeprecationWarning + assert ( + str(w[0].message) + == "The 'params' parameter is deprecated for the 'wrapped_func_default' API and will be removed in a future version. Instead use individual parameters." + ) + assert w[1].category == DeprecationWarning + assert ( + str(w[1].message) + == "Passing transport options in the API method is deprecated. Use 'Elasticsearch.options()' instead." + ) + + assert self.calls == [ + ((), {"api_key": ("id", "api_key"), "ignore_status": 404}), + ((), {"query": {"match_all": {}}, "key": "value"}), + ] + + def test_body_name_using_body(self): + with warnings.catch_warnings(record=True) as w: + self.wrapped_func_body_name( + api_key=("id", "api_key"), body={"query": {"match_all": {}}} + ) + + assert len(w) == 2 + assert w[0].category == DeprecationWarning + assert ( + str(w[0].message) + == "Passing transport options in the API method is deprecated. Use 'Elasticsearch.options()' instead." + ) + assert w[1].category == DeprecationWarning + assert str(w[1].message) == ( + "The 'body' parameter is deprecated for the 'wrapped_func_body_name' API and will be removed in a " + "future version. Instead use the 'document' parameter. See https://github.com/elastic/elasticsearch-py/issues/1698 " + "for more information" + ) + + assert self.calls == [ + ((), {"api_key": ("id", "api_key")}), + ((), {"document": {"query": {"match_all": {}}}}), + ] + + def test_body_name(self): + with warnings.catch_warnings(record=True) as w: + self.wrapped_func_body_name( + api_key=("id", "api_key"), document={"query": {"match_all": {}}} + ) + + assert len(w) == 1 + assert w[0].category == DeprecationWarning + assert ( + str(w[0].message) + == "Passing transport options in the API method is deprecated. Use 'Elasticsearch.options()' instead." + ) + + assert self.calls == [ + ((), {"api_key": ("id", "api_key")}), + ((), {"document": {"query": {"match_all": {}}}}), + ] + + def test_body_name_duplicate(self): + with pytest.raises(TypeError) as e: + self.wrapped_func_body_name(body={}, document={}) + + assert str(e.value) == ( + "Can't use 'document' and 'body' parameters together because 'document' is an alias for 'body'. " + "Instead you should only use the 'document' parameter. See https://github.com/elastic/elasticsearch-py" + "/issues/1698 for more information" + ) + + def test_body_fields(self): + with warnings.catch_warnings(record=True) as w: + self.wrapped_func_body_fields( + api_key=("id", "api_key"), body={"query": {"match_all": {}}} + ) + + assert len(w) == 2 + assert w[0].category == DeprecationWarning + assert ( + str(w[0].message) + == "Passing transport options in the API method is deprecated. Use 'Elasticsearch.options()' instead." + ) + assert w[1].category == DeprecationWarning + assert str(w[1].message) == ( + "The 'body' parameter is deprecated for the 'wrapped_func_body_fields' API and will be removed in a future version. Instead use individual parameters." + ) + + assert self.calls == [ + ((), {"api_key": ("id", "api_key")}), + ((), {"query": {"match_all": {}}}), + ] + + @pytest.mark.parametrize( + "body", ['{"query": {"match_all": {}}}', b'{"query": {"match_all": {}}}'] + ) + def test_error_on_body_merge(self, body): + with pytest.raises(ValueError) as e: + self.wrapped_func_body_fields(body=body) + assert str(e.value) == ( + "Couldn't merge 'body' with other parameters as it wasn't a mapping. Instead of " + "using 'body' use individual API parameters" + ) + + @pytest.mark.parametrize( + "params", ['{"query": {"match_all": {}}}', b'{"query": {"match_all": {}}}'] + ) + def test_error_on_params_merge(self, params): + with pytest.raises(ValueError) as e: + self.wrapped_func_body_fields(params=params) + assert str(e.value) == ( + "Couldn't merge 'params' with other parameters as it wasn't a mapping. Instead of " + "using 'params' use individual API parameters" + ) + + def test_ignore_deprecated_options(self): + with warnings.catch_warnings(record=True) as w: + self.wrapped_func_ignore( + api_key=("id", "api_key"), + body={"query": {"match_all": {}}}, + params={"key": "value"}, + param=1, + http_auth=("key", "value"), + ) + + assert len(w) == 1 + assert w[0].category == DeprecationWarning + assert ( + str(w[0].message) + == "Passing transport options in the API method is deprecated. Use 'Elasticsearch.options()' instead." + ) + + assert self.calls == [ + ((), {"http_auth": ("key", "value")}), + ( + (), + { + "api_key": ("id", "api_key"), + "body": {"query": {"match_all": {}}}, + "params": {"key": "value"}, + "param": 1, + }, + ), + ] + + def test_parameter_aliases(self): + self.wrapped_func_aliases(_source=["key1", "key2"]) + assert self.calls == [((), {"source": ["key1", "key2"]})] + + self.wrapped_func_aliases(source=["key3"]) + assert self.calls[-1] == ((), {"source": ["key3"]})