diff --git a/docs/sphinx/api.rst b/docs/sphinx/api.rst index e989557..77895da 100644 --- a/docs/sphinx/api.rst +++ b/docs/sphinx/api.rst @@ -30,36 +30,18 @@ Async Search .. autoclass:: AsyncSearchClient :members: -Autoscaling ------------ - -.. autoclass:: AutoscalingClient - :members: - Cat --- .. autoclass:: CatClient :members: -Cross-Cluster Replication (CCR) -------------------------------- - -.. autoclass:: CcrClient - :members: - Cluster ------- .. autoclass:: ClusterClient :members: -Dangling Indices ----------------- - -.. autoclass:: DanglingIndicesClient - :members: - Enrich Policies --------------- @@ -72,30 +54,12 @@ Event Query Language (EQL) .. autoclass:: EqlClient :members: -Snapshottable Features ----------------------- - -.. autoclass:: FeaturesClient - :members: - -Fleet ------ - -.. autoclass:: FleetClient - :members: - Graph Explore ------------- .. autoclass:: GraphClient :members: -Index Lifecycle Management (ILM) --------------------------------- - -.. autoclass:: IlmClient - :members: - Indices ------- @@ -120,12 +84,6 @@ Logstash .. autoclass:: LogstashClient :members: -Migration ---------- - -.. autoclass:: MigrationClient - :members: - Machine Learning (ML) --------------------- @@ -138,86 +96,26 @@ Monitoring .. autoclass:: MonitoringClient :members: -Nodes ------ - -.. autoclass:: NodesClient - :members: - -Rollup Indices --------------- - -.. autoclass:: RollupClient - :members: - -Searchable Snapshots --------------------- - -.. autoclass:: SearchableSnapshotsClient - :members: - Security -------- .. autoclass:: SecurityClient :members: -Shutdown --------- - -.. autoclass:: ShutdownClient - :members: - -Snapshot Lifecycle Management (SLM) ------------------------------------ - -.. autoclass:: SlmClient - :members: - -Snapshots ---------- - -.. autoclass:: SnapshotClient - :members: - SQL --- .. autoclass:: SqlClient :members: -TLS/SSL -------- - -.. autoclass:: SslClient - :members: - Tasks ----- .. autoclass:: TasksClient :members: -Text Structure --------------- - -.. autoclass:: TextStructureClient - :members: - Transforms ---------- .. autoclass:: TransformClient :members: - -Watcher -------- - -.. autoclass:: WatcherClient - :members: - -X-Pack ------- - -.. autoclass:: XPackClient - :members: diff --git a/elasticsearch_serverless/_async/client/__init__.py b/elasticsearch_serverless/_async/client/__init__.py index f592ec8..aec5b40 100644 --- a/elasticsearch_serverless/_async/client/__init__.py +++ b/elasticsearch_serverless/_async/client/__init__.py @@ -35,38 +35,22 @@ from ...serializer import DEFAULT_SERIALIZERS from ._base import BaseClient, resolve_auth_headers 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 .logstash import LogstashClient -from .migration import MigrationClient from .ml import MlClient -from .monitoring import MonitoringClient -from .nodes import NodesClient from .query_ruleset import QueryRulesetClient -from .rollup import RollupClient from .search_application import SearchApplicationClient -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 .synonyms import SynonymsClient from .tasks import TasksClient -from .text_structure import TextStructureClient from .transform import TransformClient from .utils import ( _TYPE_HOST, @@ -78,8 +62,6 @@ is_requests_http_auth, is_requests_node_class, ) -from .watcher import WatcherClient -from .xpack import XPackClient logger = logging.getLogger("elasticsearch") @@ -294,42 +276,24 @@ def __init__( # namespaced clients for compatibility with API names self.async_search = AsyncSearchClient(self) - self.autoscaling = AutoscalingClient(self) self.cat = CatClient(self) self.cluster = ClusterClient(self) - self.fleet = FleetClient(self) - self.features = FeaturesClient(self) self.indices = IndicesClient(self) self.ingest = IngestClient(self) - self.nodes = NodesClient(self) - self.snapshot = SnapshotClient(self) self.tasks = TasksClient(self) - self.xpack = XPackClient(self) - self.ccr = CcrClient(self) - self.dangling_indices = DanglingIndicesClient(self) self.enrich = EnrichClient(self) self.eql = EqlClient(self) self.graph = GraphClient(self) - self.ilm = IlmClient(self) self.license = LicenseClient(self) self.logstash = LogstashClient(self) - self.migration = MigrationClient(self) self.ml = MlClient(self) - self.monitoring = MonitoringClient(self) self.query_ruleset = QueryRulesetClient(self) - self.rollup = RollupClient(self) self.search_application = SearchApplicationClient(self) - self.searchable_snapshots = SearchableSnapshotsClient(self) self.security = SecurityClient(self) - self.slm = SlmClient(self) - self.shutdown = ShutdownClient(self) self.sql = SqlClient(self) - self.ssl = SslClient(self) self.synonyms = SynonymsClient(self) - self.text_structure = TextStructureClient(self) self.transform = TransformClient(self) - self.watcher = WatcherClient(self) def __repr__(self) -> str: try: diff --git a/elasticsearch_serverless/_async/client/autoscaling.py b/elasticsearch_serverless/_async/client/autoscaling.py deleted file mode 100644 index b45bc9c..0000000 --- a/elasticsearch_serverless/_async/client/autoscaling.py +++ /dev/null @@ -1,175 +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 typing as t - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters - - -class AutoscalingClient(NamespacedClient): - @_rewrite_parameters() - async def delete_autoscaling_policy( - self, - *, - name: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Deletes an autoscaling policy. Designed for indirect use by ECE/ESS and ECK. - Direct use is not supported. - - ``_ - - :param name: the name of the autoscaling policy - """ - if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'name'") - __path = f"/_autoscaling/policy/{_quote(name)}" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "DELETE", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - async def get_autoscaling_capacity( - self, - *, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Gets the current autoscaling capacity based on the configured autoscaling policy. - Designed for indirect use by ECE/ESS and ECK. Direct use is not supported. - - ``_ - """ - __path = "/_autoscaling/capacity" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - async def get_autoscaling_policy( - self, - *, - name: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Retrieves an autoscaling policy. Designed for indirect use by ECE/ESS and ECK. - Direct use is not supported. - - ``_ - - :param name: the name of the autoscaling policy - """ - if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'name'") - __path = f"/_autoscaling/policy/{_quote(name)}" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters( - body_name="policy", - ) - async def put_autoscaling_policy( - self, - *, - name: str, - policy: t.Mapping[str, t.Any], - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Creates a new autoscaling policy. Designed for indirect use by ECE/ESS and ECK. - Direct use is not supported. - - ``_ - - :param name: the name of the autoscaling policy - :param policy: - """ - 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: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path 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 - __headers = {"accept": "application/json", "content-type": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "PUT", __path, params=__query, headers=__headers, body=__body - ) diff --git a/elasticsearch_serverless/_async/client/ccr.py b/elasticsearch_serverless/_async/client/ccr.py deleted file mode 100644 index 01e7d3d..0000000 --- a/elasticsearch_serverless/_async/client/ccr.py +++ /dev/null @@ -1,749 +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 typing as t - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters - - -class CcrClient(NamespacedClient): - @_rewrite_parameters() - async def delete_auto_follow_pattern( - self, - *, - name: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Deletes auto-follow patterns. - - ``_ - - :param name: The name of the auto follow pattern. - """ - if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'name'") - __path = f"/_ccr/auto_follow/{_quote(name)}" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "DELETE", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters( - body_fields=True, - ) - async def follow( - self, - *, - index: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - leader_index: t.Optional[str] = None, - max_outstanding_read_requests: t.Optional[int] = None, - max_outstanding_write_requests: t.Optional[int] = None, - max_read_request_operation_count: t.Optional[int] = None, - max_read_request_size: t.Optional[str] = None, - max_retry_delay: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - max_write_buffer_count: t.Optional[int] = None, - max_write_buffer_size: t.Optional[str] = None, - max_write_request_operation_count: t.Optional[int] = None, - max_write_request_size: t.Optional[str] = None, - pretty: t.Optional[bool] = None, - read_poll_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - remote_cluster: t.Optional[str] = None, - wait_for_active_shards: t.Optional[ - t.Union[int, t.Union["t.Literal['all', 'index-setting']", str]] - ] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Creates a new follower index configured to follow the referenced leader index. - - ``_ - - :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) - """ - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'index'") - __path = f"/{_quote(index)}/_ccr/follow" - __query: t.Dict[str, t.Any] = {} - __body: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["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 - __headers = {"accept": "application/json", "content-type": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "PUT", __path, params=__query, headers=__headers, body=__body - ) - - @_rewrite_parameters() - async def follow_info( - self, - *, - index: t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]], - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Retrieves information about all follower indices, including parameters and status - for each follower index - - ``_ - - :param index: A comma-separated list of index patterns; use `_all` to perform - the operation on all indices - """ - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'index'") - __path = f"/{_quote(index)}/_ccr/info" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - async def follow_stats( - self, - *, - index: t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]], - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Retrieves follower stats. return shard-level stats about the following tasks - associated with each shard for the specified indices. - - ``_ - - :param index: A comma-separated list of index patterns; use `_all` to perform - the operation on all indices - """ - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'index'") - __path = f"/{_quote(index)}/_ccr/stats" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters( - body_fields=True, - ) - async def forget_follower( - self, - *, - index: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - follower_cluster: t.Optional[str] = None, - follower_index: t.Optional[str] = None, - follower_index_uuid: t.Optional[str] = None, - human: t.Optional[bool] = None, - leader_remote_cluster: t.Optional[str] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Removes the follower retention leases from the leader. - - ``_ - - :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: - """ - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'index'") - __path = f"/{_quote(index)}/_ccr/forget_follower" - __query: t.Dict[str, t.Any] = {} - __body: t.Dict[str, t.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 - __headers = {"accept": "application/json", "content-type": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers, body=__body - ) - - @_rewrite_parameters() - async def get_auto_follow_pattern( - self, - *, - name: t.Optional[str] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Gets configured auto-follow patterns. Returns the specified auto-follow pattern - collection. - - ``_ - - :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. - """ - if name not in SKIP_IN_PATH: - __path = f"/_ccr/auto_follow/{_quote(name)}" - else: - __path = "/_ccr/auto_follow" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - async def pause_auto_follow_pattern( - self, - *, - name: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Pauses an auto-follow pattern - - ``_ - - :param name: The name of the auto follow pattern that should pause discovering - new indices to follow. - """ - if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'name'") - __path = f"/_ccr/auto_follow/{_quote(name)}/pause" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - async def pause_follow( - self, - *, - index: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Pauses a follower index. The follower index will not fetch any additional operations - from the leader index. - - ``_ - - :param index: The name of the follower index that should pause following its - leader index. - """ - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'index'") - __path = f"/{_quote(index)}/_ccr/pause_follow" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters( - body_fields=True, - ) - async def put_auto_follow_pattern( - self, - *, - name: str, - remote_cluster: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - follow_index_pattern: t.Optional[str] = None, - human: t.Optional[bool] = None, - leader_index_exclusion_patterns: t.Optional[ - t.Union[t.List[str], t.Tuple[str, ...]] - ] = None, - leader_index_patterns: t.Optional[ - t.Union[t.List[str], t.Tuple[str, ...]] - ] = None, - max_outstanding_read_requests: t.Optional[int] = None, - max_outstanding_write_requests: t.Optional[int] = None, - max_read_request_operation_count: t.Optional[int] = None, - max_read_request_size: t.Optional[t.Union[int, str]] = None, - max_retry_delay: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - max_write_buffer_count: t.Optional[int] = None, - max_write_buffer_size: t.Optional[t.Union[int, str]] = None, - max_write_request_operation_count: t.Optional[int] = None, - max_write_request_size: t.Optional[t.Union[int, str]] = None, - pretty: t.Optional[bool] = None, - read_poll_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - settings: t.Optional[t.Mapping[str, t.Any]] = None, - ) -> ObjectApiResponse[t.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. - - ``_ - - :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). - """ - 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: t.Dict[str, t.Any] = {} - __query: t.Dict[str, t.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 - __headers = {"accept": "application/json", "content-type": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "PUT", __path, params=__query, headers=__headers, body=__body - ) - - @_rewrite_parameters() - async def resume_auto_follow_pattern( - self, - *, - name: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Resumes an auto-follow pattern that has been paused - - ``_ - - :param name: The name of the auto follow pattern to resume discovering new indices - to follow. - """ - if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'name'") - __path = f"/_ccr/auto_follow/{_quote(name)}/resume" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters( - body_fields=True, - ) - async def resume_follow( - self, - *, - index: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - max_outstanding_read_requests: t.Optional[int] = None, - max_outstanding_write_requests: t.Optional[int] = None, - max_read_request_operation_count: t.Optional[int] = None, - max_read_request_size: t.Optional[str] = None, - max_retry_delay: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - max_write_buffer_count: t.Optional[int] = None, - max_write_buffer_size: t.Optional[str] = None, - max_write_request_operation_count: t.Optional[int] = None, - max_write_request_size: t.Optional[str] = None, - pretty: t.Optional[bool] = None, - read_poll_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Resumes a follower index that has been paused - - ``_ - - :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: - """ - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'index'") - __path = f"/{_quote(index)}/_ccr/resume_follow" - __query: t.Dict[str, t.Any] = {} - __body: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["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] - __headers = {"accept": "application/json"} - if __body is not None: - __headers["content-type"] = "application/json" - return await self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers, body=__body - ) - - @_rewrite_parameters() - async def stats( - self, - *, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Gets all stats related to cross-cluster replication. - - ``_ - """ - __path = "/_ccr/stats" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - async def unfollow( - self, - *, - index: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Stops the following task associated with a follower index and removes index metadata - and settings associated with cross-cluster replication. - - ``_ - - :param index: The name of the follower index that should be turned into a regular - index. - """ - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'index'") - __path = f"/{_quote(index)}/_ccr/unfollow" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers - ) diff --git a/elasticsearch_serverless/_async/client/dangling_indices.py b/elasticsearch_serverless/_async/client/dangling_indices.py deleted file mode 100644 index 0b1f2c9..0000000 --- a/elasticsearch_serverless/_async/client/dangling_indices.py +++ /dev/null @@ -1,162 +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 typing as t - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters - - -class DanglingIndicesClient(NamespacedClient): - @_rewrite_parameters() - async def delete_dangling_index( - self, - *, - index_uuid: str, - accept_data_loss: bool, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - pretty: t.Optional[bool] = None, - timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Deletes the specified dangling index - - ``_ - - :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 - """ - if index_uuid in SKIP_IN_PATH: - 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: t.Dict[str, t.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 - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "DELETE", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - async def import_dangling_index( - self, - *, - index_uuid: str, - accept_data_loss: bool, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - pretty: t.Optional[bool] = None, - timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Imports the specified dangling index - - ``_ - - :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 - """ - if index_uuid in SKIP_IN_PATH: - 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: t.Dict[str, t.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 - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - async def list_dangling_indices( - self, - *, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Returns all dangling indices. - - ``_ - """ - __path = "/_dangling" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) diff --git a/elasticsearch_serverless/_async/client/features.py b/elasticsearch_serverless/_async/client/features.py deleted file mode 100644 index 5c19b7b..0000000 --- a/elasticsearch_serverless/_async/client/features.py +++ /dev/null @@ -1,88 +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 typing as t - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient -from .utils import _rewrite_parameters - - -class FeaturesClient(NamespacedClient): - @_rewrite_parameters() - async def get_features( - self, - *, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Gets a list of features which can be included in snapshots using the feature_states - field when creating a snapshot - - ``_ - """ - __path = "/_features" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - async def reset_features( - self, - *, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Resets the internal state of features, usually by deleting system indices - - ``_ - """ - __path = "/_features/_reset" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers - ) diff --git a/elasticsearch_serverless/_async/client/fleet.py b/elasticsearch_serverless/_async/client/fleet.py deleted file mode 100644 index e296a41..0000000 --- a/elasticsearch_serverless/_async/client/fleet.py +++ /dev/null @@ -1,631 +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 typing as t - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters - - -class FleetClient(NamespacedClient): - @_rewrite_parameters() - async def global_checkpoints( - self, - *, - index: str, - checkpoints: t.Optional[t.Union[t.List[int], t.Tuple[int, ...]]] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, - wait_for_advance: t.Optional[bool] = None, - wait_for_index: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Returns the current global checkpoints for an index. This API is design for internal - use by the fleet server project. - - ``_ - - :param index: A single index or index alias that resolves to a single index. - :param checkpoints: A comma separated list of previous global checkpoints. When - used in combination with `wait_for_advance`, the API will only return once - the global checkpoints advances past the checkpoints. Providing an empty - list will cause Elasticsearch to immediately return the current global checkpoints. - :param timeout: Period to wait for a global checkpoints to advance past `checkpoints`. - :param wait_for_advance: A boolean value which controls whether to wait (until - the timeout) for the global checkpoints to advance past the provided `checkpoints`. - :param wait_for_index: A boolean value which controls whether to wait (until - the timeout) for the target index to exist and all primary shards be active. - Can only be true when `wait_for_advance` is true. - """ - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'index'") - __path = f"/{_quote(index)}/_fleet/global_checkpoints" - __query: t.Dict[str, t.Any] = {} - if checkpoints is not None: - __query["checkpoints"] = checkpoints - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is 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_advance is not None: - __query["wait_for_advance"] = wait_for_advance - if wait_for_index is not None: - __query["wait_for_index"] = wait_for_index - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters( - body_name="searches", - ) - async def msearch( - self, - *, - searches: t.Union[ - t.List[t.Mapping[str, t.Any]], t.Tuple[t.Mapping[str, t.Any], ...] - ], - index: t.Optional[str] = None, - allow_no_indices: t.Optional[bool] = None, - allow_partial_search_results: t.Optional[bool] = None, - ccs_minimize_roundtrips: t.Optional[bool] = None, - error_trace: t.Optional[bool] = None, - expand_wildcards: t.Optional[ - t.Union[ - t.Union["t.Literal['all', 'closed', 'hidden', 'none', 'open']", str], - t.Union[ - t.List[ - t.Union[ - "t.Literal['all', 'closed', 'hidden', 'none', 'open']", str - ] - ], - t.Tuple[ - t.Union[ - "t.Literal['all', 'closed', 'hidden', 'none', 'open']", str - ], - ..., - ], - ], - ] - ] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - ignore_throttled: t.Optional[bool] = None, - ignore_unavailable: t.Optional[bool] = None, - max_concurrent_searches: t.Optional[int] = None, - max_concurrent_shard_requests: t.Optional[int] = None, - pre_filter_shard_size: t.Optional[int] = None, - pretty: t.Optional[bool] = None, - rest_total_hits_as_int: t.Optional[bool] = None, - search_type: t.Optional[ - t.Union["t.Literal['dfs_query_then_fetch', 'query_then_fetch']", str] - ] = None, - typed_keys: t.Optional[bool] = None, - wait_for_checkpoints: t.Optional[ - t.Union[t.List[int], t.Tuple[int, ...]] - ] = None, - ) -> ObjectApiResponse[t.Any]: - """ - 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. - - :param searches: - :param index: A single target to search. If the target is an index alias, it - must resolve to a single index. - :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 allow_partial_search_results: If true, returns partial results if there - are shard request timeouts or [shard failures](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-replication.html#shard-failures). - If false, returns an error with no partial results. Defaults to the configured - cluster setting `search.default_allow_partial_results` which is true by default. - :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. - :param wait_for_checkpoints: A comma separated list of checkpoints. When configured, - the search API will only be executed on a shard after the relevant checkpoint - has become visible for search. Defaults to an empty list which will cause - Elasticsearch to immediately execute the search. - """ - if searches is None: - raise ValueError("Empty value passed for parameter 'searches'") - if index not in SKIP_IN_PATH: - __path = f"/{_quote(index)}/_fleet/_fleet_msearch" - else: - __path = "/_fleet/_fleet_msearch" - __query: t.Dict[str, t.Any] = {} - 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 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 - if wait_for_checkpoints is not None: - __query["wait_for_checkpoints"] = wait_for_checkpoints - __body = searches - __headers = { - "accept": "application/json", - "content-type": "application/x-ndjson", - } - return await self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers, body=__body - ) - - @_rewrite_parameters( - body_fields=True, - parameter_aliases={ - "_source": "source", - "_source_excludes": "source_excludes", - "_source_includes": "source_includes", - "from": "from_", - }, - ) - async def search( - self, - *, - index: str, - aggregations: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None, - aggs: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None, - allow_no_indices: t.Optional[bool] = None, - allow_partial_search_results: t.Optional[bool] = None, - analyze_wildcard: t.Optional[bool] = None, - analyzer: t.Optional[str] = None, - batched_reduce_size: t.Optional[int] = None, - ccs_minimize_roundtrips: t.Optional[bool] = None, - collapse: t.Optional[t.Mapping[str, t.Any]] = None, - default_operator: t.Optional[t.Union["t.Literal['and', 'or']", str]] = None, - df: t.Optional[str] = None, - docvalue_fields: t.Optional[ - t.Union[t.List[t.Mapping[str, t.Any]], t.Tuple[t.Mapping[str, t.Any], ...]] - ] = None, - error_trace: t.Optional[bool] = None, - expand_wildcards: t.Optional[ - t.Union[ - t.Union["t.Literal['all', 'closed', 'hidden', 'none', 'open']", str], - t.Union[ - t.List[ - t.Union[ - "t.Literal['all', 'closed', 'hidden', 'none', 'open']", str - ] - ], - t.Tuple[ - t.Union[ - "t.Literal['all', 'closed', 'hidden', 'none', 'open']", str - ], - ..., - ], - ], - ] - ] = None, - explain: t.Optional[bool] = None, - ext: t.Optional[t.Mapping[str, t.Any]] = None, - fields: t.Optional[ - t.Union[t.List[t.Mapping[str, t.Any]], t.Tuple[t.Mapping[str, t.Any], ...]] - ] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - from_: t.Optional[int] = None, - highlight: t.Optional[t.Mapping[str, t.Any]] = None, - human: t.Optional[bool] = None, - ignore_throttled: t.Optional[bool] = None, - ignore_unavailable: t.Optional[bool] = None, - indices_boost: t.Optional[ - t.Union[t.List[t.Mapping[str, float]], t.Tuple[t.Mapping[str, float], ...]] - ] = None, - lenient: t.Optional[bool] = None, - max_concurrent_shard_requests: t.Optional[int] = None, - min_compatible_shard_node: t.Optional[str] = None, - min_score: t.Optional[float] = None, - pit: t.Optional[t.Mapping[str, t.Any]] = None, - post_filter: t.Optional[t.Mapping[str, t.Any]] = None, - pre_filter_shard_size: t.Optional[int] = None, - preference: t.Optional[str] = None, - pretty: t.Optional[bool] = None, - profile: t.Optional[bool] = None, - q: t.Optional[str] = None, - query: t.Optional[t.Mapping[str, t.Any]] = None, - request_cache: t.Optional[bool] = None, - rescore: t.Optional[ - t.Union[ - t.Mapping[str, t.Any], - t.Union[ - t.List[t.Mapping[str, t.Any]], t.Tuple[t.Mapping[str, t.Any], ...] - ], - ] - ] = None, - rest_total_hits_as_int: t.Optional[bool] = None, - routing: t.Optional[str] = None, - runtime_mappings: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None, - script_fields: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None, - scroll: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, - search_after: t.Optional[ - t.Union[ - t.List[t.Union[None, bool, float, int, str, t.Any]], - t.Tuple[t.Union[None, bool, float, int, str, t.Any], ...], - ] - ] = None, - search_type: t.Optional[ - t.Union["t.Literal['dfs_query_then_fetch', 'query_then_fetch']", str] - ] = None, - seq_no_primary_term: t.Optional[bool] = None, - size: t.Optional[int] = None, - slice: t.Optional[t.Mapping[str, t.Any]] = None, - sort: t.Optional[ - t.Union[ - t.Union[str, t.Mapping[str, t.Any]], - t.Union[ - t.List[t.Union[str, t.Mapping[str, t.Any]]], - t.Tuple[t.Union[str, t.Mapping[str, t.Any]], ...], - ], - ] - ] = None, - source: t.Optional[t.Union[bool, t.Mapping[str, t.Any]]] = None, - source_excludes: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - source_includes: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - stats: t.Optional[t.Union[t.List[str], t.Tuple[str, ...]]] = None, - stored_fields: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - suggest: t.Optional[t.Mapping[str, t.Any]] = None, - suggest_field: t.Optional[str] = None, - suggest_mode: t.Optional[ - t.Union["t.Literal['always', 'missing', 'popular']", str] - ] = None, - suggest_size: t.Optional[int] = None, - suggest_text: t.Optional[str] = None, - terminate_after: t.Optional[int] = None, - timeout: t.Optional[str] = None, - track_scores: t.Optional[bool] = None, - track_total_hits: t.Optional[t.Union[bool, int]] = None, - typed_keys: t.Optional[bool] = None, - version: t.Optional[bool] = None, - wait_for_checkpoints: t.Optional[ - t.Union[t.List[int], t.Tuple[int, ...]] - ] = None, - ) -> ObjectApiResponse[t.Any]: - """ - 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. - - :param index: A single target to search. If the target is an index alias, it - must resolve to a single index. - :param aggregations: - :param aggs: - :param allow_no_indices: - :param allow_partial_search_results: If true, returns partial results if there - are shard request timeouts or [shard failures](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-replication.html#shard-failures). - If false, returns an error with no partial results. Defaults to the configured - cluster setting `search.default_allow_partial_results` which is true by default. - :param analyze_wildcard: - :param analyzer: - :param batched_reduce_size: - :param ccs_minimize_roundtrips: - :param collapse: - :param default_operator: - :param df: - :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: - :param explain: If true, returns detailed information about score computation - as part of a hit. - :param ext: Configuration of search extensions defined by Elasticsearch plugins. - :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: - :param ignore_unavailable: - :param indices_boost: Boosts the _score of documents from specified indices. - :param lenient: - :param max_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: - :param profile: - :param q: - :param query: Defines the search definition using the Query DSL. - :param request_cache: - :param rescore: - :param rest_total_hits_as_int: - :param routing: - :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: - :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: - :param source_includes: - :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: - :param suggest_size: - :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: - :param version: If true, returns document version as part of a hit. - :param wait_for_checkpoints: A comma separated list of checkpoints. When configured, - the search API will only be executed on a shard after the relevant checkpoint - has become visible for search. Defaults to an empty list which will cause - Elasticsearch to immediately execute the search. - """ - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'index'") - __path = f"/{_quote(index)}/_fleet/_fleet_search" - __body: t.Dict[str, t.Any] = {} - __query: t.Dict[str, t.Any] = {} - # The 'sort' parameter with a colon can't be encoded to the body. - if sort is not None and ( - (isinstance(sort, str) and ":" in sort) - or ( - isinstance(sort, (list, tuple)) - and all(isinstance(_x, str) for _x in sort) - and any(":" in _x for _x in sort) - ) - ): - __query["sort"] = sort - sort = None - 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: - __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 ext is not None: - __body["ext"] = ext - 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 wait_for_checkpoints is not None: - __query["wait_for_checkpoints"] = wait_for_checkpoints - if not __body: - __body = None # type: ignore[assignment] - __headers = {"accept": "application/json"} - if __body is not None: - __headers["content-type"] = "application/json" - return await self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers, body=__body - ) diff --git a/elasticsearch_serverless/_async/client/ilm.py b/elasticsearch_serverless/_async/client/ilm.py deleted file mode 100644 index 83ffa2a..0000000 --- a/elasticsearch_serverless/_async/client/ilm.py +++ /dev/null @@ -1,543 +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 typing as t - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters - - -class IlmClient(NamespacedClient): - @_rewrite_parameters() - async def delete_lifecycle( - self, - *, - name: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - pretty: t.Optional[bool] = None, - timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Deletes the specified lifecycle policy definition. A currently used policy cannot - be deleted. - - ``_ - - :param name: Identifier for 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 timeout: Period to wait for a response. If no response is received before - the timeout expires, the request fails and returns an error. - """ - if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'name'") - __path = f"/_ilm/policy/{_quote(name)}" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["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 - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "DELETE", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - async def explain_lifecycle( - self, - *, - index: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - only_errors: t.Optional[bool] = None, - only_managed: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Retrieves information about the index's current lifecycle state, such as the - currently executing phase, action, and step. - - ``_ - - :param index: Comma-separated list of data streams, indices, and aliases to target. - Supports wildcards (`*`). To target all data streams and indices, use `*` - or `_all`. - :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 only_errors: Filters the returned indices to only indices that are managed - by ILM and are in an error state, either due to an encountering an error - while executing the policy, or attempting to use a policy that does not exist. - :param only_managed: Filters the returned indices to only indices that are managed - by ILM. - :param timeout: Period to wait for a response. If no response is received before - the timeout expires, the request fails and returns an error. - """ - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'index'") - __path = f"/{_quote(index)}/_ilm/explain" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["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 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 timeout is not None: - __query["timeout"] = timeout - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - async def get_lifecycle( - self, - *, - name: t.Optional[str] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - pretty: t.Optional[bool] = None, - timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Returns the specified policy definition. Includes the policy version and last - modified date. - - ``_ - - :param name: Identifier for 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 timeout: Period to wait for a response. 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"/_ilm/policy/{_quote(name)}" - else: - __path = "/_ilm/policy" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["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 - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - async def get_status( - self, - *, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Retrieves the current index lifecycle management (ILM) status. - - ``_ - """ - __path = "/_ilm/status" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters( - body_fields=True, - ) - async def migrate_to_data_tiers( - self, - *, - dry_run: t.Optional[bool] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - legacy_template_to_delete: t.Optional[str] = None, - node_attribute: t.Optional[str] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Migrates the indices and ILM policies away from custom node attribute allocation - routing to data tiers routing - - ``_ - - :param dry_run: If true, simulates the migration from node attributes based allocation - filters to data tiers, but does not perform the migration. This provides - a way to retrieve the indices and ILM policies that need to be migrated. - :param legacy_template_to_delete: - :param node_attribute: - """ - __path = "/_ilm/migrate_to_data_tiers" - __query: t.Dict[str, t.Any] = {} - __body: t.Dict[str, t.Any] = {} - 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 legacy_template_to_delete is not None: - __body["legacy_template_to_delete"] = legacy_template_to_delete - if node_attribute is not None: - __body["node_attribute"] = node_attribute - if pretty is not None: - __query["pretty"] = pretty - if not __body: - __body = None # type: ignore[assignment] - __headers = {"accept": "application/json"} - if __body is not None: - __headers["content-type"] = "application/json" - return await self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers, body=__body - ) - - @_rewrite_parameters( - body_fields=True, - ) - async def move_to_step( - self, - *, - index: str, - current_step: t.Optional[t.Mapping[str, t.Any]] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - next_step: t.Optional[t.Mapping[str, t.Any]] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Manually moves an index into the specified step and executes that step. - - ``_ - - :param index: The name of the index whose lifecycle step is to change - :param current_step: - :param next_step: - """ - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'index'") - __path = f"/_ilm/move/{_quote(index)}" - __body: t.Dict[str, t.Any] = {} - __query: t.Dict[str, t.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] - __headers = {"accept": "application/json"} - if __body is not None: - __headers["content-type"] = "application/json" - return await self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers, body=__body - ) - - @_rewrite_parameters( - body_fields=True, - ) - async def put_lifecycle( - self, - *, - name: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - policy: t.Optional[t.Mapping[str, t.Any]] = None, - pretty: t.Optional[bool] = None, - timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Creates a lifecycle policy - - ``_ - - :param name: Identifier for 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 policy: - :param timeout: Period to wait for a response. If no response is received before - the timeout expires, the request fails and returns an error. - """ - if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'name'") - __path = f"/_ilm/policy/{_quote(name)}" - __query: t.Dict[str, t.Any] = {} - __body: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["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 policy is not None: - __body["policy"] = policy - if pretty is not None: - __query["pretty"] = pretty - if timeout is not None: - __query["timeout"] = timeout - if not __body: - __body = None # type: ignore[assignment] - __headers = {"accept": "application/json"} - if __body is not None: - __headers["content-type"] = "application/json" - return await self.perform_request( # type: ignore[return-value] - "PUT", __path, params=__query, headers=__headers, body=__body - ) - - @_rewrite_parameters() - async def remove_policy( - self, - *, - index: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Removes the assigned lifecycle policy and stops managing the specified index - - ``_ - - :param index: The name of the index to remove policy on - """ - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'index'") - __path = f"/{_quote(index)}/_ilm/remove" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - async def retry( - self, - *, - index: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Retries executing the policy for an index that is in the ERROR step. - - ``_ - - :param index: The name of the indices (comma-separated) whose failed lifecycle - step is to be retry - """ - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'index'") - __path = f"/{_quote(index)}/_ilm/retry" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - async def start( - self, - *, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - pretty: t.Optional[bool] = None, - timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Start the index lifecycle management (ILM) plugin. - - ``_ - - :param master_timeout: - :param timeout: - """ - __path = "/_ilm/start" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["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 - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - async def stop( - self, - *, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - pretty: t.Optional[bool] = None, - timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Halts all lifecycle management operations and stops the index lifecycle management - (ILM) plugin - - ``_ - - :param master_timeout: - :param timeout: - """ - __path = "/_ilm/stop" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["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 - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers - ) diff --git a/elasticsearch_serverless/_async/client/migration.py b/elasticsearch_serverless/_async/client/migration.py deleted file mode 100644 index 8ba52c0..0000000 --- a/elasticsearch_serverless/_async/client/migration.py +++ /dev/null @@ -1,127 +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 typing as t - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters - - -class MigrationClient(NamespacedClient): - @_rewrite_parameters() - async def deprecations( - self, - *, - index: t.Optional[str] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.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. - - ``_ - - :param index: Comma-separate list of data streams or indices to check. Wildcard - (*) expressions are supported. - """ - if index not in SKIP_IN_PATH: - __path = f"/{_quote(index)}/_migration/deprecations" - else: - __path = "/_migration/deprecations" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - async def get_feature_upgrade_status( - self, - *, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Find out whether system features need to be upgraded or not - - ``_ - """ - __path = "/_migration/system_features" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - async def post_feature_upgrade( - self, - *, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Begin upgrades for system features - - ``_ - """ - __path = "/_migration/system_features" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers - ) diff --git a/elasticsearch_serverless/_async/client/monitoring.py b/elasticsearch_serverless/_async/client/monitoring.py deleted file mode 100644 index 75fe1bc..0000000 --- a/elasticsearch_serverless/_async/client/monitoring.py +++ /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. - -import typing as t - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient -from .utils import _rewrite_parameters - - -class MonitoringClient(NamespacedClient): - @_rewrite_parameters( - body_name="operations", - ) - async def bulk( - self, - *, - interval: t.Union["t.Literal[-1]", "t.Literal[0]", str], - operations: t.Union[ - t.List[t.Mapping[str, t.Any]], t.Tuple[t.Mapping[str, t.Any], ...] - ], - system_api_version: str, - system_id: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Used by the monitoring features to send monitoring data. - - ``_ - - :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 - """ - 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: t.Dict[str, t.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 - __headers = { - "accept": "application/json", - "content-type": "application/x-ndjson", - } - return await self.perform_request( # type: ignore[return-value] - "PUT", __path, params=__query, headers=__headers, body=__body - ) diff --git a/elasticsearch_serverless/_async/client/nodes.py b/elasticsearch_serverless/_async/client/nodes.py deleted file mode 100644 index 51f7cf7..0000000 --- a/elasticsearch_serverless/_async/client/nodes.py +++ /dev/null @@ -1,483 +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 typing as t - -from elastic_transport import ObjectApiResponse, TextApiResponse - -from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters - - -class NodesClient(NamespacedClient): - @_rewrite_parameters() - async def clear_repositories_metering_archive( - self, - *, - node_id: t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]], - max_archive_version: int, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Removes the archived repositories metering information present in the cluster. - - ``_ - - :param node_id: Comma-separated list of node IDs or names used to limit returned - information. All the nodes selective options are explained [here](https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster.html#cluster-nodes). - :param max_archive_version: Specifies the maximum [archive_version](https://www.elastic.co/guide/en/elasticsearch/reference/current/get-repositories-metering-api.html#get-repositories-metering-api-response-body) - to be cleared from the archive. - """ - if node_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'node_id'") - if max_archive_version in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'max_archive_version'") - __path = f"/_nodes/{_quote(node_id)}/_repositories_metering/{_quote(max_archive_version)}" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "DELETE", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - async def get_repositories_metering_info( - self, - *, - node_id: t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]], - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Returns cluster repositories metering information. - - ``_ - - :param node_id: Comma-separated list of node IDs or names used to limit returned - information. All the nodes selective options are explained [here](https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster.html#cluster-nodes). - """ - if node_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'node_id'") - __path = f"/_nodes/{_quote(node_id)}/_repositories_metering" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - async def hot_threads( - self, - *, - node_id: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - ignore_idle_threads: t.Optional[bool] = None, - interval: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - pretty: t.Optional[bool] = None, - snapshots: t.Optional[int] = None, - sort: t.Optional[ - t.Union["t.Literal['block', 'cpu', 'gpu', 'mem', 'wait']", str] - ] = None, - threads: t.Optional[int] = None, - timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, - type: t.Optional[ - t.Union["t.Literal['block', 'cpu', 'gpu', 'mem', 'wait']", str] - ] = None, - ) -> TextApiResponse: - """ - Returns information about hot threads on each node in the cluster. - - ``_ - - :param node_id: List of node IDs or names used to limit returned information. - :param ignore_idle_threads: If true, known idle threads (e.g. waiting in a socket - select, or to get a task from an empty queue) are filtered out. - :param interval: The interval to do the second sampling of threads. - :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 snapshots: Number of samples of thread stacktrace. - :param sort: The sort order for 'cpu' type (default: total) - :param threads: Specifies the number of hot threads to provide information for. - :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 type: The type to sample. - """ - if node_id not in SKIP_IN_PATH: - __path = f"/_nodes/{_quote(node_id)}/hot_threads" - else: - __path = "/_nodes/hot_threads" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["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 master_timeout is not None: - __query["master_timeout"] = master_timeout - if pretty is not None: - __query["pretty"] = pretty - if snapshots is not None: - __query["snapshots"] = snapshots - if sort is not None: - __query["sort"] = sort - if threads is not None: - __query["threads"] = threads - if timeout is not None: - __query["timeout"] = timeout - if type is not None: - __query["type"] = type - __headers = {"accept": "text/plain"} - return await self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - async def info( - self, - *, - node_id: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - metric: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - flat_settings: t.Optional[bool] = None, - human: t.Optional[bool] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - pretty: t.Optional[bool] = None, - timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Returns information about nodes in the cluster. - - ``_ - - :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. - """ - 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: t.Dict[str, t.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 - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters( - body_fields=True, - ) - async def reload_secure_settings( - self, - *, - node_id: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - secure_settings_password: t.Optional[str] = None, - timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Reloads secure settings. - - ``_ - - :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 - """ - if node_id not in SKIP_IN_PATH: - __path = f"/_nodes/{_quote(node_id)}/reload_secure_settings" - else: - __path = "/_nodes/reload_secure_settings" - __query: t.Dict[str, t.Any] = {} - __body: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is 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] - __headers = {"accept": "application/json"} - if __body is not None: - __headers["content-type"] = "application/json" - return await self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers, body=__body - ) - - @_rewrite_parameters() - async def stats( - self, - *, - node_id: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - metric: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - index_metric: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - completion_fields: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - error_trace: t.Optional[bool] = None, - fielddata_fields: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - fields: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - groups: t.Optional[bool] = None, - human: t.Optional[bool] = None, - include_segment_file_sizes: t.Optional[bool] = None, - include_unloaded_segments: t.Optional[bool] = None, - level: t.Optional[ - t.Union["t.Literal['cluster', 'indices', 'shards']", str] - ] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - pretty: t.Optional[bool] = None, - timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, - types: t.Optional[t.Union[t.List[str], t.Tuple[str, ...]]] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Returns statistical information about nodes in the cluster. - - ``_ - - :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. - """ - 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: t.Dict[str, t.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 - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - async def usage( - self, - *, - node_id: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - metric: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Returns low-level information about REST actions usage on nodes. - - ``_ - - :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 - """ - 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: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is 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 - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) diff --git a/elasticsearch_serverless/_async/client/rollup.py b/elasticsearch_serverless/_async/client/rollup.py deleted file mode 100644 index 9a314db..0000000 --- a/elasticsearch_serverless/_async/client/rollup.py +++ /dev/null @@ -1,440 +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 typing as t - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters - - -class RollupClient(NamespacedClient): - @_rewrite_parameters() - async def delete_job( - self, - *, - id: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Deletes an existing rollup job. - - ``_ - - :param id: The ID of the job to delete - """ - if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'id'") - __path = f"/_rollup/job/{_quote(id)}" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "DELETE", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - async def get_jobs( - self, - *, - id: t.Optional[str] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Retrieves the configuration, stats, and status of rollup jobs. - - ``_ - - :param id: The ID of the job(s) to fetch. Accepts glob patterns, or left blank - for all jobs - """ - if id not in SKIP_IN_PATH: - __path = f"/_rollup/job/{_quote(id)}" - else: - __path = "/_rollup/job" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - async def get_rollup_caps( - self, - *, - id: t.Optional[str] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Returns the capabilities of any rollup jobs that have been configured for a specific - index or index pattern. - - ``_ - - :param id: The ID of the index to check rollup capabilities on, or left blank - for all jobs - """ - if id not in SKIP_IN_PATH: - __path = f"/_rollup/data/{_quote(id)}" - else: - __path = "/_rollup/data" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - async def get_rollup_index_caps( - self, - *, - index: t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]], - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Returns the rollup capabilities of all jobs inside of a rollup index (e.g. the - index where rollup data is stored). - - ``_ - - :param index: The rollup index or index pattern to obtain rollup capabilities - from. - """ - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'index'") - __path = f"/{_quote(index)}/_rollup/data" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters( - body_fields=True, - ignore_deprecated_options={"headers"}, - ) - async def put_job( - self, - *, - id: str, - cron: str, - groups: t.Mapping[str, t.Any], - index_pattern: str, - page_size: int, - rollup_index: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - headers: t.Optional[ - t.Mapping[str, t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]]] - ] = None, - human: t.Optional[bool] = None, - metrics: t.Optional[ - t.Union[t.List[t.Mapping[str, t.Any]], t.Tuple[t.Mapping[str, t.Any], ...]] - ] = None, - pretty: t.Optional[bool] = None, - timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Creates a rollup job. - - ``_ - - :param id: Identifier for the rollup job. This can be any alphanumeric string - and uniquely identifies the data that is associated with the rollup job. - The ID is persistent; it is stored with the rolled up data. If you create - a job, let it run for a while, then delete the job, the data that the job - rolled up is still be associated with this job ID. You cannot create a new - job with the same ID since that could lead to problems with mismatched job - configurations. - :param cron: A cron string which defines the intervals when the rollup job should - be executed. When the interval triggers, the indexer attempts to rollup the - data in the index pattern. The cron pattern is unrelated to the time interval - of the data being rolled up. For example, you may wish to create hourly rollups - of your document but to only run the indexer on a daily basis at midnight, - as defined by the cron. The cron pattern is defined just like a Watcher cron - schedule. - :param groups: Defines the grouping fields and aggregations that are defined - for this rollup job. These fields will then be available later for aggregating - into buckets. These aggs and fields can be used in any combination. Think - of the groups configuration as defining a set of tools that can later be - used in aggregations to partition the data. Unlike raw data, we have to think - ahead to which fields and aggregations might be used. Rollups provide enough - flexibility that you simply need to determine which fields are needed, not - in what order they are needed. - :param index_pattern: The index or index pattern to roll up. Supports wildcard-style - patterns (`logstash-*`). The job attempts to rollup the entire index or index-pattern. - :param page_size: The number of bucket results that are processed on each iteration - of the rollup indexer. A larger value tends to execute faster, but requires - more memory during processing. This value has no effect on how the data is - rolled up; it is merely used for tweaking the speed or memory cost of the - indexer. - :param rollup_index: The index that contains the rollup results. The index can - be shared with other rollup jobs. The data is stored so that it doesn’t interfere - with unrelated jobs. - :param headers: - :param metrics: Defines the metrics to collect for each grouping tuple. By default, - only the doc_counts are collected for each group. To make rollup useful, - you will often add metrics like averages, mins, maxes, etc. Metrics are defined - on a per-field basis and for each field you configure which metric should - be collected. - :param timeout: Time to wait for the request to complete. - """ - if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'id'") - if cron is None: - raise ValueError("Empty value passed for parameter 'cron'") - if groups is None: - raise ValueError("Empty value passed for parameter 'groups'") - if index_pattern is None: - raise ValueError("Empty value passed for parameter 'index_pattern'") - if page_size is None: - raise ValueError("Empty value passed for parameter 'page_size'") - if rollup_index is None: - raise ValueError("Empty value passed for parameter 'rollup_index'") - __path = f"/_rollup/job/{_quote(id)}" - __body: t.Dict[str, t.Any] = {} - __query: t.Dict[str, t.Any] = {} - if cron is not None: - __body["cron"] = cron - if groups is not None: - __body["groups"] = groups - if index_pattern is not None: - __body["index_pattern"] = index_pattern - if page_size is not None: - __body["page_size"] = page_size - if rollup_index is not None: - __body["rollup_index"] = rollup_index - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if headers is not None: - __body["headers"] = headers - if human is not None: - __query["human"] = human - if metrics is not None: - __body["metrics"] = metrics - if pretty is not None: - __query["pretty"] = pretty - if timeout is not None: - __body["timeout"] = timeout - __headers = {"accept": "application/json", "content-type": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "PUT", __path, params=__query, headers=__headers, body=__body - ) - - @_rewrite_parameters( - body_fields=True, - ) - async def rollup_search( - self, - *, - index: t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]], - aggregations: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None, - aggs: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - query: t.Optional[t.Mapping[str, t.Any]] = None, - rest_total_hits_as_int: t.Optional[bool] = None, - size: t.Optional[int] = None, - typed_keys: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Enables searching rolled-up data using the standard query DSL. - - ``_ - - :param index: The indices or index-pattern(s) (containing rollup or regular data) - that should be searched - :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 - :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 - """ - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'index'") - __path = f"/{_quote(index)}/_rollup_search" - __body: t.Dict[str, t.Any] = {} - __query: t.Dict[str, t.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: - __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 - __headers = {"accept": "application/json", "content-type": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers, body=__body - ) - - @_rewrite_parameters() - async def start_job( - self, - *, - id: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Starts an existing, stopped rollup job. - - ``_ - - :param id: The ID of the job to start - """ - if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'id'") - __path = f"/_rollup/job/{_quote(id)}/_start" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - async def stop_job( - self, - *, - id: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, - wait_for_completion: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Stops an existing, started rollup job. - - ``_ - - :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. - """ - if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'id'") - __path = f"/_rollup/job/{_quote(id)}/_stop" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is 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 - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers - ) diff --git a/elasticsearch_serverless/_async/client/searchable_snapshots.py b/elasticsearch_serverless/_async/client/searchable_snapshots.py deleted file mode 100644 index e8ba046..0000000 --- a/elasticsearch_serverless/_async/client/searchable_snapshots.py +++ /dev/null @@ -1,265 +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 typing as t - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters - - -class SearchableSnapshotsClient(NamespacedClient): - @_rewrite_parameters() - async def cache_stats( - self, - *, - node_id: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Retrieve node-level cache statistics about searchable snapshots. - - ``_ - - :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 master_timeout: - """ - if node_id not in SKIP_IN_PATH: - __path = f"/_searchable_snapshots/{_quote(node_id)}/cache/stats" - else: - __path = "/_searchable_snapshots/cache/stats" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["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 - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - async def clear_cache( - self, - *, - index: t.Optional[t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]]] = None, - allow_no_indices: t.Optional[bool] = None, - error_trace: t.Optional[bool] = None, - expand_wildcards: t.Optional[ - t.Union[ - t.Union["t.Literal['all', 'closed', 'hidden', 'none', 'open']", str], - t.Union[ - t.List[ - t.Union[ - "t.Literal['all', 'closed', 'hidden', 'none', 'open']", str - ] - ], - t.Tuple[ - t.Union[ - "t.Literal['all', 'closed', 'hidden', 'none', 'open']", str - ], - ..., - ], - ], - ] - ] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - ignore_unavailable: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Clear the cache of searchable snapshots. - - ``_ - - :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) - """ - if index not in SKIP_IN_PATH: - __path = f"/{_quote(index)}/_searchable_snapshots/cache/clear" - else: - __path = "/_searchable_snapshots/cache/clear" - __query: t.Dict[str, t.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 - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters( - body_fields=True, - ) - async def mount( - self, - *, - repository: str, - snapshot: str, - index: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - ignore_index_settings: t.Optional[ - t.Union[t.List[str], t.Tuple[str, ...]] - ] = None, - index_settings: t.Optional[t.Mapping[str, t.Any]] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - pretty: t.Optional[bool] = None, - renamed_index: t.Optional[str] = None, - storage: t.Optional[str] = None, - wait_for_completion: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Mount a snapshot as a searchable index. - - ``_ - - :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 - """ - 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: t.Dict[str, t.Any] = {} - __query: t.Dict[str, t.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 - __headers = {"accept": "application/json", "content-type": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers, body=__body - ) - - @_rewrite_parameters() - async def stats( - self, - *, - index: t.Optional[t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]]] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - level: t.Optional[ - t.Union["t.Literal['cluster', 'indices', 'shards']", str] - ] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Retrieve shard-level statistics about searchable snapshots. - - ``_ - - :param index: A comma-separated list of index names - :param level: Return stats aggregated at cluster, index or shard level - """ - if index not in SKIP_IN_PATH: - __path = f"/{_quote(index)}/_searchable_snapshots/stats" - else: - __path = "/_searchable_snapshots/stats" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["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 - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) diff --git a/elasticsearch_serverless/_async/client/shutdown.py b/elasticsearch_serverless/_async/client/shutdown.py deleted file mode 100644 index a19cdc3..0000000 --- a/elasticsearch_serverless/_async/client/shutdown.py +++ /dev/null @@ -1,229 +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 typing as t - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters - - -class ShutdownClient(NamespacedClient): - @_rewrite_parameters() - async def delete_node( - self, - *, - node_id: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - master_timeout: t.Optional[ - t.Union["t.Literal['d', 'h', 'm', 'micros', 'ms', 'nanos', 's']", str] - ] = None, - pretty: t.Optional[bool] = None, - timeout: t.Optional[ - t.Union["t.Literal['d', 'h', 'm', 'micros', 'ms', 'nanos', 's']", str] - ] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Removes a node from the shutdown list. Designed for indirect use by ECE/ESS and - ECK. Direct use is not supported. - - ``_ - - :param node_id: The node id of node to be removed from the shutdown state - :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. - """ - if node_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'node_id'") - __path = f"/_nodes/{_quote(node_id)}/shutdown" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["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 - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "DELETE", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - async def get_node( - self, - *, - node_id: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - master_timeout: t.Optional[ - t.Union["t.Literal['d', 'h', 'm', 'micros', 'ms', 'nanos', 's']", str] - ] = None, - pretty: t.Optional[bool] = None, - timeout: t.Optional[ - t.Union["t.Literal['d', 'h', 'm', 'micros', 'ms', 'nanos', 's']", str] - ] = None, - ) -> ObjectApiResponse[t.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. - - ``_ - - :param node_id: Which node for which to retrieve the shutdown status - :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. - """ - if node_id not in SKIP_IN_PATH: - __path = f"/_nodes/{_quote(node_id)}/shutdown" - else: - __path = "/_nodes/shutdown" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["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 - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters( - body_fields=True, - ) - async def put_node( - self, - *, - node_id: str, - reason: str, - type: t.Union["t.Literal['remove', 'replace', 'restart']", str], - allocation_delay: t.Optional[str] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - master_timeout: t.Optional[ - t.Union["t.Literal['d', 'h', 'm', 'micros', 'ms', 'nanos', 's']", str] - ] = None, - pretty: t.Optional[bool] = None, - target_node_name: t.Optional[str] = None, - timeout: t.Optional[ - t.Union["t.Literal['d', 'h', 'm', 'micros', 'ms', 'nanos', 's']", str] - ] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Adds a node to be shut down. Designed for indirect use by ECE/ESS and ECK. Direct - use is not supported. - - ``_ - - :param node_id: The node id of node to be shut down - :param reason: A human-readable reason that the node is being shut down. This - field provides information for other cluster operators; it does not affect - the shut down process. - :param type: Valid values are restart, remove, or replace. Use restart when you - need to temporarily shut down a node to perform an upgrade, make configuration - changes, or perform other maintenance. Because the node is expected to rejoin - the cluster, data is not migrated off of the node. Use remove when you need - to permanently remove a node from the cluster. The node is not marked ready - for shutdown until data is migrated off of the node Use replace to do a 1:1 - replacement of a node with another node. Certain allocation decisions will - be ignored (such as disk watermarks) in the interest of true replacement - of the source node with the target node. During a replace-type shutdown, - rollover and index creation may result in unassigned shards, and shrink may - fail until the replacement is complete. - :param allocation_delay: Only valid if type is restart. Controls how long Elasticsearch - will wait for the node to restart and join the cluster before reassigning - its shards to other nodes. This works the same as delaying allocation with - the index.unassigned.node_left.delayed_timeout setting. If you specify both - a restart allocation delay and an index-level allocation delay, the longer - of the two is used. - :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 target_node_name: Only valid if type is replace. Specifies the name of - the node that is replacing the node being shut down. Shards from the shut - down node are only allowed to be allocated to the target node, and no other - data will be allocated to the target node. During relocation of data certain - allocation rules are ignored, such as disk watermarks or user attribute filtering - rules. - :param timeout: Period to wait for a response. If no response is received before - the timeout expires, the request fails and returns an error. - """ - if node_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'node_id'") - if reason is None: - raise ValueError("Empty value passed for parameter 'reason'") - if type is None: - raise ValueError("Empty value passed for parameter 'type'") - __path = f"/_nodes/{_quote(node_id)}/shutdown" - __body: t.Dict[str, t.Any] = {} - __query: t.Dict[str, t.Any] = {} - if reason is not None: - __body["reason"] = reason - if type is not None: - __body["type"] = type - if allocation_delay is not None: - __body["allocation_delay"] = allocation_delay - if error_trace is not None: - __query["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 target_node_name is not None: - __body["target_node_name"] = target_node_name - if timeout is not None: - __query["timeout"] = timeout - __headers = {"accept": "application/json", "content-type": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "PUT", __path, params=__query, headers=__headers, body=__body - ) diff --git a/elasticsearch_serverless/_async/client/slm.py b/elasticsearch_serverless/_async/client/slm.py deleted file mode 100644 index 35b0c16..0000000 --- a/elasticsearch_serverless/_async/client/slm.py +++ /dev/null @@ -1,377 +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 typing as t - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters - - -class SlmClient(NamespacedClient): - @_rewrite_parameters() - async def delete_lifecycle( - self, - *, - policy_id: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Deletes an existing snapshot lifecycle policy. - - ``_ - - :param policy_id: The id of the snapshot lifecycle policy to remove - """ - if policy_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'policy_id'") - __path = f"/_slm/policy/{_quote(policy_id)}" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "DELETE", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - async def execute_lifecycle( - self, - *, - policy_id: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Immediately creates a snapshot according to the lifecycle policy, without waiting - for the scheduled time. - - ``_ - - :param policy_id: The id of the snapshot lifecycle policy to be executed - """ - if policy_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'policy_id'") - __path = f"/_slm/policy/{_quote(policy_id)}/_execute" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "PUT", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - async def execute_retention( - self, - *, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Deletes any snapshots that are expired according to the policy's retention rules. - - ``_ - """ - __path = "/_slm/_execute_retention" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - async def get_lifecycle( - self, - *, - policy_id: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Retrieves one or more snapshot lifecycle policy definitions and information about - the latest snapshot attempts. - - ``_ - - :param policy_id: Comma-separated list of snapshot lifecycle policies to retrieve - """ - if policy_id not in SKIP_IN_PATH: - __path = f"/_slm/policy/{_quote(policy_id)}" - else: - __path = "/_slm/policy" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - async def get_stats( - self, - *, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Returns global and policy-level statistics about actions taken by snapshot lifecycle - management. - - ``_ - """ - __path = "/_slm/stats" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - async def get_status( - self, - *, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Retrieves the status of snapshot lifecycle management (SLM). - - ``_ - """ - __path = "/_slm/status" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters( - body_fields=True, - ) - async def put_lifecycle( - self, - *, - policy_id: str, - config: t.Optional[t.Mapping[str, t.Any]] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - name: t.Optional[str] = None, - pretty: t.Optional[bool] = None, - repository: t.Optional[str] = None, - retention: t.Optional[t.Mapping[str, t.Any]] = None, - schedule: t.Optional[str] = None, - timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, - ) -> ObjectApiResponse[t.Any]: - """ - 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. - """ - if policy_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'policy_id'") - __path = f"/_slm/policy/{_quote(policy_id)}" - __body: t.Dict[str, t.Any] = {} - __query: t.Dict[str, t.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] - __headers = {"accept": "application/json"} - if __body is not None: - __headers["content-type"] = "application/json" - return await self.perform_request( # type: ignore[return-value] - "PUT", __path, params=__query, headers=__headers, body=__body - ) - - @_rewrite_parameters() - async def start( - self, - *, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Turns on snapshot lifecycle management (SLM). - - ``_ - """ - __path = "/_slm/start" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - async def stop( - self, - *, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Turns off snapshot lifecycle management (SLM). - - ``_ - """ - __path = "/_slm/stop" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers - ) diff --git a/elasticsearch_serverless/_async/client/snapshot.py b/elasticsearch_serverless/_async/client/snapshot.py deleted file mode 100644 index 9bcf81f..0000000 --- a/elasticsearch_serverless/_async/client/snapshot.py +++ /dev/null @@ -1,773 +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 typing as t - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters - - -class SnapshotClient(NamespacedClient): - @_rewrite_parameters() - async def cleanup_repository( - self, - *, - name: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - pretty: t.Optional[bool] = None, - timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Removes stale data from repository. - - ``_ - - :param name: Snapshot repository to clean up. - :param master_timeout: Period to wait for a connection to the master node. - :param timeout: Period to wait for a response. - """ - if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'name'") - __path = f"/_snapshot/{_quote(name)}/_cleanup" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["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 - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters( - body_fields=True, - ) - async def clone( - self, - *, - repository: str, - snapshot: str, - target_snapshot: str, - indices: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - pretty: t.Optional[bool] = None, - timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Clones indices from one snapshot into another snapshot in the same repository. - - ``_ - - :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: - """ - 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: t.Dict[str, t.Any] = {} - __query: t.Dict[str, t.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 - __headers = {"accept": "application/json", "content-type": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "PUT", __path, params=__query, headers=__headers, body=__body - ) - - @_rewrite_parameters( - body_fields=True, - ) - async def create( - self, - *, - repository: str, - snapshot: str, - error_trace: t.Optional[bool] = None, - feature_states: t.Optional[t.Union[t.List[str], t.Tuple[str, ...]]] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - ignore_unavailable: t.Optional[bool] = None, - include_global_state: t.Optional[bool] = None, - indices: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - metadata: t.Optional[t.Mapping[str, t.Any]] = None, - partial: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - wait_for_completion: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Creates a snapshot in a repository. - - ``_ - - :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. - """ - 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: t.Dict[str, t.Any] = {} - __body: t.Dict[str, t.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] - __headers = {"accept": "application/json"} - if __body is not None: - __headers["content-type"] = "application/json" - return await self.perform_request( # type: ignore[return-value] - "PUT", __path, params=__query, headers=__headers, body=__body - ) - - @_rewrite_parameters( - body_fields=True, - ) - async def create_repository( - self, - *, - name: str, - settings: t.Mapping[str, t.Any], - type: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - pretty: t.Optional[bool] = None, - repository: t.Optional[t.Mapping[str, t.Any]] = None, - timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, - verify: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Creates a repository. - - ``_ - - :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 - """ - 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: t.Dict[str, t.Any] = {} - __query: t.Dict[str, t.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 - __headers = {"accept": "application/json", "content-type": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "PUT", __path, params=__query, headers=__headers, body=__body - ) - - @_rewrite_parameters() - async def delete( - self, - *, - repository: str, - snapshot: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Deletes one or more snapshots. - - ``_ - - :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 - """ - 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: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["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 - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "DELETE", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - async def delete_repository( - self, - *, - name: t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]], - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - pretty: t.Optional[bool] = None, - timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Deletes a repository. - - ``_ - - :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 - """ - if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'name'") - __path = f"/_snapshot/{_quote(name)}" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["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 - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "DELETE", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - async def get( - self, - *, - repository: str, - snapshot: t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]], - after: t.Optional[str] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - from_sort_value: t.Optional[str] = None, - human: t.Optional[bool] = None, - ignore_unavailable: t.Optional[bool] = None, - include_repository: t.Optional[bool] = None, - index_details: t.Optional[bool] = None, - index_names: t.Optional[bool] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - offset: t.Optional[int] = None, - order: t.Optional[t.Union["t.Literal['asc', 'desc']", str]] = None, - pretty: t.Optional[bool] = None, - size: t.Optional[int] = None, - slm_policy_filter: t.Optional[str] = None, - sort: t.Optional[ - t.Union[ - "t.Literal['duration', 'failed_shard_count', 'index_count', 'name', 'repository', 'shard_count', 'start_time']", - str, - ] - ] = None, - verbose: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Returns information about a snapshot. - - ``_ - - :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 after: Offset identifier to start pagination from as returned by the next - field in the response body. - :param from_sort_value: Value of the current sort column at which to start retrieval. - Can either be a string snapshot- or repository name when sorting by snapshot - or repository name, a millisecond time value or a number when sorting by - index- or shard count. - :param ignore_unavailable: If false, the request returns an error for any snapshots - that are unavailable. - :param include_repository: If true, returns the repository name in each snapshot. - :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 index_names: If true, returns the name of each index in each snapshot. - :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 offset: Numeric offset to start pagination from based on the snapshots - matching this request. Using a non-zero value for this parameter is mutually - exclusive with using the after parameter. Defaults to 0. - :param order: Sort order. Valid values are asc for ascending and desc for descending - order. Defaults to asc, meaning ascending order. - :param size: Maximum number of snapshots to return. Defaults to 0 which means - return all that match the request without limit. - :param slm_policy_filter: Filter snapshots by a comma-separated list of SLM policy - names that snapshots belong to. Also accepts wildcards (*) and combinations - of wildcards followed by exclude patterns starting with -. To include snapshots - not created by an SLM policy you can use the special pattern _none that will - match all snapshots without an SLM policy. - :param sort: Allows setting a sort order for the result. Defaults to start_time, - i.e. sorting by snapshot start time stamp. - :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. - """ - 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: t.Dict[str, t.Any] = {} - if after is not None: - __query["after"] = after - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if from_sort_value is not None: - __query["from_sort_value"] = from_sort_value - 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 index_names is not None: - __query["index_names"] = index_names - if master_timeout is not None: - __query["master_timeout"] = master_timeout - if offset is not None: - __query["offset"] = offset - if order is not None: - __query["order"] = order - if pretty is not None: - __query["pretty"] = pretty - if size is not None: - __query["size"] = size - if slm_policy_filter is not None: - __query["slm_policy_filter"] = slm_policy_filter - if sort is not None: - __query["sort"] = sort - if verbose is not None: - __query["verbose"] = verbose - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - async def get_repository( - self, - *, - name: t.Optional[t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]]] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - local: t.Optional[bool] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Returns information about a repository. - - ``_ - - :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 - """ - if name not in SKIP_IN_PATH: - __path = f"/_snapshot/{_quote(name)}" - else: - __path = "/_snapshot" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["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 - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters( - body_fields=True, - ) - async def restore( - self, - *, - repository: str, - snapshot: str, - error_trace: t.Optional[bool] = None, - feature_states: t.Optional[t.Union[t.List[str], t.Tuple[str, ...]]] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - ignore_index_settings: t.Optional[ - t.Union[t.List[str], t.Tuple[str, ...]] - ] = None, - ignore_unavailable: t.Optional[bool] = None, - include_aliases: t.Optional[bool] = None, - include_global_state: t.Optional[bool] = None, - index_settings: t.Optional[t.Mapping[str, t.Any]] = None, - indices: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - partial: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - rename_pattern: t.Optional[str] = None, - rename_replacement: t.Optional[str] = None, - wait_for_completion: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Restores a snapshot. - - ``_ - - :param repository: A repository name - :param snapshot: A snapshot name - :param feature_states: - :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 - """ - 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)}/_restore" - __query: t.Dict[str, t.Any] = {} - __body: t.Dict[str, t.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_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] - __headers = {"accept": "application/json"} - if __body is not None: - __headers["content-type"] = "application/json" - return await self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers, body=__body - ) - - @_rewrite_parameters() - async def status( - self, - *, - repository: t.Optional[str] = None, - snapshot: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - ignore_unavailable: t.Optional[bool] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Returns information about the status of a snapshot. - - ``_ - - :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 - """ - 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: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["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 - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - async def verify_repository( - self, - *, - name: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - pretty: t.Optional[bool] = None, - timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Verifies a repository. - - ``_ - - :param name: A repository name - :param master_timeout: Explicit operation timeout for connection to master node - :param timeout: Explicit operation timeout - """ - if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'name'") - __path = f"/_snapshot/{_quote(name)}/_verify" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["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 - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers - ) diff --git a/elasticsearch_serverless/_async/client/ssl.py b/elasticsearch_serverless/_async/client/ssl.py deleted file mode 100644 index 4205dee..0000000 --- a/elasticsearch_serverless/_async/client/ssl.py +++ /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. - -import typing as t - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient -from .utils import _rewrite_parameters - - -class SslClient(NamespacedClient): - @_rewrite_parameters() - async def certificates( - self, - *, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Retrieves information about the X.509 certificates used to encrypt communications - in the cluster. - - ``_ - """ - __path = "/_ssl/certificates" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) diff --git a/elasticsearch_serverless/_async/client/text_structure.py b/elasticsearch_serverless/_async/client/text_structure.py deleted file mode 100644 index 107ad05..0000000 --- a/elasticsearch_serverless/_async/client/text_structure.py +++ /dev/null @@ -1,158 +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 typing as t - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient -from .utils import _rewrite_parameters - - -class TextStructureClient(NamespacedClient): - @_rewrite_parameters( - body_name="text_files", - ) - async def find_structure( - self, - *, - text_files: t.Union[t.List[t.Any], t.Tuple[t.Any, ...]], - charset: t.Optional[str] = None, - column_names: t.Optional[str] = None, - delimiter: t.Optional[str] = None, - explain: t.Optional[bool] = None, - format: t.Optional[str] = None, - grok_pattern: t.Optional[str] = None, - has_header_row: t.Optional[bool] = None, - line_merge_size_limit: t.Optional[int] = None, - lines_to_sample: t.Optional[int] = None, - quote: t.Optional[str] = None, - should_trim_fields: t.Optional[bool] = None, - timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, - timestamp_field: t.Optional[str] = None, - timestamp_format: t.Optional[str] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Finds the structure of a text file. The text file must contain data that is suitable - to be ingested into Elasticsearch. - - ``_ - - :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 - :param timestamp_format: The Java time format of the timestamp field in the text. - """ - if text_files is None: - raise ValueError("Empty value passed for parameter 'text_files'") - __path = "/_text_structure/find_structure" - __query: t.Dict[str, t.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 - __headers = { - "accept": "application/json", - "content-type": "application/x-ndjson", - } - return await self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers, body=__body - ) diff --git a/elasticsearch_serverless/_async/client/watcher.py b/elasticsearch_serverless/_async/client/watcher.py deleted file mode 100644 index 7c63f5f..0000000 --- a/elasticsearch_serverless/_async/client/watcher.py +++ /dev/null @@ -1,607 +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 typing as t - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters - - -class WatcherClient(NamespacedClient): - @_rewrite_parameters() - async def ack_watch( - self, - *, - watch_id: str, - action_id: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Acknowledges a watch, manually throttling the execution of the watch's actions. - - ``_ - - :param watch_id: Watch ID - :param action_id: A comma-separated list of the action ids to be acked - """ - if watch_id in SKIP_IN_PATH: - 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: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "PUT", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - async def activate_watch( - self, - *, - watch_id: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Activates a currently inactive watch. - - ``_ - - :param watch_id: Watch ID - """ - if watch_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'watch_id'") - __path = f"/_watcher/watch/{_quote(watch_id)}/_activate" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "PUT", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - async def deactivate_watch( - self, - *, - watch_id: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Deactivates a currently active watch. - - ``_ - - :param watch_id: Watch ID - """ - if watch_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'watch_id'") - __path = f"/_watcher/watch/{_quote(watch_id)}/_deactivate" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "PUT", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - async def delete_watch( - self, - *, - id: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Removes a watch from Watcher. - - ``_ - - :param id: Watch ID - """ - if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'id'") - __path = f"/_watcher/watch/{_quote(id)}" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "DELETE", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters( - body_fields=True, - ) - async def execute_watch( - self, - *, - id: t.Optional[str] = None, - action_modes: t.Optional[ - t.Mapping[ - str, - t.Union[ - "t.Literal['execute', 'force_execute', 'force_simulate', 'simulate', 'skip']", - str, - ], - ] - ] = None, - alternative_input: t.Optional[t.Mapping[str, t.Any]] = None, - debug: t.Optional[bool] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - ignore_condition: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - record_execution: t.Optional[bool] = None, - simulated_actions: t.Optional[t.Mapping[str, t.Any]] = None, - trigger_data: t.Optional[t.Mapping[str, t.Any]] = None, - watch: t.Optional[t.Mapping[str, t.Any]] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Forces the execution of a stored watch. - - ``_ - - :param id: Identifier for the watch. - :param action_modes: Determines how to handle the watch actions as part of the - watch execution. - :param alternative_input: When present, the watch uses this object as a payload - instead of executing its own input. - :param debug: Defines whether the watch runs in debug mode. - :param ignore_condition: When set to `true`, the watch execution uses the always - condition. This can also be specified as an HTTP parameter. - :param record_execution: When set to `true`, the watch record representing the - watch execution result is persisted to the `.watcher-history` index for the - current time. In addition, the status of the watch is updated, possibly throttling - subsequent executions. This can also be specified as an HTTP parameter. - :param simulated_actions: - :param trigger_data: This structure is parsed as the data of the trigger event - that will be used during the watch execution - :param watch: When present, this watch is used instead of the one specified in - the request. This watch is not persisted to the index and record_execution - cannot be set. - """ - if id not in SKIP_IN_PATH: - __path = f"/_watcher/watch/{_quote(id)}/_execute" - else: - __path = "/_watcher/watch/_execute" - __body: t.Dict[str, t.Any] = {} - __query: t.Dict[str, t.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] - __headers = {"accept": "application/json"} - if __body is not None: - __headers["content-type"] = "application/json" - return await self.perform_request( # type: ignore[return-value] - "PUT", __path, params=__query, headers=__headers, body=__body - ) - - @_rewrite_parameters() - async def get_watch( - self, - *, - id: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Retrieves a watch by its ID. - - ``_ - - :param id: Watch ID - """ - if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'id'") - __path = f"/_watcher/watch/{_quote(id)}" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters( - body_fields=True, - ) - async def put_watch( - self, - *, - id: str, - actions: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None, - active: t.Optional[bool] = None, - condition: t.Optional[t.Mapping[str, t.Any]] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - if_primary_term: t.Optional[int] = None, - if_seq_no: t.Optional[int] = None, - input: t.Optional[t.Mapping[str, t.Any]] = None, - metadata: t.Optional[t.Mapping[str, t.Any]] = None, - pretty: t.Optional[bool] = None, - throttle_period: t.Optional[str] = None, - transform: t.Optional[t.Mapping[str, t.Any]] = None, - trigger: t.Optional[t.Mapping[str, t.Any]] = None, - version: t.Optional[int] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Creates a new watch, or updates an existing one. - - ``_ - - :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_seq_no: only update the watch if the last operation that has changed - the watch has the specified 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: t.Dict[str, t.Any] = {} - __query: t.Dict[str, t.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_seq_no is not None: - __query["if_seq_no"] = if_seq_no - 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] - __headers = {"accept": "application/json"} - if __body is not None: - __headers["content-type"] = "application/json" - return await self.perform_request( # type: ignore[return-value] - "PUT", __path, params=__query, headers=__headers, body=__body - ) - - @_rewrite_parameters( - body_fields=True, - parameter_aliases={"from": "from_"}, - ) - async def query_watches( - self, - *, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - from_: t.Optional[int] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - query: t.Optional[t.Mapping[str, t.Any]] = None, - search_after: t.Optional[ - t.Union[ - t.List[t.Union[None, bool, float, int, str, t.Any]], - t.Tuple[t.Union[None, bool, float, int, str, t.Any], ...], - ] - ] = None, - size: t.Optional[int] = None, - sort: t.Optional[ - t.Union[ - t.Union[str, t.Mapping[str, t.Any]], - t.Union[ - t.List[t.Union[str, t.Mapping[str, t.Any]]], - t.Tuple[t.Union[str, t.Mapping[str, t.Any]], ...], - ], - ] - ] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Retrieves stored watches. - - ``_ - - :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: t.Dict[str, t.Any] = {} - __body: t.Dict[str, t.Any] = {} - # The 'sort' parameter with a colon can't be encoded to the body. - if sort is not None and ( - (isinstance(sort, str) and ":" in sort) - or ( - isinstance(sort, (list, tuple)) - and all(isinstance(_x, str) for _x in sort) - and any(":" in _x for _x in sort) - ) - ): - __query["sort"] = sort - sort = None - 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] - __headers = {"accept": "application/json"} - if __body is not None: - __headers["content-type"] = "application/json" - return await self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers, body=__body - ) - - @_rewrite_parameters() - async def start( - self, - *, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Starts Watcher if it is not already running. - - ``_ - """ - __path = "/_watcher/_start" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - async def stats( - self, - *, - metric: t.Optional[ - t.Union[ - t.Union[ - "t.Literal['_all', 'current_watches', 'pending_watches', 'queued_watches']", - str, - ], - t.Union[ - t.List[ - t.Union[ - "t.Literal['_all', 'current_watches', 'pending_watches', 'queued_watches']", - str, - ] - ], - t.Tuple[ - t.Union[ - "t.Literal['_all', 'current_watches', 'pending_watches', 'queued_watches']", - str, - ], - ..., - ], - ], - ] - ] = None, - emit_stacktraces: t.Optional[bool] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Retrieves the current Watcher metrics. - - ``_ - - :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. - """ - if metric not in SKIP_IN_PATH: - __path = f"/_watcher/stats/{_quote(metric)}" - else: - __path = "/_watcher/stats" - __query: t.Dict[str, t.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 - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - async def stop( - self, - *, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Stops Watcher if it is running. - - ``_ - """ - __path = "/_watcher/_stop" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers - ) diff --git a/elasticsearch_serverless/_async/client/xpack.py b/elasticsearch_serverless/_async/client/xpack.py deleted file mode 100644 index 0b5d4c3..0000000 --- a/elasticsearch_serverless/_async/client/xpack.py +++ /dev/null @@ -1,111 +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 typing as t - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient -from .utils import _rewrite_parameters - - -class XPackClient(NamespacedClient): - def __getattr__(self, attr_name: str) -> t.Any: - return getattr(self.client, attr_name) - - # AUTO-GENERATED-API-DEFINITIONS # - - @_rewrite_parameters() - async def info( - self, - *, - accept_enterprise: t.Optional[bool] = None, - categories: t.Optional[t.Union[t.List[str], t.Tuple[str, ...]]] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Retrieves information about the installed X-Pack features. - - ``_ - - :param accept_enterprise: If this param is used it must be set to true - :param categories: A comma-separated list of the information categories to include - in the response. For example, `build,license,features`. - """ - __path = "/_xpack" - __query: t.Dict[str, t.Any] = {} - if accept_enterprise is not None: - __query["accept_enterprise"] = accept_enterprise - 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 - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - async def usage( - self, - *, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Retrieves usage information about the installed X-Pack features. - - ``_ - - :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. - """ - __path = "/_xpack/usage" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["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 - __headers = {"accept": "application/json"} - return await self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) diff --git a/elasticsearch_serverless/_sync/client/__init__.py b/elasticsearch_serverless/_sync/client/__init__.py index f16211e..453df38 100644 --- a/elasticsearch_serverless/_sync/client/__init__.py +++ b/elasticsearch_serverless/_sync/client/__init__.py @@ -35,38 +35,22 @@ from ...serializer import DEFAULT_SERIALIZERS from ._base import BaseClient, resolve_auth_headers 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 .logstash import LogstashClient -from .migration import MigrationClient from .ml import MlClient -from .monitoring import MonitoringClient -from .nodes import NodesClient from .query_ruleset import QueryRulesetClient -from .rollup import RollupClient from .search_application import SearchApplicationClient -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 .synonyms import SynonymsClient from .tasks import TasksClient -from .text_structure import TextStructureClient from .transform import TransformClient from .utils import ( _TYPE_HOST, @@ -78,8 +62,6 @@ is_requests_http_auth, is_requests_node_class, ) -from .watcher import WatcherClient -from .xpack import XPackClient logger = logging.getLogger("elasticsearch") @@ -294,42 +276,24 @@ def __init__( # namespaced clients for compatibility with API names self.async_search = AsyncSearchClient(self) - self.autoscaling = AutoscalingClient(self) self.cat = CatClient(self) self.cluster = ClusterClient(self) - self.fleet = FleetClient(self) - self.features = FeaturesClient(self) self.indices = IndicesClient(self) self.ingest = IngestClient(self) - self.nodes = NodesClient(self) - self.snapshot = SnapshotClient(self) self.tasks = TasksClient(self) - self.xpack = XPackClient(self) - self.ccr = CcrClient(self) - self.dangling_indices = DanglingIndicesClient(self) self.enrich = EnrichClient(self) self.eql = EqlClient(self) self.graph = GraphClient(self) - self.ilm = IlmClient(self) self.license = LicenseClient(self) self.logstash = LogstashClient(self) - self.migration = MigrationClient(self) self.ml = MlClient(self) - self.monitoring = MonitoringClient(self) self.query_ruleset = QueryRulesetClient(self) - self.rollup = RollupClient(self) self.search_application = SearchApplicationClient(self) - self.searchable_snapshots = SearchableSnapshotsClient(self) self.security = SecurityClient(self) - self.slm = SlmClient(self) - self.shutdown = ShutdownClient(self) self.sql = SqlClient(self) - self.ssl = SslClient(self) self.synonyms = SynonymsClient(self) - self.text_structure = TextStructureClient(self) self.transform = TransformClient(self) - self.watcher = WatcherClient(self) def __repr__(self) -> str: try: diff --git a/elasticsearch_serverless/_sync/client/autoscaling.py b/elasticsearch_serverless/_sync/client/autoscaling.py deleted file mode 100644 index be21e6f..0000000 --- a/elasticsearch_serverless/_sync/client/autoscaling.py +++ /dev/null @@ -1,175 +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 typing as t - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters - - -class AutoscalingClient(NamespacedClient): - @_rewrite_parameters() - def delete_autoscaling_policy( - self, - *, - name: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Deletes an autoscaling policy. Designed for indirect use by ECE/ESS and ECK. - Direct use is not supported. - - ``_ - - :param name: the name of the autoscaling policy - """ - if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'name'") - __path = f"/_autoscaling/policy/{_quote(name)}" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "DELETE", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - def get_autoscaling_capacity( - self, - *, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Gets the current autoscaling capacity based on the configured autoscaling policy. - Designed for indirect use by ECE/ESS and ECK. Direct use is not supported. - - ``_ - """ - __path = "/_autoscaling/capacity" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - def get_autoscaling_policy( - self, - *, - name: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Retrieves an autoscaling policy. Designed for indirect use by ECE/ESS and ECK. - Direct use is not supported. - - ``_ - - :param name: the name of the autoscaling policy - """ - if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'name'") - __path = f"/_autoscaling/policy/{_quote(name)}" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters( - body_name="policy", - ) - def put_autoscaling_policy( - self, - *, - name: str, - policy: t.Mapping[str, t.Any], - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Creates a new autoscaling policy. Designed for indirect use by ECE/ESS and ECK. - Direct use is not supported. - - ``_ - - :param name: the name of the autoscaling policy - :param policy: - """ - 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: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path 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 - __headers = {"accept": "application/json", "content-type": "application/json"} - return self.perform_request( # type: ignore[return-value] - "PUT", __path, params=__query, headers=__headers, body=__body - ) diff --git a/elasticsearch_serverless/_sync/client/ccr.py b/elasticsearch_serverless/_sync/client/ccr.py deleted file mode 100644 index bb19eb7..0000000 --- a/elasticsearch_serverless/_sync/client/ccr.py +++ /dev/null @@ -1,749 +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 typing as t - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters - - -class CcrClient(NamespacedClient): - @_rewrite_parameters() - def delete_auto_follow_pattern( - self, - *, - name: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Deletes auto-follow patterns. - - ``_ - - :param name: The name of the auto follow pattern. - """ - if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'name'") - __path = f"/_ccr/auto_follow/{_quote(name)}" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "DELETE", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters( - body_fields=True, - ) - def follow( - self, - *, - index: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - leader_index: t.Optional[str] = None, - max_outstanding_read_requests: t.Optional[int] = None, - max_outstanding_write_requests: t.Optional[int] = None, - max_read_request_operation_count: t.Optional[int] = None, - max_read_request_size: t.Optional[str] = None, - max_retry_delay: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - max_write_buffer_count: t.Optional[int] = None, - max_write_buffer_size: t.Optional[str] = None, - max_write_request_operation_count: t.Optional[int] = None, - max_write_request_size: t.Optional[str] = None, - pretty: t.Optional[bool] = None, - read_poll_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - remote_cluster: t.Optional[str] = None, - wait_for_active_shards: t.Optional[ - t.Union[int, t.Union["t.Literal['all', 'index-setting']", str]] - ] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Creates a new follower index configured to follow the referenced leader index. - - ``_ - - :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) - """ - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'index'") - __path = f"/{_quote(index)}/_ccr/follow" - __query: t.Dict[str, t.Any] = {} - __body: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["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 - __headers = {"accept": "application/json", "content-type": "application/json"} - return self.perform_request( # type: ignore[return-value] - "PUT", __path, params=__query, headers=__headers, body=__body - ) - - @_rewrite_parameters() - def follow_info( - self, - *, - index: t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]], - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Retrieves information about all follower indices, including parameters and status - for each follower index - - ``_ - - :param index: A comma-separated list of index patterns; use `_all` to perform - the operation on all indices - """ - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'index'") - __path = f"/{_quote(index)}/_ccr/info" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - def follow_stats( - self, - *, - index: t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]], - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Retrieves follower stats. return shard-level stats about the following tasks - associated with each shard for the specified indices. - - ``_ - - :param index: A comma-separated list of index patterns; use `_all` to perform - the operation on all indices - """ - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'index'") - __path = f"/{_quote(index)}/_ccr/stats" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters( - body_fields=True, - ) - def forget_follower( - self, - *, - index: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - follower_cluster: t.Optional[str] = None, - follower_index: t.Optional[str] = None, - follower_index_uuid: t.Optional[str] = None, - human: t.Optional[bool] = None, - leader_remote_cluster: t.Optional[str] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Removes the follower retention leases from the leader. - - ``_ - - :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: - """ - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'index'") - __path = f"/{_quote(index)}/_ccr/forget_follower" - __query: t.Dict[str, t.Any] = {} - __body: t.Dict[str, t.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 - __headers = {"accept": "application/json", "content-type": "application/json"} - return self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers, body=__body - ) - - @_rewrite_parameters() - def get_auto_follow_pattern( - self, - *, - name: t.Optional[str] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Gets configured auto-follow patterns. Returns the specified auto-follow pattern - collection. - - ``_ - - :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. - """ - if name not in SKIP_IN_PATH: - __path = f"/_ccr/auto_follow/{_quote(name)}" - else: - __path = "/_ccr/auto_follow" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - def pause_auto_follow_pattern( - self, - *, - name: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Pauses an auto-follow pattern - - ``_ - - :param name: The name of the auto follow pattern that should pause discovering - new indices to follow. - """ - if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'name'") - __path = f"/_ccr/auto_follow/{_quote(name)}/pause" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - def pause_follow( - self, - *, - index: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Pauses a follower index. The follower index will not fetch any additional operations - from the leader index. - - ``_ - - :param index: The name of the follower index that should pause following its - leader index. - """ - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'index'") - __path = f"/{_quote(index)}/_ccr/pause_follow" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters( - body_fields=True, - ) - def put_auto_follow_pattern( - self, - *, - name: str, - remote_cluster: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - follow_index_pattern: t.Optional[str] = None, - human: t.Optional[bool] = None, - leader_index_exclusion_patterns: t.Optional[ - t.Union[t.List[str], t.Tuple[str, ...]] - ] = None, - leader_index_patterns: t.Optional[ - t.Union[t.List[str], t.Tuple[str, ...]] - ] = None, - max_outstanding_read_requests: t.Optional[int] = None, - max_outstanding_write_requests: t.Optional[int] = None, - max_read_request_operation_count: t.Optional[int] = None, - max_read_request_size: t.Optional[t.Union[int, str]] = None, - max_retry_delay: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - max_write_buffer_count: t.Optional[int] = None, - max_write_buffer_size: t.Optional[t.Union[int, str]] = None, - max_write_request_operation_count: t.Optional[int] = None, - max_write_request_size: t.Optional[t.Union[int, str]] = None, - pretty: t.Optional[bool] = None, - read_poll_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - settings: t.Optional[t.Mapping[str, t.Any]] = None, - ) -> ObjectApiResponse[t.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. - - ``_ - - :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). - """ - 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: t.Dict[str, t.Any] = {} - __query: t.Dict[str, t.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 - __headers = {"accept": "application/json", "content-type": "application/json"} - return self.perform_request( # type: ignore[return-value] - "PUT", __path, params=__query, headers=__headers, body=__body - ) - - @_rewrite_parameters() - def resume_auto_follow_pattern( - self, - *, - name: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Resumes an auto-follow pattern that has been paused - - ``_ - - :param name: The name of the auto follow pattern to resume discovering new indices - to follow. - """ - if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'name'") - __path = f"/_ccr/auto_follow/{_quote(name)}/resume" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters( - body_fields=True, - ) - def resume_follow( - self, - *, - index: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - max_outstanding_read_requests: t.Optional[int] = None, - max_outstanding_write_requests: t.Optional[int] = None, - max_read_request_operation_count: t.Optional[int] = None, - max_read_request_size: t.Optional[str] = None, - max_retry_delay: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - max_write_buffer_count: t.Optional[int] = None, - max_write_buffer_size: t.Optional[str] = None, - max_write_request_operation_count: t.Optional[int] = None, - max_write_request_size: t.Optional[str] = None, - pretty: t.Optional[bool] = None, - read_poll_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Resumes a follower index that has been paused - - ``_ - - :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: - """ - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'index'") - __path = f"/{_quote(index)}/_ccr/resume_follow" - __query: t.Dict[str, t.Any] = {} - __body: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["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] - __headers = {"accept": "application/json"} - if __body is not None: - __headers["content-type"] = "application/json" - return self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers, body=__body - ) - - @_rewrite_parameters() - def stats( - self, - *, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Gets all stats related to cross-cluster replication. - - ``_ - """ - __path = "/_ccr/stats" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - def unfollow( - self, - *, - index: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Stops the following task associated with a follower index and removes index metadata - and settings associated with cross-cluster replication. - - ``_ - - :param index: The name of the follower index that should be turned into a regular - index. - """ - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'index'") - __path = f"/{_quote(index)}/_ccr/unfollow" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers - ) diff --git a/elasticsearch_serverless/_sync/client/dangling_indices.py b/elasticsearch_serverless/_sync/client/dangling_indices.py deleted file mode 100644 index b742998..0000000 --- a/elasticsearch_serverless/_sync/client/dangling_indices.py +++ /dev/null @@ -1,162 +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 typing as t - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters - - -class DanglingIndicesClient(NamespacedClient): - @_rewrite_parameters() - def delete_dangling_index( - self, - *, - index_uuid: str, - accept_data_loss: bool, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - pretty: t.Optional[bool] = None, - timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Deletes the specified dangling index - - ``_ - - :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 - """ - if index_uuid in SKIP_IN_PATH: - 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: t.Dict[str, t.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 - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "DELETE", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - def import_dangling_index( - self, - *, - index_uuid: str, - accept_data_loss: bool, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - pretty: t.Optional[bool] = None, - timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Imports the specified dangling index - - ``_ - - :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 - """ - if index_uuid in SKIP_IN_PATH: - 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: t.Dict[str, t.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 - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - def list_dangling_indices( - self, - *, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Returns all dangling indices. - - ``_ - """ - __path = "/_dangling" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) diff --git a/elasticsearch_serverless/_sync/client/features.py b/elasticsearch_serverless/_sync/client/features.py deleted file mode 100644 index 43dca35..0000000 --- a/elasticsearch_serverless/_sync/client/features.py +++ /dev/null @@ -1,88 +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 typing as t - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient -from .utils import _rewrite_parameters - - -class FeaturesClient(NamespacedClient): - @_rewrite_parameters() - def get_features( - self, - *, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Gets a list of features which can be included in snapshots using the feature_states - field when creating a snapshot - - ``_ - """ - __path = "/_features" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - def reset_features( - self, - *, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Resets the internal state of features, usually by deleting system indices - - ``_ - """ - __path = "/_features/_reset" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers - ) diff --git a/elasticsearch_serverless/_sync/client/fleet.py b/elasticsearch_serverless/_sync/client/fleet.py deleted file mode 100644 index 20357ef..0000000 --- a/elasticsearch_serverless/_sync/client/fleet.py +++ /dev/null @@ -1,631 +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 typing as t - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters - - -class FleetClient(NamespacedClient): - @_rewrite_parameters() - def global_checkpoints( - self, - *, - index: str, - checkpoints: t.Optional[t.Union[t.List[int], t.Tuple[int, ...]]] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, - wait_for_advance: t.Optional[bool] = None, - wait_for_index: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Returns the current global checkpoints for an index. This API is design for internal - use by the fleet server project. - - ``_ - - :param index: A single index or index alias that resolves to a single index. - :param checkpoints: A comma separated list of previous global checkpoints. When - used in combination with `wait_for_advance`, the API will only return once - the global checkpoints advances past the checkpoints. Providing an empty - list will cause Elasticsearch to immediately return the current global checkpoints. - :param timeout: Period to wait for a global checkpoints to advance past `checkpoints`. - :param wait_for_advance: A boolean value which controls whether to wait (until - the timeout) for the global checkpoints to advance past the provided `checkpoints`. - :param wait_for_index: A boolean value which controls whether to wait (until - the timeout) for the target index to exist and all primary shards be active. - Can only be true when `wait_for_advance` is true. - """ - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'index'") - __path = f"/{_quote(index)}/_fleet/global_checkpoints" - __query: t.Dict[str, t.Any] = {} - if checkpoints is not None: - __query["checkpoints"] = checkpoints - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is 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_advance is not None: - __query["wait_for_advance"] = wait_for_advance - if wait_for_index is not None: - __query["wait_for_index"] = wait_for_index - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters( - body_name="searches", - ) - def msearch( - self, - *, - searches: t.Union[ - t.List[t.Mapping[str, t.Any]], t.Tuple[t.Mapping[str, t.Any], ...] - ], - index: t.Optional[str] = None, - allow_no_indices: t.Optional[bool] = None, - allow_partial_search_results: t.Optional[bool] = None, - ccs_minimize_roundtrips: t.Optional[bool] = None, - error_trace: t.Optional[bool] = None, - expand_wildcards: t.Optional[ - t.Union[ - t.Union["t.Literal['all', 'closed', 'hidden', 'none', 'open']", str], - t.Union[ - t.List[ - t.Union[ - "t.Literal['all', 'closed', 'hidden', 'none', 'open']", str - ] - ], - t.Tuple[ - t.Union[ - "t.Literal['all', 'closed', 'hidden', 'none', 'open']", str - ], - ..., - ], - ], - ] - ] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - ignore_throttled: t.Optional[bool] = None, - ignore_unavailable: t.Optional[bool] = None, - max_concurrent_searches: t.Optional[int] = None, - max_concurrent_shard_requests: t.Optional[int] = None, - pre_filter_shard_size: t.Optional[int] = None, - pretty: t.Optional[bool] = None, - rest_total_hits_as_int: t.Optional[bool] = None, - search_type: t.Optional[ - t.Union["t.Literal['dfs_query_then_fetch', 'query_then_fetch']", str] - ] = None, - typed_keys: t.Optional[bool] = None, - wait_for_checkpoints: t.Optional[ - t.Union[t.List[int], t.Tuple[int, ...]] - ] = None, - ) -> ObjectApiResponse[t.Any]: - """ - 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. - - :param searches: - :param index: A single target to search. If the target is an index alias, it - must resolve to a single index. - :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 allow_partial_search_results: If true, returns partial results if there - are shard request timeouts or [shard failures](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-replication.html#shard-failures). - If false, returns an error with no partial results. Defaults to the configured - cluster setting `search.default_allow_partial_results` which is true by default. - :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. - :param wait_for_checkpoints: A comma separated list of checkpoints. When configured, - the search API will only be executed on a shard after the relevant checkpoint - has become visible for search. Defaults to an empty list which will cause - Elasticsearch to immediately execute the search. - """ - if searches is None: - raise ValueError("Empty value passed for parameter 'searches'") - if index not in SKIP_IN_PATH: - __path = f"/{_quote(index)}/_fleet/_fleet_msearch" - else: - __path = "/_fleet/_fleet_msearch" - __query: t.Dict[str, t.Any] = {} - 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 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 - if wait_for_checkpoints is not None: - __query["wait_for_checkpoints"] = wait_for_checkpoints - __body = searches - __headers = { - "accept": "application/json", - "content-type": "application/x-ndjson", - } - return self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, 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, - *, - index: str, - aggregations: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None, - aggs: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None, - allow_no_indices: t.Optional[bool] = None, - allow_partial_search_results: t.Optional[bool] = None, - analyze_wildcard: t.Optional[bool] = None, - analyzer: t.Optional[str] = None, - batched_reduce_size: t.Optional[int] = None, - ccs_minimize_roundtrips: t.Optional[bool] = None, - collapse: t.Optional[t.Mapping[str, t.Any]] = None, - default_operator: t.Optional[t.Union["t.Literal['and', 'or']", str]] = None, - df: t.Optional[str] = None, - docvalue_fields: t.Optional[ - t.Union[t.List[t.Mapping[str, t.Any]], t.Tuple[t.Mapping[str, t.Any], ...]] - ] = None, - error_trace: t.Optional[bool] = None, - expand_wildcards: t.Optional[ - t.Union[ - t.Union["t.Literal['all', 'closed', 'hidden', 'none', 'open']", str], - t.Union[ - t.List[ - t.Union[ - "t.Literal['all', 'closed', 'hidden', 'none', 'open']", str - ] - ], - t.Tuple[ - t.Union[ - "t.Literal['all', 'closed', 'hidden', 'none', 'open']", str - ], - ..., - ], - ], - ] - ] = None, - explain: t.Optional[bool] = None, - ext: t.Optional[t.Mapping[str, t.Any]] = None, - fields: t.Optional[ - t.Union[t.List[t.Mapping[str, t.Any]], t.Tuple[t.Mapping[str, t.Any], ...]] - ] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - from_: t.Optional[int] = None, - highlight: t.Optional[t.Mapping[str, t.Any]] = None, - human: t.Optional[bool] = None, - ignore_throttled: t.Optional[bool] = None, - ignore_unavailable: t.Optional[bool] = None, - indices_boost: t.Optional[ - t.Union[t.List[t.Mapping[str, float]], t.Tuple[t.Mapping[str, float], ...]] - ] = None, - lenient: t.Optional[bool] = None, - max_concurrent_shard_requests: t.Optional[int] = None, - min_compatible_shard_node: t.Optional[str] = None, - min_score: t.Optional[float] = None, - pit: t.Optional[t.Mapping[str, t.Any]] = None, - post_filter: t.Optional[t.Mapping[str, t.Any]] = None, - pre_filter_shard_size: t.Optional[int] = None, - preference: t.Optional[str] = None, - pretty: t.Optional[bool] = None, - profile: t.Optional[bool] = None, - q: t.Optional[str] = None, - query: t.Optional[t.Mapping[str, t.Any]] = None, - request_cache: t.Optional[bool] = None, - rescore: t.Optional[ - t.Union[ - t.Mapping[str, t.Any], - t.Union[ - t.List[t.Mapping[str, t.Any]], t.Tuple[t.Mapping[str, t.Any], ...] - ], - ] - ] = None, - rest_total_hits_as_int: t.Optional[bool] = None, - routing: t.Optional[str] = None, - runtime_mappings: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None, - script_fields: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None, - scroll: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, - search_after: t.Optional[ - t.Union[ - t.List[t.Union[None, bool, float, int, str, t.Any]], - t.Tuple[t.Union[None, bool, float, int, str, t.Any], ...], - ] - ] = None, - search_type: t.Optional[ - t.Union["t.Literal['dfs_query_then_fetch', 'query_then_fetch']", str] - ] = None, - seq_no_primary_term: t.Optional[bool] = None, - size: t.Optional[int] = None, - slice: t.Optional[t.Mapping[str, t.Any]] = None, - sort: t.Optional[ - t.Union[ - t.Union[str, t.Mapping[str, t.Any]], - t.Union[ - t.List[t.Union[str, t.Mapping[str, t.Any]]], - t.Tuple[t.Union[str, t.Mapping[str, t.Any]], ...], - ], - ] - ] = None, - source: t.Optional[t.Union[bool, t.Mapping[str, t.Any]]] = None, - source_excludes: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - source_includes: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - stats: t.Optional[t.Union[t.List[str], t.Tuple[str, ...]]] = None, - stored_fields: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - suggest: t.Optional[t.Mapping[str, t.Any]] = None, - suggest_field: t.Optional[str] = None, - suggest_mode: t.Optional[ - t.Union["t.Literal['always', 'missing', 'popular']", str] - ] = None, - suggest_size: t.Optional[int] = None, - suggest_text: t.Optional[str] = None, - terminate_after: t.Optional[int] = None, - timeout: t.Optional[str] = None, - track_scores: t.Optional[bool] = None, - track_total_hits: t.Optional[t.Union[bool, int]] = None, - typed_keys: t.Optional[bool] = None, - version: t.Optional[bool] = None, - wait_for_checkpoints: t.Optional[ - t.Union[t.List[int], t.Tuple[int, ...]] - ] = None, - ) -> ObjectApiResponse[t.Any]: - """ - 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. - - :param index: A single target to search. If the target is an index alias, it - must resolve to a single index. - :param aggregations: - :param aggs: - :param allow_no_indices: - :param allow_partial_search_results: If true, returns partial results if there - are shard request timeouts or [shard failures](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-replication.html#shard-failures). - If false, returns an error with no partial results. Defaults to the configured - cluster setting `search.default_allow_partial_results` which is true by default. - :param analyze_wildcard: - :param analyzer: - :param batched_reduce_size: - :param ccs_minimize_roundtrips: - :param collapse: - :param default_operator: - :param df: - :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: - :param explain: If true, returns detailed information about score computation - as part of a hit. - :param ext: Configuration of search extensions defined by Elasticsearch plugins. - :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: - :param ignore_unavailable: - :param indices_boost: Boosts the _score of documents from specified indices. - :param lenient: - :param max_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: - :param profile: - :param q: - :param query: Defines the search definition using the Query DSL. - :param request_cache: - :param rescore: - :param rest_total_hits_as_int: - :param routing: - :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: - :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: - :param source_includes: - :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: - :param suggest_size: - :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: - :param version: If true, returns document version as part of a hit. - :param wait_for_checkpoints: A comma separated list of checkpoints. When configured, - the search API will only be executed on a shard after the relevant checkpoint - has become visible for search. Defaults to an empty list which will cause - Elasticsearch to immediately execute the search. - """ - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'index'") - __path = f"/{_quote(index)}/_fleet/_fleet_search" - __body: t.Dict[str, t.Any] = {} - __query: t.Dict[str, t.Any] = {} - # The 'sort' parameter with a colon can't be encoded to the body. - if sort is not None and ( - (isinstance(sort, str) and ":" in sort) - or ( - isinstance(sort, (list, tuple)) - and all(isinstance(_x, str) for _x in sort) - and any(":" in _x for _x in sort) - ) - ): - __query["sort"] = sort - sort = None - 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: - __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 ext is not None: - __body["ext"] = ext - 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 wait_for_checkpoints is not None: - __query["wait_for_checkpoints"] = wait_for_checkpoints - if not __body: - __body = None # type: ignore[assignment] - __headers = {"accept": "application/json"} - if __body is not None: - __headers["content-type"] = "application/json" - return self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers, body=__body - ) diff --git a/elasticsearch_serverless/_sync/client/ilm.py b/elasticsearch_serverless/_sync/client/ilm.py deleted file mode 100644 index 6fa488a..0000000 --- a/elasticsearch_serverless/_sync/client/ilm.py +++ /dev/null @@ -1,543 +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 typing as t - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters - - -class IlmClient(NamespacedClient): - @_rewrite_parameters() - def delete_lifecycle( - self, - *, - name: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - pretty: t.Optional[bool] = None, - timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Deletes the specified lifecycle policy definition. A currently used policy cannot - be deleted. - - ``_ - - :param name: Identifier for 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 timeout: Period to wait for a response. If no response is received before - the timeout expires, the request fails and returns an error. - """ - if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'name'") - __path = f"/_ilm/policy/{_quote(name)}" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["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 - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "DELETE", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - def explain_lifecycle( - self, - *, - index: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - only_errors: t.Optional[bool] = None, - only_managed: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Retrieves information about the index's current lifecycle state, such as the - currently executing phase, action, and step. - - ``_ - - :param index: Comma-separated list of data streams, indices, and aliases to target. - Supports wildcards (`*`). To target all data streams and indices, use `*` - or `_all`. - :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 only_errors: Filters the returned indices to only indices that are managed - by ILM and are in an error state, either due to an encountering an error - while executing the policy, or attempting to use a policy that does not exist. - :param only_managed: Filters the returned indices to only indices that are managed - by ILM. - :param timeout: Period to wait for a response. If no response is received before - the timeout expires, the request fails and returns an error. - """ - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'index'") - __path = f"/{_quote(index)}/_ilm/explain" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["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 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 timeout is not None: - __query["timeout"] = timeout - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - def get_lifecycle( - self, - *, - name: t.Optional[str] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - pretty: t.Optional[bool] = None, - timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Returns the specified policy definition. Includes the policy version and last - modified date. - - ``_ - - :param name: Identifier for 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 timeout: Period to wait for a response. 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"/_ilm/policy/{_quote(name)}" - else: - __path = "/_ilm/policy" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["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 - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - def get_status( - self, - *, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Retrieves the current index lifecycle management (ILM) status. - - ``_ - """ - __path = "/_ilm/status" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters( - body_fields=True, - ) - def migrate_to_data_tiers( - self, - *, - dry_run: t.Optional[bool] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - legacy_template_to_delete: t.Optional[str] = None, - node_attribute: t.Optional[str] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Migrates the indices and ILM policies away from custom node attribute allocation - routing to data tiers routing - - ``_ - - :param dry_run: If true, simulates the migration from node attributes based allocation - filters to data tiers, but does not perform the migration. This provides - a way to retrieve the indices and ILM policies that need to be migrated. - :param legacy_template_to_delete: - :param node_attribute: - """ - __path = "/_ilm/migrate_to_data_tiers" - __query: t.Dict[str, t.Any] = {} - __body: t.Dict[str, t.Any] = {} - 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 legacy_template_to_delete is not None: - __body["legacy_template_to_delete"] = legacy_template_to_delete - if node_attribute is not None: - __body["node_attribute"] = node_attribute - if pretty is not None: - __query["pretty"] = pretty - if not __body: - __body = None # type: ignore[assignment] - __headers = {"accept": "application/json"} - if __body is not None: - __headers["content-type"] = "application/json" - return self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers, body=__body - ) - - @_rewrite_parameters( - body_fields=True, - ) - def move_to_step( - self, - *, - index: str, - current_step: t.Optional[t.Mapping[str, t.Any]] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - next_step: t.Optional[t.Mapping[str, t.Any]] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Manually moves an index into the specified step and executes that step. - - ``_ - - :param index: The name of the index whose lifecycle step is to change - :param current_step: - :param next_step: - """ - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'index'") - __path = f"/_ilm/move/{_quote(index)}" - __body: t.Dict[str, t.Any] = {} - __query: t.Dict[str, t.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] - __headers = {"accept": "application/json"} - if __body is not None: - __headers["content-type"] = "application/json" - return self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers, body=__body - ) - - @_rewrite_parameters( - body_fields=True, - ) - def put_lifecycle( - self, - *, - name: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - policy: t.Optional[t.Mapping[str, t.Any]] = None, - pretty: t.Optional[bool] = None, - timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Creates a lifecycle policy - - ``_ - - :param name: Identifier for 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 policy: - :param timeout: Period to wait for a response. If no response is received before - the timeout expires, the request fails and returns an error. - """ - if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'name'") - __path = f"/_ilm/policy/{_quote(name)}" - __query: t.Dict[str, t.Any] = {} - __body: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["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 policy is not None: - __body["policy"] = policy - if pretty is not None: - __query["pretty"] = pretty - if timeout is not None: - __query["timeout"] = timeout - if not __body: - __body = None # type: ignore[assignment] - __headers = {"accept": "application/json"} - if __body is not None: - __headers["content-type"] = "application/json" - return self.perform_request( # type: ignore[return-value] - "PUT", __path, params=__query, headers=__headers, body=__body - ) - - @_rewrite_parameters() - def remove_policy( - self, - *, - index: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Removes the assigned lifecycle policy and stops managing the specified index - - ``_ - - :param index: The name of the index to remove policy on - """ - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'index'") - __path = f"/{_quote(index)}/_ilm/remove" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - def retry( - self, - *, - index: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Retries executing the policy for an index that is in the ERROR step. - - ``_ - - :param index: The name of the indices (comma-separated) whose failed lifecycle - step is to be retry - """ - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'index'") - __path = f"/{_quote(index)}/_ilm/retry" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - def start( - self, - *, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - pretty: t.Optional[bool] = None, - timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Start the index lifecycle management (ILM) plugin. - - ``_ - - :param master_timeout: - :param timeout: - """ - __path = "/_ilm/start" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["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 - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - def stop( - self, - *, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - pretty: t.Optional[bool] = None, - timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Halts all lifecycle management operations and stops the index lifecycle management - (ILM) plugin - - ``_ - - :param master_timeout: - :param timeout: - """ - __path = "/_ilm/stop" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["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 - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers - ) diff --git a/elasticsearch_serverless/_sync/client/migration.py b/elasticsearch_serverless/_sync/client/migration.py deleted file mode 100644 index 2ce226c..0000000 --- a/elasticsearch_serverless/_sync/client/migration.py +++ /dev/null @@ -1,127 +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 typing as t - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters - - -class MigrationClient(NamespacedClient): - @_rewrite_parameters() - def deprecations( - self, - *, - index: t.Optional[str] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.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. - - ``_ - - :param index: Comma-separate list of data streams or indices to check. Wildcard - (*) expressions are supported. - """ - if index not in SKIP_IN_PATH: - __path = f"/{_quote(index)}/_migration/deprecations" - else: - __path = "/_migration/deprecations" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - def get_feature_upgrade_status( - self, - *, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Find out whether system features need to be upgraded or not - - ``_ - """ - __path = "/_migration/system_features" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - def post_feature_upgrade( - self, - *, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Begin upgrades for system features - - ``_ - """ - __path = "/_migration/system_features" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers - ) diff --git a/elasticsearch_serverless/_sync/client/monitoring.py b/elasticsearch_serverless/_sync/client/monitoring.py deleted file mode 100644 index 1b65a06..0000000 --- a/elasticsearch_serverless/_sync/client/monitoring.py +++ /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. - -import typing as t - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient -from .utils import _rewrite_parameters - - -class MonitoringClient(NamespacedClient): - @_rewrite_parameters( - body_name="operations", - ) - def bulk( - self, - *, - interval: t.Union["t.Literal[-1]", "t.Literal[0]", str], - operations: t.Union[ - t.List[t.Mapping[str, t.Any]], t.Tuple[t.Mapping[str, t.Any], ...] - ], - system_api_version: str, - system_id: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Used by the monitoring features to send monitoring data. - - ``_ - - :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 - """ - 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: t.Dict[str, t.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 - __headers = { - "accept": "application/json", - "content-type": "application/x-ndjson", - } - return self.perform_request( # type: ignore[return-value] - "PUT", __path, params=__query, headers=__headers, body=__body - ) diff --git a/elasticsearch_serverless/_sync/client/nodes.py b/elasticsearch_serverless/_sync/client/nodes.py deleted file mode 100644 index e38240f..0000000 --- a/elasticsearch_serverless/_sync/client/nodes.py +++ /dev/null @@ -1,483 +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 typing as t - -from elastic_transport import ObjectApiResponse, TextApiResponse - -from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters - - -class NodesClient(NamespacedClient): - @_rewrite_parameters() - def clear_repositories_metering_archive( - self, - *, - node_id: t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]], - max_archive_version: int, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Removes the archived repositories metering information present in the cluster. - - ``_ - - :param node_id: Comma-separated list of node IDs or names used to limit returned - information. All the nodes selective options are explained [here](https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster.html#cluster-nodes). - :param max_archive_version: Specifies the maximum [archive_version](https://www.elastic.co/guide/en/elasticsearch/reference/current/get-repositories-metering-api.html#get-repositories-metering-api-response-body) - to be cleared from the archive. - """ - if node_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'node_id'") - if max_archive_version in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'max_archive_version'") - __path = f"/_nodes/{_quote(node_id)}/_repositories_metering/{_quote(max_archive_version)}" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "DELETE", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - def get_repositories_metering_info( - self, - *, - node_id: t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]], - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Returns cluster repositories metering information. - - ``_ - - :param node_id: Comma-separated list of node IDs or names used to limit returned - information. All the nodes selective options are explained [here](https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster.html#cluster-nodes). - """ - if node_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'node_id'") - __path = f"/_nodes/{_quote(node_id)}/_repositories_metering" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - def hot_threads( - self, - *, - node_id: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - ignore_idle_threads: t.Optional[bool] = None, - interval: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - pretty: t.Optional[bool] = None, - snapshots: t.Optional[int] = None, - sort: t.Optional[ - t.Union["t.Literal['block', 'cpu', 'gpu', 'mem', 'wait']", str] - ] = None, - threads: t.Optional[int] = None, - timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, - type: t.Optional[ - t.Union["t.Literal['block', 'cpu', 'gpu', 'mem', 'wait']", str] - ] = None, - ) -> TextApiResponse: - """ - Returns information about hot threads on each node in the cluster. - - ``_ - - :param node_id: List of node IDs or names used to limit returned information. - :param ignore_idle_threads: If true, known idle threads (e.g. waiting in a socket - select, or to get a task from an empty queue) are filtered out. - :param interval: The interval to do the second sampling of threads. - :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 snapshots: Number of samples of thread stacktrace. - :param sort: The sort order for 'cpu' type (default: total) - :param threads: Specifies the number of hot threads to provide information for. - :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 type: The type to sample. - """ - if node_id not in SKIP_IN_PATH: - __path = f"/_nodes/{_quote(node_id)}/hot_threads" - else: - __path = "/_nodes/hot_threads" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["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 master_timeout is not None: - __query["master_timeout"] = master_timeout - if pretty is not None: - __query["pretty"] = pretty - if snapshots is not None: - __query["snapshots"] = snapshots - if sort is not None: - __query["sort"] = sort - if threads is not None: - __query["threads"] = threads - if timeout is not None: - __query["timeout"] = timeout - if type is not None: - __query["type"] = type - __headers = {"accept": "text/plain"} - return self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - def info( - self, - *, - node_id: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - metric: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - flat_settings: t.Optional[bool] = None, - human: t.Optional[bool] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - pretty: t.Optional[bool] = None, - timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Returns information about nodes in the cluster. - - ``_ - - :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. - """ - 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: t.Dict[str, t.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 - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters( - body_fields=True, - ) - def reload_secure_settings( - self, - *, - node_id: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - secure_settings_password: t.Optional[str] = None, - timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Reloads secure settings. - - ``_ - - :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 - """ - if node_id not in SKIP_IN_PATH: - __path = f"/_nodes/{_quote(node_id)}/reload_secure_settings" - else: - __path = "/_nodes/reload_secure_settings" - __query: t.Dict[str, t.Any] = {} - __body: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is 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] - __headers = {"accept": "application/json"} - if __body is not None: - __headers["content-type"] = "application/json" - return self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers, body=__body - ) - - @_rewrite_parameters() - def stats( - self, - *, - node_id: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - metric: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - index_metric: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - completion_fields: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - error_trace: t.Optional[bool] = None, - fielddata_fields: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - fields: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - groups: t.Optional[bool] = None, - human: t.Optional[bool] = None, - include_segment_file_sizes: t.Optional[bool] = None, - include_unloaded_segments: t.Optional[bool] = None, - level: t.Optional[ - t.Union["t.Literal['cluster', 'indices', 'shards']", str] - ] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - pretty: t.Optional[bool] = None, - timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, - types: t.Optional[t.Union[t.List[str], t.Tuple[str, ...]]] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Returns statistical information about nodes in the cluster. - - ``_ - - :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. - """ - 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: t.Dict[str, t.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 - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - def usage( - self, - *, - node_id: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - metric: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Returns low-level information about REST actions usage on nodes. - - ``_ - - :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 - """ - 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: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is 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 - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) diff --git a/elasticsearch_serverless/_sync/client/rollup.py b/elasticsearch_serverless/_sync/client/rollup.py deleted file mode 100644 index c54e0c0..0000000 --- a/elasticsearch_serverless/_sync/client/rollup.py +++ /dev/null @@ -1,440 +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 typing as t - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters - - -class RollupClient(NamespacedClient): - @_rewrite_parameters() - def delete_job( - self, - *, - id: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Deletes an existing rollup job. - - ``_ - - :param id: The ID of the job to delete - """ - if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'id'") - __path = f"/_rollup/job/{_quote(id)}" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "DELETE", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - def get_jobs( - self, - *, - id: t.Optional[str] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Retrieves the configuration, stats, and status of rollup jobs. - - ``_ - - :param id: The ID of the job(s) to fetch. Accepts glob patterns, or left blank - for all jobs - """ - if id not in SKIP_IN_PATH: - __path = f"/_rollup/job/{_quote(id)}" - else: - __path = "/_rollup/job" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - def get_rollup_caps( - self, - *, - id: t.Optional[str] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Returns the capabilities of any rollup jobs that have been configured for a specific - index or index pattern. - - ``_ - - :param id: The ID of the index to check rollup capabilities on, or left blank - for all jobs - """ - if id not in SKIP_IN_PATH: - __path = f"/_rollup/data/{_quote(id)}" - else: - __path = "/_rollup/data" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - def get_rollup_index_caps( - self, - *, - index: t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]], - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Returns the rollup capabilities of all jobs inside of a rollup index (e.g. the - index where rollup data is stored). - - ``_ - - :param index: The rollup index or index pattern to obtain rollup capabilities - from. - """ - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'index'") - __path = f"/{_quote(index)}/_rollup/data" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters( - body_fields=True, - ignore_deprecated_options={"headers"}, - ) - def put_job( - self, - *, - id: str, - cron: str, - groups: t.Mapping[str, t.Any], - index_pattern: str, - page_size: int, - rollup_index: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - headers: t.Optional[ - t.Mapping[str, t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]]] - ] = None, - human: t.Optional[bool] = None, - metrics: t.Optional[ - t.Union[t.List[t.Mapping[str, t.Any]], t.Tuple[t.Mapping[str, t.Any], ...]] - ] = None, - pretty: t.Optional[bool] = None, - timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Creates a rollup job. - - ``_ - - :param id: Identifier for the rollup job. This can be any alphanumeric string - and uniquely identifies the data that is associated with the rollup job. - The ID is persistent; it is stored with the rolled up data. If you create - a job, let it run for a while, then delete the job, the data that the job - rolled up is still be associated with this job ID. You cannot create a new - job with the same ID since that could lead to problems with mismatched job - configurations. - :param cron: A cron string which defines the intervals when the rollup job should - be executed. When the interval triggers, the indexer attempts to rollup the - data in the index pattern. The cron pattern is unrelated to the time interval - of the data being rolled up. For example, you may wish to create hourly rollups - of your document but to only run the indexer on a daily basis at midnight, - as defined by the cron. The cron pattern is defined just like a Watcher cron - schedule. - :param groups: Defines the grouping fields and aggregations that are defined - for this rollup job. These fields will then be available later for aggregating - into buckets. These aggs and fields can be used in any combination. Think - of the groups configuration as defining a set of tools that can later be - used in aggregations to partition the data. Unlike raw data, we have to think - ahead to which fields and aggregations might be used. Rollups provide enough - flexibility that you simply need to determine which fields are needed, not - in what order they are needed. - :param index_pattern: The index or index pattern to roll up. Supports wildcard-style - patterns (`logstash-*`). The job attempts to rollup the entire index or index-pattern. - :param page_size: The number of bucket results that are processed on each iteration - of the rollup indexer. A larger value tends to execute faster, but requires - more memory during processing. This value has no effect on how the data is - rolled up; it is merely used for tweaking the speed or memory cost of the - indexer. - :param rollup_index: The index that contains the rollup results. The index can - be shared with other rollup jobs. The data is stored so that it doesn’t interfere - with unrelated jobs. - :param headers: - :param metrics: Defines the metrics to collect for each grouping tuple. By default, - only the doc_counts are collected for each group. To make rollup useful, - you will often add metrics like averages, mins, maxes, etc. Metrics are defined - on a per-field basis and for each field you configure which metric should - be collected. - :param timeout: Time to wait for the request to complete. - """ - if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'id'") - if cron is None: - raise ValueError("Empty value passed for parameter 'cron'") - if groups is None: - raise ValueError("Empty value passed for parameter 'groups'") - if index_pattern is None: - raise ValueError("Empty value passed for parameter 'index_pattern'") - if page_size is None: - raise ValueError("Empty value passed for parameter 'page_size'") - if rollup_index is None: - raise ValueError("Empty value passed for parameter 'rollup_index'") - __path = f"/_rollup/job/{_quote(id)}" - __body: t.Dict[str, t.Any] = {} - __query: t.Dict[str, t.Any] = {} - if cron is not None: - __body["cron"] = cron - if groups is not None: - __body["groups"] = groups - if index_pattern is not None: - __body["index_pattern"] = index_pattern - if page_size is not None: - __body["page_size"] = page_size - if rollup_index is not None: - __body["rollup_index"] = rollup_index - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if headers is not None: - __body["headers"] = headers - if human is not None: - __query["human"] = human - if metrics is not None: - __body["metrics"] = metrics - if pretty is not None: - __query["pretty"] = pretty - if timeout is not None: - __body["timeout"] = timeout - __headers = {"accept": "application/json", "content-type": "application/json"} - return self.perform_request( # type: ignore[return-value] - "PUT", __path, params=__query, headers=__headers, body=__body - ) - - @_rewrite_parameters( - body_fields=True, - ) - def rollup_search( - self, - *, - index: t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]], - aggregations: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None, - aggs: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - query: t.Optional[t.Mapping[str, t.Any]] = None, - rest_total_hits_as_int: t.Optional[bool] = None, - size: t.Optional[int] = None, - typed_keys: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Enables searching rolled-up data using the standard query DSL. - - ``_ - - :param index: The indices or index-pattern(s) (containing rollup or regular data) - that should be searched - :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 - :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 - """ - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'index'") - __path = f"/{_quote(index)}/_rollup_search" - __body: t.Dict[str, t.Any] = {} - __query: t.Dict[str, t.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: - __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 - __headers = {"accept": "application/json", "content-type": "application/json"} - return self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers, body=__body - ) - - @_rewrite_parameters() - def start_job( - self, - *, - id: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Starts an existing, stopped rollup job. - - ``_ - - :param id: The ID of the job to start - """ - if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'id'") - __path = f"/_rollup/job/{_quote(id)}/_start" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - def stop_job( - self, - *, - id: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, - wait_for_completion: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Stops an existing, started rollup job. - - ``_ - - :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. - """ - if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'id'") - __path = f"/_rollup/job/{_quote(id)}/_stop" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is 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 - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers - ) diff --git a/elasticsearch_serverless/_sync/client/searchable_snapshots.py b/elasticsearch_serverless/_sync/client/searchable_snapshots.py deleted file mode 100644 index 17cc31e..0000000 --- a/elasticsearch_serverless/_sync/client/searchable_snapshots.py +++ /dev/null @@ -1,265 +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 typing as t - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters - - -class SearchableSnapshotsClient(NamespacedClient): - @_rewrite_parameters() - def cache_stats( - self, - *, - node_id: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Retrieve node-level cache statistics about searchable snapshots. - - ``_ - - :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 master_timeout: - """ - if node_id not in SKIP_IN_PATH: - __path = f"/_searchable_snapshots/{_quote(node_id)}/cache/stats" - else: - __path = "/_searchable_snapshots/cache/stats" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["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 - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - def clear_cache( - self, - *, - index: t.Optional[t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]]] = None, - allow_no_indices: t.Optional[bool] = None, - error_trace: t.Optional[bool] = None, - expand_wildcards: t.Optional[ - t.Union[ - t.Union["t.Literal['all', 'closed', 'hidden', 'none', 'open']", str], - t.Union[ - t.List[ - t.Union[ - "t.Literal['all', 'closed', 'hidden', 'none', 'open']", str - ] - ], - t.Tuple[ - t.Union[ - "t.Literal['all', 'closed', 'hidden', 'none', 'open']", str - ], - ..., - ], - ], - ] - ] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - ignore_unavailable: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Clear the cache of searchable snapshots. - - ``_ - - :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) - """ - if index not in SKIP_IN_PATH: - __path = f"/{_quote(index)}/_searchable_snapshots/cache/clear" - else: - __path = "/_searchable_snapshots/cache/clear" - __query: t.Dict[str, t.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 - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters( - body_fields=True, - ) - def mount( - self, - *, - repository: str, - snapshot: str, - index: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - ignore_index_settings: t.Optional[ - t.Union[t.List[str], t.Tuple[str, ...]] - ] = None, - index_settings: t.Optional[t.Mapping[str, t.Any]] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - pretty: t.Optional[bool] = None, - renamed_index: t.Optional[str] = None, - storage: t.Optional[str] = None, - wait_for_completion: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Mount a snapshot as a searchable index. - - ``_ - - :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 - """ - 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: t.Dict[str, t.Any] = {} - __query: t.Dict[str, t.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 - __headers = {"accept": "application/json", "content-type": "application/json"} - return self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers, body=__body - ) - - @_rewrite_parameters() - def stats( - self, - *, - index: t.Optional[t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]]] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - level: t.Optional[ - t.Union["t.Literal['cluster', 'indices', 'shards']", str] - ] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Retrieve shard-level statistics about searchable snapshots. - - ``_ - - :param index: A comma-separated list of index names - :param level: Return stats aggregated at cluster, index or shard level - """ - if index not in SKIP_IN_PATH: - __path = f"/{_quote(index)}/_searchable_snapshots/stats" - else: - __path = "/_searchable_snapshots/stats" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["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 - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) diff --git a/elasticsearch_serverless/_sync/client/shutdown.py b/elasticsearch_serverless/_sync/client/shutdown.py deleted file mode 100644 index fef109e..0000000 --- a/elasticsearch_serverless/_sync/client/shutdown.py +++ /dev/null @@ -1,229 +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 typing as t - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters - - -class ShutdownClient(NamespacedClient): - @_rewrite_parameters() - def delete_node( - self, - *, - node_id: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - master_timeout: t.Optional[ - t.Union["t.Literal['d', 'h', 'm', 'micros', 'ms', 'nanos', 's']", str] - ] = None, - pretty: t.Optional[bool] = None, - timeout: t.Optional[ - t.Union["t.Literal['d', 'h', 'm', 'micros', 'ms', 'nanos', 's']", str] - ] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Removes a node from the shutdown list. Designed for indirect use by ECE/ESS and - ECK. Direct use is not supported. - - ``_ - - :param node_id: The node id of node to be removed from the shutdown state - :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. - """ - if node_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'node_id'") - __path = f"/_nodes/{_quote(node_id)}/shutdown" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["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 - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "DELETE", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - def get_node( - self, - *, - node_id: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - master_timeout: t.Optional[ - t.Union["t.Literal['d', 'h', 'm', 'micros', 'ms', 'nanos', 's']", str] - ] = None, - pretty: t.Optional[bool] = None, - timeout: t.Optional[ - t.Union["t.Literal['d', 'h', 'm', 'micros', 'ms', 'nanos', 's']", str] - ] = None, - ) -> ObjectApiResponse[t.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. - - ``_ - - :param node_id: Which node for which to retrieve the shutdown status - :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. - """ - if node_id not in SKIP_IN_PATH: - __path = f"/_nodes/{_quote(node_id)}/shutdown" - else: - __path = "/_nodes/shutdown" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["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 - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters( - body_fields=True, - ) - def put_node( - self, - *, - node_id: str, - reason: str, - type: t.Union["t.Literal['remove', 'replace', 'restart']", str], - allocation_delay: t.Optional[str] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - master_timeout: t.Optional[ - t.Union["t.Literal['d', 'h', 'm', 'micros', 'ms', 'nanos', 's']", str] - ] = None, - pretty: t.Optional[bool] = None, - target_node_name: t.Optional[str] = None, - timeout: t.Optional[ - t.Union["t.Literal['d', 'h', 'm', 'micros', 'ms', 'nanos', 's']", str] - ] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Adds a node to be shut down. Designed for indirect use by ECE/ESS and ECK. Direct - use is not supported. - - ``_ - - :param node_id: The node id of node to be shut down - :param reason: A human-readable reason that the node is being shut down. This - field provides information for other cluster operators; it does not affect - the shut down process. - :param type: Valid values are restart, remove, or replace. Use restart when you - need to temporarily shut down a node to perform an upgrade, make configuration - changes, or perform other maintenance. Because the node is expected to rejoin - the cluster, data is not migrated off of the node. Use remove when you need - to permanently remove a node from the cluster. The node is not marked ready - for shutdown until data is migrated off of the node Use replace to do a 1:1 - replacement of a node with another node. Certain allocation decisions will - be ignored (such as disk watermarks) in the interest of true replacement - of the source node with the target node. During a replace-type shutdown, - rollover and index creation may result in unassigned shards, and shrink may - fail until the replacement is complete. - :param allocation_delay: Only valid if type is restart. Controls how long Elasticsearch - will wait for the node to restart and join the cluster before reassigning - its shards to other nodes. This works the same as delaying allocation with - the index.unassigned.node_left.delayed_timeout setting. If you specify both - a restart allocation delay and an index-level allocation delay, the longer - of the two is used. - :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 target_node_name: Only valid if type is replace. Specifies the name of - the node that is replacing the node being shut down. Shards from the shut - down node are only allowed to be allocated to the target node, and no other - data will be allocated to the target node. During relocation of data certain - allocation rules are ignored, such as disk watermarks or user attribute filtering - rules. - :param timeout: Period to wait for a response. If no response is received before - the timeout expires, the request fails and returns an error. - """ - if node_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'node_id'") - if reason is None: - raise ValueError("Empty value passed for parameter 'reason'") - if type is None: - raise ValueError("Empty value passed for parameter 'type'") - __path = f"/_nodes/{_quote(node_id)}/shutdown" - __body: t.Dict[str, t.Any] = {} - __query: t.Dict[str, t.Any] = {} - if reason is not None: - __body["reason"] = reason - if type is not None: - __body["type"] = type - if allocation_delay is not None: - __body["allocation_delay"] = allocation_delay - if error_trace is not None: - __query["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 target_node_name is not None: - __body["target_node_name"] = target_node_name - if timeout is not None: - __query["timeout"] = timeout - __headers = {"accept": "application/json", "content-type": "application/json"} - return self.perform_request( # type: ignore[return-value] - "PUT", __path, params=__query, headers=__headers, body=__body - ) diff --git a/elasticsearch_serverless/_sync/client/slm.py b/elasticsearch_serverless/_sync/client/slm.py deleted file mode 100644 index 671b1c7..0000000 --- a/elasticsearch_serverless/_sync/client/slm.py +++ /dev/null @@ -1,377 +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 typing as t - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters - - -class SlmClient(NamespacedClient): - @_rewrite_parameters() - def delete_lifecycle( - self, - *, - policy_id: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Deletes an existing snapshot lifecycle policy. - - ``_ - - :param policy_id: The id of the snapshot lifecycle policy to remove - """ - if policy_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'policy_id'") - __path = f"/_slm/policy/{_quote(policy_id)}" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "DELETE", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - def execute_lifecycle( - self, - *, - policy_id: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Immediately creates a snapshot according to the lifecycle policy, without waiting - for the scheduled time. - - ``_ - - :param policy_id: The id of the snapshot lifecycle policy to be executed - """ - if policy_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'policy_id'") - __path = f"/_slm/policy/{_quote(policy_id)}/_execute" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "PUT", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - def execute_retention( - self, - *, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Deletes any snapshots that are expired according to the policy's retention rules. - - ``_ - """ - __path = "/_slm/_execute_retention" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - def get_lifecycle( - self, - *, - policy_id: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Retrieves one or more snapshot lifecycle policy definitions and information about - the latest snapshot attempts. - - ``_ - - :param policy_id: Comma-separated list of snapshot lifecycle policies to retrieve - """ - if policy_id not in SKIP_IN_PATH: - __path = f"/_slm/policy/{_quote(policy_id)}" - else: - __path = "/_slm/policy" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - def get_stats( - self, - *, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Returns global and policy-level statistics about actions taken by snapshot lifecycle - management. - - ``_ - """ - __path = "/_slm/stats" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - def get_status( - self, - *, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Retrieves the status of snapshot lifecycle management (SLM). - - ``_ - """ - __path = "/_slm/status" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters( - body_fields=True, - ) - def put_lifecycle( - self, - *, - policy_id: str, - config: t.Optional[t.Mapping[str, t.Any]] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - name: t.Optional[str] = None, - pretty: t.Optional[bool] = None, - repository: t.Optional[str] = None, - retention: t.Optional[t.Mapping[str, t.Any]] = None, - schedule: t.Optional[str] = None, - timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, - ) -> ObjectApiResponse[t.Any]: - """ - 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. - """ - if policy_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'policy_id'") - __path = f"/_slm/policy/{_quote(policy_id)}" - __body: t.Dict[str, t.Any] = {} - __query: t.Dict[str, t.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] - __headers = {"accept": "application/json"} - if __body is not None: - __headers["content-type"] = "application/json" - return self.perform_request( # type: ignore[return-value] - "PUT", __path, params=__query, headers=__headers, body=__body - ) - - @_rewrite_parameters() - def start( - self, - *, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Turns on snapshot lifecycle management (SLM). - - ``_ - """ - __path = "/_slm/start" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - def stop( - self, - *, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Turns off snapshot lifecycle management (SLM). - - ``_ - """ - __path = "/_slm/stop" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers - ) diff --git a/elasticsearch_serverless/_sync/client/snapshot.py b/elasticsearch_serverless/_sync/client/snapshot.py deleted file mode 100644 index 20cba3f..0000000 --- a/elasticsearch_serverless/_sync/client/snapshot.py +++ /dev/null @@ -1,773 +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 typing as t - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters - - -class SnapshotClient(NamespacedClient): - @_rewrite_parameters() - def cleanup_repository( - self, - *, - name: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - pretty: t.Optional[bool] = None, - timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Removes stale data from repository. - - ``_ - - :param name: Snapshot repository to clean up. - :param master_timeout: Period to wait for a connection to the master node. - :param timeout: Period to wait for a response. - """ - if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'name'") - __path = f"/_snapshot/{_quote(name)}/_cleanup" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["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 - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters( - body_fields=True, - ) - def clone( - self, - *, - repository: str, - snapshot: str, - target_snapshot: str, - indices: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - pretty: t.Optional[bool] = None, - timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Clones indices from one snapshot into another snapshot in the same repository. - - ``_ - - :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: - """ - 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: t.Dict[str, t.Any] = {} - __query: t.Dict[str, t.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 - __headers = {"accept": "application/json", "content-type": "application/json"} - return self.perform_request( # type: ignore[return-value] - "PUT", __path, params=__query, headers=__headers, body=__body - ) - - @_rewrite_parameters( - body_fields=True, - ) - def create( - self, - *, - repository: str, - snapshot: str, - error_trace: t.Optional[bool] = None, - feature_states: t.Optional[t.Union[t.List[str], t.Tuple[str, ...]]] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - ignore_unavailable: t.Optional[bool] = None, - include_global_state: t.Optional[bool] = None, - indices: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - metadata: t.Optional[t.Mapping[str, t.Any]] = None, - partial: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - wait_for_completion: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Creates a snapshot in a repository. - - ``_ - - :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. - """ - 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: t.Dict[str, t.Any] = {} - __body: t.Dict[str, t.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] - __headers = {"accept": "application/json"} - if __body is not None: - __headers["content-type"] = "application/json" - return self.perform_request( # type: ignore[return-value] - "PUT", __path, params=__query, headers=__headers, body=__body - ) - - @_rewrite_parameters( - body_fields=True, - ) - def create_repository( - self, - *, - name: str, - settings: t.Mapping[str, t.Any], - type: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - pretty: t.Optional[bool] = None, - repository: t.Optional[t.Mapping[str, t.Any]] = None, - timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, - verify: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Creates a repository. - - ``_ - - :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 - """ - 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: t.Dict[str, t.Any] = {} - __query: t.Dict[str, t.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 - __headers = {"accept": "application/json", "content-type": "application/json"} - return self.perform_request( # type: ignore[return-value] - "PUT", __path, params=__query, headers=__headers, body=__body - ) - - @_rewrite_parameters() - def delete( - self, - *, - repository: str, - snapshot: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Deletes one or more snapshots. - - ``_ - - :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 - """ - 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: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["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 - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "DELETE", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - def delete_repository( - self, - *, - name: t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]], - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - pretty: t.Optional[bool] = None, - timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Deletes a repository. - - ``_ - - :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 - """ - if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'name'") - __path = f"/_snapshot/{_quote(name)}" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["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 - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "DELETE", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - def get( - self, - *, - repository: str, - snapshot: t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]], - after: t.Optional[str] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - from_sort_value: t.Optional[str] = None, - human: t.Optional[bool] = None, - ignore_unavailable: t.Optional[bool] = None, - include_repository: t.Optional[bool] = None, - index_details: t.Optional[bool] = None, - index_names: t.Optional[bool] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - offset: t.Optional[int] = None, - order: t.Optional[t.Union["t.Literal['asc', 'desc']", str]] = None, - pretty: t.Optional[bool] = None, - size: t.Optional[int] = None, - slm_policy_filter: t.Optional[str] = None, - sort: t.Optional[ - t.Union[ - "t.Literal['duration', 'failed_shard_count', 'index_count', 'name', 'repository', 'shard_count', 'start_time']", - str, - ] - ] = None, - verbose: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Returns information about a snapshot. - - ``_ - - :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 after: Offset identifier to start pagination from as returned by the next - field in the response body. - :param from_sort_value: Value of the current sort column at which to start retrieval. - Can either be a string snapshot- or repository name when sorting by snapshot - or repository name, a millisecond time value or a number when sorting by - index- or shard count. - :param ignore_unavailable: If false, the request returns an error for any snapshots - that are unavailable. - :param include_repository: If true, returns the repository name in each snapshot. - :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 index_names: If true, returns the name of each index in each snapshot. - :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 offset: Numeric offset to start pagination from based on the snapshots - matching this request. Using a non-zero value for this parameter is mutually - exclusive with using the after parameter. Defaults to 0. - :param order: Sort order. Valid values are asc for ascending and desc for descending - order. Defaults to asc, meaning ascending order. - :param size: Maximum number of snapshots to return. Defaults to 0 which means - return all that match the request without limit. - :param slm_policy_filter: Filter snapshots by a comma-separated list of SLM policy - names that snapshots belong to. Also accepts wildcards (*) and combinations - of wildcards followed by exclude patterns starting with -. To include snapshots - not created by an SLM policy you can use the special pattern _none that will - match all snapshots without an SLM policy. - :param sort: Allows setting a sort order for the result. Defaults to start_time, - i.e. sorting by snapshot start time stamp. - :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. - """ - 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: t.Dict[str, t.Any] = {} - if after is not None: - __query["after"] = after - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if from_sort_value is not None: - __query["from_sort_value"] = from_sort_value - 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 index_names is not None: - __query["index_names"] = index_names - if master_timeout is not None: - __query["master_timeout"] = master_timeout - if offset is not None: - __query["offset"] = offset - if order is not None: - __query["order"] = order - if pretty is not None: - __query["pretty"] = pretty - if size is not None: - __query["size"] = size - if slm_policy_filter is not None: - __query["slm_policy_filter"] = slm_policy_filter - if sort is not None: - __query["sort"] = sort - if verbose is not None: - __query["verbose"] = verbose - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - def get_repository( - self, - *, - name: t.Optional[t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]]] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - local: t.Optional[bool] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Returns information about a repository. - - ``_ - - :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 - """ - if name not in SKIP_IN_PATH: - __path = f"/_snapshot/{_quote(name)}" - else: - __path = "/_snapshot" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["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 - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters( - body_fields=True, - ) - def restore( - self, - *, - repository: str, - snapshot: str, - error_trace: t.Optional[bool] = None, - feature_states: t.Optional[t.Union[t.List[str], t.Tuple[str, ...]]] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - ignore_index_settings: t.Optional[ - t.Union[t.List[str], t.Tuple[str, ...]] - ] = None, - ignore_unavailable: t.Optional[bool] = None, - include_aliases: t.Optional[bool] = None, - include_global_state: t.Optional[bool] = None, - index_settings: t.Optional[t.Mapping[str, t.Any]] = None, - indices: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - partial: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - rename_pattern: t.Optional[str] = None, - rename_replacement: t.Optional[str] = None, - wait_for_completion: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Restores a snapshot. - - ``_ - - :param repository: A repository name - :param snapshot: A snapshot name - :param feature_states: - :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 - """ - 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)}/_restore" - __query: t.Dict[str, t.Any] = {} - __body: t.Dict[str, t.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_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] - __headers = {"accept": "application/json"} - if __body is not None: - __headers["content-type"] = "application/json" - return self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers, body=__body - ) - - @_rewrite_parameters() - def status( - self, - *, - repository: t.Optional[str] = None, - snapshot: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - ignore_unavailable: t.Optional[bool] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Returns information about the status of a snapshot. - - ``_ - - :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 - """ - 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: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["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 - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - def verify_repository( - self, - *, - name: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - pretty: t.Optional[bool] = None, - timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Verifies a repository. - - ``_ - - :param name: A repository name - :param master_timeout: Explicit operation timeout for connection to master node - :param timeout: Explicit operation timeout - """ - if name in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'name'") - __path = f"/_snapshot/{_quote(name)}/_verify" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["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 - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers - ) diff --git a/elasticsearch_serverless/_sync/client/ssl.py b/elasticsearch_serverless/_sync/client/ssl.py deleted file mode 100644 index 99c1926..0000000 --- a/elasticsearch_serverless/_sync/client/ssl.py +++ /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. - -import typing as t - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient -from .utils import _rewrite_parameters - - -class SslClient(NamespacedClient): - @_rewrite_parameters() - def certificates( - self, - *, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Retrieves information about the X.509 certificates used to encrypt communications - in the cluster. - - ``_ - """ - __path = "/_ssl/certificates" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) diff --git a/elasticsearch_serverless/_sync/client/text_structure.py b/elasticsearch_serverless/_sync/client/text_structure.py deleted file mode 100644 index 5172c25..0000000 --- a/elasticsearch_serverless/_sync/client/text_structure.py +++ /dev/null @@ -1,158 +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 typing as t - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient -from .utils import _rewrite_parameters - - -class TextStructureClient(NamespacedClient): - @_rewrite_parameters( - body_name="text_files", - ) - def find_structure( - self, - *, - text_files: t.Union[t.List[t.Any], t.Tuple[t.Any, ...]], - charset: t.Optional[str] = None, - column_names: t.Optional[str] = None, - delimiter: t.Optional[str] = None, - explain: t.Optional[bool] = None, - format: t.Optional[str] = None, - grok_pattern: t.Optional[str] = None, - has_header_row: t.Optional[bool] = None, - line_merge_size_limit: t.Optional[int] = None, - lines_to_sample: t.Optional[int] = None, - quote: t.Optional[str] = None, - should_trim_fields: t.Optional[bool] = None, - timeout: t.Optional[t.Union["t.Literal[-1]", "t.Literal[0]", str]] = None, - timestamp_field: t.Optional[str] = None, - timestamp_format: t.Optional[str] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Finds the structure of a text file. The text file must contain data that is suitable - to be ingested into Elasticsearch. - - ``_ - - :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 - :param timestamp_format: The Java time format of the timestamp field in the text. - """ - if text_files is None: - raise ValueError("Empty value passed for parameter 'text_files'") - __path = "/_text_structure/find_structure" - __query: t.Dict[str, t.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 - __headers = { - "accept": "application/json", - "content-type": "application/x-ndjson", - } - return self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers, body=__body - ) diff --git a/elasticsearch_serverless/_sync/client/watcher.py b/elasticsearch_serverless/_sync/client/watcher.py deleted file mode 100644 index 2e1d866..0000000 --- a/elasticsearch_serverless/_sync/client/watcher.py +++ /dev/null @@ -1,607 +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 typing as t - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters - - -class WatcherClient(NamespacedClient): - @_rewrite_parameters() - def ack_watch( - self, - *, - watch_id: str, - action_id: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Acknowledges a watch, manually throttling the execution of the watch's actions. - - ``_ - - :param watch_id: Watch ID - :param action_id: A comma-separated list of the action ids to be acked - """ - if watch_id in SKIP_IN_PATH: - 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: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "PUT", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - def activate_watch( - self, - *, - watch_id: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Activates a currently inactive watch. - - ``_ - - :param watch_id: Watch ID - """ - if watch_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'watch_id'") - __path = f"/_watcher/watch/{_quote(watch_id)}/_activate" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "PUT", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - def deactivate_watch( - self, - *, - watch_id: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Deactivates a currently active watch. - - ``_ - - :param watch_id: Watch ID - """ - if watch_id in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'watch_id'") - __path = f"/_watcher/watch/{_quote(watch_id)}/_deactivate" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "PUT", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - def delete_watch( - self, - *, - id: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Removes a watch from Watcher. - - ``_ - - :param id: Watch ID - """ - if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'id'") - __path = f"/_watcher/watch/{_quote(id)}" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "DELETE", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters( - body_fields=True, - ) - def execute_watch( - self, - *, - id: t.Optional[str] = None, - action_modes: t.Optional[ - t.Mapping[ - str, - t.Union[ - "t.Literal['execute', 'force_execute', 'force_simulate', 'simulate', 'skip']", - str, - ], - ] - ] = None, - alternative_input: t.Optional[t.Mapping[str, t.Any]] = None, - debug: t.Optional[bool] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - ignore_condition: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - record_execution: t.Optional[bool] = None, - simulated_actions: t.Optional[t.Mapping[str, t.Any]] = None, - trigger_data: t.Optional[t.Mapping[str, t.Any]] = None, - watch: t.Optional[t.Mapping[str, t.Any]] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Forces the execution of a stored watch. - - ``_ - - :param id: Identifier for the watch. - :param action_modes: Determines how to handle the watch actions as part of the - watch execution. - :param alternative_input: When present, the watch uses this object as a payload - instead of executing its own input. - :param debug: Defines whether the watch runs in debug mode. - :param ignore_condition: When set to `true`, the watch execution uses the always - condition. This can also be specified as an HTTP parameter. - :param record_execution: When set to `true`, the watch record representing the - watch execution result is persisted to the `.watcher-history` index for the - current time. In addition, the status of the watch is updated, possibly throttling - subsequent executions. This can also be specified as an HTTP parameter. - :param simulated_actions: - :param trigger_data: This structure is parsed as the data of the trigger event - that will be used during the watch execution - :param watch: When present, this watch is used instead of the one specified in - the request. This watch is not persisted to the index and record_execution - cannot be set. - """ - if id not in SKIP_IN_PATH: - __path = f"/_watcher/watch/{_quote(id)}/_execute" - else: - __path = "/_watcher/watch/_execute" - __body: t.Dict[str, t.Any] = {} - __query: t.Dict[str, t.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] - __headers = {"accept": "application/json"} - if __body is not None: - __headers["content-type"] = "application/json" - return self.perform_request( # type: ignore[return-value] - "PUT", __path, params=__query, headers=__headers, body=__body - ) - - @_rewrite_parameters() - def get_watch( - self, - *, - id: str, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Retrieves a watch by its ID. - - ``_ - - :param id: Watch ID - """ - if id in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'id'") - __path = f"/_watcher/watch/{_quote(id)}" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters( - body_fields=True, - ) - def put_watch( - self, - *, - id: str, - actions: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None, - active: t.Optional[bool] = None, - condition: t.Optional[t.Mapping[str, t.Any]] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - if_primary_term: t.Optional[int] = None, - if_seq_no: t.Optional[int] = None, - input: t.Optional[t.Mapping[str, t.Any]] = None, - metadata: t.Optional[t.Mapping[str, t.Any]] = None, - pretty: t.Optional[bool] = None, - throttle_period: t.Optional[str] = None, - transform: t.Optional[t.Mapping[str, t.Any]] = None, - trigger: t.Optional[t.Mapping[str, t.Any]] = None, - version: t.Optional[int] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Creates a new watch, or updates an existing one. - - ``_ - - :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_seq_no: only update the watch if the last operation that has changed - the watch has the specified 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: t.Dict[str, t.Any] = {} - __query: t.Dict[str, t.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_seq_no is not None: - __query["if_seq_no"] = if_seq_no - 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] - __headers = {"accept": "application/json"} - if __body is not None: - __headers["content-type"] = "application/json" - return self.perform_request( # type: ignore[return-value] - "PUT", __path, params=__query, headers=__headers, body=__body - ) - - @_rewrite_parameters( - body_fields=True, - parameter_aliases={"from": "from_"}, - ) - def query_watches( - self, - *, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - from_: t.Optional[int] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - query: t.Optional[t.Mapping[str, t.Any]] = None, - search_after: t.Optional[ - t.Union[ - t.List[t.Union[None, bool, float, int, str, t.Any]], - t.Tuple[t.Union[None, bool, float, int, str, t.Any], ...], - ] - ] = None, - size: t.Optional[int] = None, - sort: t.Optional[ - t.Union[ - t.Union[str, t.Mapping[str, t.Any]], - t.Union[ - t.List[t.Union[str, t.Mapping[str, t.Any]]], - t.Tuple[t.Union[str, t.Mapping[str, t.Any]], ...], - ], - ] - ] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Retrieves stored watches. - - ``_ - - :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: t.Dict[str, t.Any] = {} - __body: t.Dict[str, t.Any] = {} - # The 'sort' parameter with a colon can't be encoded to the body. - if sort is not None and ( - (isinstance(sort, str) and ":" in sort) - or ( - isinstance(sort, (list, tuple)) - and all(isinstance(_x, str) for _x in sort) - and any(":" in _x for _x in sort) - ) - ): - __query["sort"] = sort - sort = None - 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] - __headers = {"accept": "application/json"} - if __body is not None: - __headers["content-type"] = "application/json" - return self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers, body=__body - ) - - @_rewrite_parameters() - def start( - self, - *, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Starts Watcher if it is not already running. - - ``_ - """ - __path = "/_watcher/_start" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - def stats( - self, - *, - metric: t.Optional[ - t.Union[ - t.Union[ - "t.Literal['_all', 'current_watches', 'pending_watches', 'queued_watches']", - str, - ], - t.Union[ - t.List[ - t.Union[ - "t.Literal['_all', 'current_watches', 'pending_watches', 'queued_watches']", - str, - ] - ], - t.Tuple[ - t.Union[ - "t.Literal['_all', 'current_watches', 'pending_watches', 'queued_watches']", - str, - ], - ..., - ], - ], - ] - ] = None, - emit_stacktraces: t.Optional[bool] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Retrieves the current Watcher metrics. - - ``_ - - :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. - """ - if metric not in SKIP_IN_PATH: - __path = f"/_watcher/stats/{_quote(metric)}" - else: - __path = "/_watcher/stats" - __query: t.Dict[str, t.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 - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - def stop( - self, - *, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Stops Watcher if it is running. - - ``_ - """ - __path = "/_watcher/_stop" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "POST", __path, params=__query, headers=__headers - ) diff --git a/elasticsearch_serverless/_sync/client/xpack.py b/elasticsearch_serverless/_sync/client/xpack.py deleted file mode 100644 index b1fbdd5..0000000 --- a/elasticsearch_serverless/_sync/client/xpack.py +++ /dev/null @@ -1,111 +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 typing as t - -from elastic_transport import ObjectApiResponse - -from ._base import NamespacedClient -from .utils import _rewrite_parameters - - -class XPackClient(NamespacedClient): - def __getattr__(self, attr_name: str) -> t.Any: - return getattr(self.client, attr_name) - - # AUTO-GENERATED-API-DEFINITIONS # - - @_rewrite_parameters() - def info( - self, - *, - accept_enterprise: t.Optional[bool] = None, - categories: t.Optional[t.Union[t.List[str], t.Tuple[str, ...]]] = None, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Retrieves information about the installed X-Pack features. - - ``_ - - :param accept_enterprise: If this param is used it must be set to true - :param categories: A comma-separated list of the information categories to include - in the response. For example, `build,license,features`. - """ - __path = "/_xpack" - __query: t.Dict[str, t.Any] = {} - if accept_enterprise is not None: - __query["accept_enterprise"] = accept_enterprise - 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 - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) - - @_rewrite_parameters() - def usage( - self, - *, - error_trace: t.Optional[bool] = None, - filter_path: t.Optional[ - t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]] - ] = None, - human: t.Optional[bool] = None, - master_timeout: t.Optional[ - t.Union["t.Literal[-1]", "t.Literal[0]", str] - ] = None, - pretty: t.Optional[bool] = None, - ) -> ObjectApiResponse[t.Any]: - """ - Retrieves usage information about the installed X-Pack features. - - ``_ - - :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. - """ - __path = "/_xpack/usage" - __query: t.Dict[str, t.Any] = {} - if error_trace is not None: - __query["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 - __headers = {"accept": "application/json"} - return self.perform_request( # type: ignore[return-value] - "GET", __path, params=__query, headers=__headers - ) diff --git a/elasticsearch_serverless/client.py b/elasticsearch_serverless/client.py index ae31a2f..802268b 100644 --- a/elasticsearch_serverless/client.py +++ b/elasticsearch_serverless/client.py @@ -21,50 +21,24 @@ from ._sync.client.async_search import ( # noqa: F401 AsyncSearchClient as AsyncSearchClient, ) -from ._sync.client.autoscaling import ( # noqa: F401 - AutoscalingClient as AutoscalingClient, -) from ._sync.client.cat import CatClient as CatClient # noqa: F401 -from ._sync.client.ccr import CcrClient as CcrClient # noqa: F401 from ._sync.client.cluster import ClusterClient as ClusterClient # noqa: F401 -from ._sync.client.dangling_indices import ( # noqa: F401 - DanglingIndicesClient as DanglingIndicesClient, -) from ._sync.client.enrich import EnrichClient as EnrichClient # noqa: F401 from ._sync.client.eql import EqlClient as EqlClient # noqa: F401 -from ._sync.client.features import FeaturesClient as FeaturesClient # noqa: F401 -from ._sync.client.fleet import FleetClient as FleetClient # noqa: F401 from ._sync.client.graph import GraphClient as GraphClient # noqa: F401 -from ._sync.client.ilm import IlmClient as IlmClient # noqa: F401 from ._sync.client.indices import IndicesClient as IndicesClient # noqa: F401 from ._sync.client.ingest import IngestClient as IngestClient # noqa: F401 from ._sync.client.license import LicenseClient as LicenseClient # noqa: F401 from ._sync.client.logstash import LogstashClient as LogstashClient # noqa: F401 -from ._sync.client.migration import MigrationClient as MigrationClient # noqa: F401 from ._sync.client.ml import MlClient as MlClient # noqa: F401 -from ._sync.client.monitoring import MonitoringClient as MonitoringClient # noqa: F401 -from ._sync.client.nodes import NodesClient as NodesClient # noqa: F401 from ._sync.client.query_ruleset import ( # noqa: F401 QueryRulesetClient as QueryRulesetClient, ) -from ._sync.client.rollup import RollupClient as RollupClient # noqa: F401 -from ._sync.client.searchable_snapshots import ( # noqa: F401 - SearchableSnapshotsClient as SearchableSnapshotsClient, -) from ._sync.client.security import SecurityClient as SecurityClient # noqa: F401 -from ._sync.client.shutdown import ShutdownClient as ShutdownClient # noqa: F401 -from ._sync.client.slm import SlmClient as SlmClient # noqa: F401 -from ._sync.client.snapshot import SnapshotClient as SnapshotClient # noqa: F401 from ._sync.client.sql import SqlClient as SqlClient # noqa: F401 -from ._sync.client.ssl import SslClient as SslClient # noqa: F401 from ._sync.client.synonyms import SynonymsClient as SynonymsClient # noqa: F401 from ._sync.client.tasks import TasksClient as TasksClient # noqa: F401 -from ._sync.client.text_structure import ( # noqa: F401 - TextStructureClient as TextStructureClient, -) from ._sync.client.transform import TransformClient as TransformClient # noqa: F401 -from ._sync.client.watcher import WatcherClient as WatcherClient # noqa: F401 -from ._sync.client.xpack import XPackClient as XPackClient # noqa: F401 from ._utils import fixup_module_metadata # This file exists for backwards compatibility. @@ -77,39 +51,21 @@ __all__ = [ "AsyncSearchClient", - "AutoscalingClient", "CatClient", - "CcrClient", "ClusterClient", - "DanglingIndicesClient", "Elasticsearch", "EnrichClient", "EqlClient", - "FeaturesClient", - "FleetClient", "GraphClient", - "IlmClient", "IndicesClient", "IngestClient", "LicenseClient", "LogstashClient", - "MigrationClient", "MlClient", - "MonitoringClient", - "NodesClient", - "RollupClient", - "SearchableSnapshotsClient", "SecurityClient", - "ShutdownClient", - "SlmClient", - "SnapshotClient", "SqlClient", - "SslClient", "TasksClient", - "TextStructureClient", "TransformClient", - "WatcherClient", - "XPackClient", ] fixup_module_metadata(__name__, globals())