diff --git a/docs/api.rst b/docs/api.rst index c1b4cc45..aba6c7eb 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -142,3 +142,9 @@ Tasks .. autoclass:: TasksClient :members: + +Dangling Indices +---------------- + +.. autoclass:: DanglingIndicesClient + :members: diff --git a/elasticsearch/_async/client/__init__.py b/elasticsearch/_async/client/__init__.py index 28278e9e..a8f262e2 100644 --- a/elasticsearch/_async/client/__init__.py +++ b/elasticsearch/_async/client/__init__.py @@ -7,23 +7,26 @@ from __future__ import unicode_literals import logging from ..transport import AsyncTransport, TransportError +from .utils import query_params, _make_path, SKIP_IN_PATH, _bulk_body, _normalize_hosts + +from .async_search import AsyncSearchClient +from .autoscaling import AutoscalingClient +from .cat import CatClient +from .cluster import ClusterClient +from .dangling_indices import DanglingIndicesClient from .indices import IndicesClient from .ingest import IngestClient -from .cluster import ClusterClient -from .cat import CatClient from .nodes import NodesClient from .remote import RemoteClient from .snapshot import SnapshotClient from .tasks import TasksClient -from .xpack import XPackClient -from .utils import query_params, _make_path, SKIP_IN_PATH, _bulk_body, _normalize_hosts # xpack APIs -from .async_search import AsyncSearchClient -from .autoscaling import AutoscalingClient +from .xpack import XPackClient from .ccr import CcrClient from .data_frame import Data_FrameClient from .deprecation import DeprecationClient +from .enrich import EnrichClient from .eql import EqlClient from .graph import GraphClient from .ilm import IlmClient @@ -32,14 +35,13 @@ from .migration import MigrationClient from .ml import MlClient from .monitoring import MonitoringClient from .rollup import RollupClient +from .searchable_snapshots import SearchableSnapshotsClient from .security import SecurityClient +from .slm import SlmClient from .sql import SqlClient from .ssl import SslClient -from .watcher import WatcherClient -from .enrich import EnrichClient -from .searchable_snapshots import SearchableSnapshotsClient -from .slm import SlmClient from .transform import TransformClient +from .watcher import WatcherClient logger = logging.getLogger("elasticsearch") @@ -188,21 +190,23 @@ class AsyncElasticsearch(object): self.transport = transport_class(_normalize_hosts(hosts), **kwargs) # namespaced clients for compatibility with API names + self.async_search = AsyncSearchClient(self) + self.autoscaling = AutoscalingClient(self) + self.cat = CatClient(self) + self.cluster = ClusterClient(self) + self.dangling_indices = DanglingIndicesClient(self) self.indices = IndicesClient(self) self.ingest = IngestClient(self) - self.cluster = ClusterClient(self) - self.cat = CatClient(self) self.nodes = NodesClient(self) self.remote = RemoteClient(self) self.snapshot = SnapshotClient(self) self.tasks = TasksClient(self) self.xpack = XPackClient(self) - self.async_search = AsyncSearchClient(self) - self.autoscaling = AutoscalingClient(self) self.ccr = CcrClient(self) self.data_frame = Data_FrameClient(self) self.deprecation = DeprecationClient(self) + self.enrich = EnrichClient(self) self.eql = EqlClient(self) self.graph = GraphClient(self) self.ilm = IlmClient(self) @@ -212,14 +216,13 @@ class AsyncElasticsearch(object): self.ml = MlClient(self) self.monitoring = MonitoringClient(self) self.rollup = RollupClient(self) + self.searchable_snapshots = SearchableSnapshotsClient(self) self.security = SecurityClient(self) + self.slm = SlmClient(self) self.sql = SqlClient(self) self.ssl = SslClient(self) - self.watcher = WatcherClient(self) - self.enrich = EnrichClient(self) - self.searchable_snapshots = SearchableSnapshotsClient(self) - self.slm = SlmClient(self) self.transform = TransformClient(self) + self.watcher = WatcherClient(self) def __repr__(self): try: @@ -908,12 +911,13 @@ class AsyncElasticsearch(object): "ignore_unavailable", "include_unmapped", ) - async def field_caps(self, index=None, params=None, headers=None): + async def field_caps(self, body=None, index=None, params=None, headers=None): """ Returns the information about the capabilities of fields among multiple indices. ``_ + :arg body: An index filter specified with the Query DSL :arg index: A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices :arg allow_no_indices: Whether to ignore if a wildcard indices @@ -929,7 +933,11 @@ class AsyncElasticsearch(object): be included in the response. """ return await self.transport.perform_request( - "GET", _make_path(index, "_field_caps"), params=params, headers=headers + "POST", + _make_path(index, "_field_caps"), + params=params, + headers=headers, + body=body, ) @query_params( diff --git a/elasticsearch/_async/client/dangling_indices.py b/elasticsearch/_async/client/dangling_indices.py new file mode 100644 index 00000000..aabc768b --- /dev/null +++ b/elasticsearch/_async/client/dangling_indices.py @@ -0,0 +1,58 @@ +# Licensed to Elasticsearch B.V under one or more agreements. +# Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +# See the LICENSE file in the project root for more information + +from .utils import NamespacedClient, SKIP_IN_PATH, query_params, _make_path + + +class DanglingIndicesClient(NamespacedClient): + @query_params("accept_data_loss", "master_timeout", "timeout") + async def delete_dangling_index(self, index_uuid, params=None, headers=None): + """ + Deletes the specified dangling index + ``_ + + :arg index_uuid: The UUID of the dangling index + :arg accept_data_loss: Must be set to true in order to delete + the dangling index + :arg master_timeout: Specify timeout for connection to master + :arg timeout: Explicit operation timeout + """ + if index_uuid in SKIP_IN_PATH: + raise ValueError("Empty value passed for a required argument 'index_uuid'.") + + return await self.transport.perform_request( + "DELETE", + _make_path("_dangling", index_uuid), + params=params, + headers=headers, + ) + + @query_params("accept_data_loss", "master_timeout", "timeout") + async def import_dangling_index(self, index_uuid, params=None, headers=None): + """ + Imports the specified dangling index + ``_ + + :arg index_uuid: The UUID of the dangling index + :arg accept_data_loss: Must be set to true in order to import + the dangling index + :arg master_timeout: Specify timeout for connection to master + :arg timeout: Explicit operation timeout + """ + if index_uuid in SKIP_IN_PATH: + raise ValueError("Empty value passed for a required argument 'index_uuid'.") + + return await self.transport.perform_request( + "POST", _make_path("_dangling", index_uuid), params=params, headers=headers + ) + + @query_params() + async def list_dangling_indices(self, params=None, headers=None): + """ + Returns all dangling indices. + ``_ + """ + return await self.transport.perform_request( + "GET", "/_dangling", params=params, headers=headers + ) diff --git a/elasticsearch/_async/client/indices.py b/elasticsearch/_async/client/indices.py index 14f64131..c60253d9 100644 --- a/elasticsearch/_async/client/indices.py +++ b/elasticsearch/_async/client/indices.py @@ -1460,3 +1460,22 @@ class IndicesClient(NamespacedClient): headers=headers, body=body, ) + + @query_params("expand_wildcards") + async def resolve_index(self, name, params=None, headers=None): + """ + Returns information about any matching indices, aliases, and data streams + ``_ + + :arg name: A comma-separated list of names or wildcard + expressions + :arg expand_wildcards: Whether wildcard expressions should get + expanded to open or closed indices (default: open) Valid choices: open, + closed, hidden, none, all Default: open + """ + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for a required argument 'name'.") + + return await self.transport.perform_request( + "GET", _make_path("_resolve", "index", name), params=params, headers=headers + ) diff --git a/elasticsearch/_async/client/ml.py b/elasticsearch/_async/client/ml.py index 7837a51f..29fb3f40 100644 --- a/elasticsearch/_async/client/ml.py +++ b/elasticsearch/_async/client/ml.py @@ -116,17 +116,25 @@ class MlClient(NamespacedClient): headers=headers, ) - @query_params() - async def delete_expired_data(self, body=None, params=None, headers=None): + @query_params("requests_per_second", "timeout") + async def delete_expired_data( + self, body=None, job_id=None, params=None, headers=None + ): """ Deletes expired and unused machine learning data. ``_ :arg body: deleting expired data parameters + :arg job_id: The ID of the job(s) to perform expired data + hygiene for + :arg requests_per_second: The desired requests per second for + the deletion processes. + :arg timeout: How long can the underlying delete processes run + until they are canceled """ return await self.transport.perform_request( "DELETE", - "/_ml/_delete_expired_data", + _make_path("_ml", "_delete_expired_data", job_id), params=params, headers=headers, body=body, @@ -446,7 +454,7 @@ class MlClient(NamespacedClient): body=body, ) - @query_params("from_", "size") + @query_params("from_", "partition_field_value", "size") async def get_categories( self, job_id, body=None, category_id=None, params=None, headers=None ): @@ -459,6 +467,9 @@ class MlClient(NamespacedClient): :arg category_id: The identifier of the category definition of interest :arg from_: skips a number of categories + :arg partition_field_value: Specifies the partition to retrieve + categories for. This is optional, and should never be used for jobs + where per-partition categorization is disabled. :arg size: specifies a max number of categories to get """ # from is a reserved word so it cannot be used, use from_ instead @@ -1197,7 +1208,7 @@ class MlClient(NamespacedClient): body=body, ) - @query_params("force") + @query_params("force", "timeout") async def delete_data_frame_analytics(self, id, params=None, headers=None): """ Deletes an existing data frame analytics job. @@ -1205,6 +1216,8 @@ class MlClient(NamespacedClient): :arg id: The ID of the data frame analytics to delete :arg force: True if the job should be forcefully deleted + :arg timeout: Controls the time to wait until a job is deleted. + Defaults to 1 minute """ if id in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'id'.") diff --git a/elasticsearch/client/__init__.py b/elasticsearch/client/__init__.py index 3a1e2e99..6e40d2c0 100644 --- a/elasticsearch/client/__init__.py +++ b/elasticsearch/client/__init__.py @@ -7,23 +7,26 @@ from __future__ import unicode_literals import logging from ..transport import Transport, TransportError +from .utils import query_params, _make_path, SKIP_IN_PATH, _bulk_body, _normalize_hosts + +from .async_search import AsyncSearchClient +from .autoscaling import AutoscalingClient +from .cat import CatClient +from .cluster import ClusterClient +from .dangling_indices import DanglingIndicesClient from .indices import IndicesClient from .ingest import IngestClient -from .cluster import ClusterClient -from .cat import CatClient from .nodes import NodesClient from .remote import RemoteClient from .snapshot import SnapshotClient from .tasks import TasksClient -from .xpack import XPackClient -from .utils import query_params, _make_path, SKIP_IN_PATH, _bulk_body, _normalize_hosts # xpack APIs -from .async_search import AsyncSearchClient -from .autoscaling import AutoscalingClient +from .xpack import XPackClient from .ccr import CcrClient from .data_frame import Data_FrameClient from .deprecation import DeprecationClient +from .enrich import EnrichClient from .eql import EqlClient from .graph import GraphClient from .ilm import IlmClient @@ -32,14 +35,13 @@ from .migration import MigrationClient from .ml import MlClient from .monitoring import MonitoringClient from .rollup import RollupClient +from .searchable_snapshots import SearchableSnapshotsClient from .security import SecurityClient +from .slm import SlmClient from .sql import SqlClient from .ssl import SslClient -from .watcher import WatcherClient -from .enrich import EnrichClient -from .searchable_snapshots import SearchableSnapshotsClient -from .slm import SlmClient from .transform import TransformClient +from .watcher import WatcherClient logger = logging.getLogger("elasticsearch") @@ -188,21 +190,23 @@ class Elasticsearch(object): self.transport = transport_class(_normalize_hosts(hosts), **kwargs) # namespaced clients for compatibility with API names + self.async_search = AsyncSearchClient(self) + self.autoscaling = AutoscalingClient(self) + self.cat = CatClient(self) + self.cluster = ClusterClient(self) + self.dangling_indices = DanglingIndicesClient(self) self.indices = IndicesClient(self) self.ingest = IngestClient(self) - self.cluster = ClusterClient(self) - self.cat = CatClient(self) self.nodes = NodesClient(self) self.remote = RemoteClient(self) self.snapshot = SnapshotClient(self) self.tasks = TasksClient(self) self.xpack = XPackClient(self) - self.async_search = AsyncSearchClient(self) - self.autoscaling = AutoscalingClient(self) self.ccr = CcrClient(self) self.data_frame = Data_FrameClient(self) self.deprecation = DeprecationClient(self) + self.enrich = EnrichClient(self) self.eql = EqlClient(self) self.graph = GraphClient(self) self.ilm = IlmClient(self) @@ -212,14 +216,13 @@ class Elasticsearch(object): self.ml = MlClient(self) self.monitoring = MonitoringClient(self) self.rollup = RollupClient(self) + self.searchable_snapshots = SearchableSnapshotsClient(self) self.security = SecurityClient(self) + self.slm = SlmClient(self) self.sql = SqlClient(self) self.ssl = SslClient(self) - self.watcher = WatcherClient(self) - self.enrich = EnrichClient(self) - self.searchable_snapshots = SearchableSnapshotsClient(self) - self.slm = SlmClient(self) self.transform = TransformClient(self) + self.watcher = WatcherClient(self) def __repr__(self): try: @@ -900,12 +903,13 @@ class Elasticsearch(object): "ignore_unavailable", "include_unmapped", ) - def field_caps(self, index=None, params=None, headers=None): + def field_caps(self, body=None, index=None, params=None, headers=None): """ Returns the information about the capabilities of fields among multiple indices. ``_ + :arg body: An index filter specified with the Query DSL :arg index: A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices :arg allow_no_indices: Whether to ignore if a wildcard indices @@ -921,7 +925,11 @@ class Elasticsearch(object): be included in the response. """ return self.transport.perform_request( - "GET", _make_path(index, "_field_caps"), params=params, headers=headers + "POST", + _make_path(index, "_field_caps"), + params=params, + headers=headers, + body=body, ) @query_params( diff --git a/elasticsearch/client/dangling_indices.py b/elasticsearch/client/dangling_indices.py new file mode 100644 index 00000000..8fc2dfe3 --- /dev/null +++ b/elasticsearch/client/dangling_indices.py @@ -0,0 +1,58 @@ +# Licensed to Elasticsearch B.V under one or more agreements. +# Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +# See the LICENSE file in the project root for more information + +from .utils import NamespacedClient, SKIP_IN_PATH, query_params, _make_path + + +class DanglingIndicesClient(NamespacedClient): + @query_params("accept_data_loss", "master_timeout", "timeout") + def delete_dangling_index(self, index_uuid, params=None, headers=None): + """ + Deletes the specified dangling index + ``_ + + :arg index_uuid: The UUID of the dangling index + :arg accept_data_loss: Must be set to true in order to delete + the dangling index + :arg master_timeout: Specify timeout for connection to master + :arg timeout: Explicit operation timeout + """ + if index_uuid in SKIP_IN_PATH: + raise ValueError("Empty value passed for a required argument 'index_uuid'.") + + return self.transport.perform_request( + "DELETE", + _make_path("_dangling", index_uuid), + params=params, + headers=headers, + ) + + @query_params("accept_data_loss", "master_timeout", "timeout") + def import_dangling_index(self, index_uuid, params=None, headers=None): + """ + Imports the specified dangling index + ``_ + + :arg index_uuid: The UUID of the dangling index + :arg accept_data_loss: Must be set to true in order to import + the dangling index + :arg master_timeout: Specify timeout for connection to master + :arg timeout: Explicit operation timeout + """ + if index_uuid in SKIP_IN_PATH: + raise ValueError("Empty value passed for a required argument 'index_uuid'.") + + return self.transport.perform_request( + "POST", _make_path("_dangling", index_uuid), params=params, headers=headers + ) + + @query_params() + def list_dangling_indices(self, params=None, headers=None): + """ + Returns all dangling indices. + ``_ + """ + return self.transport.perform_request( + "GET", "/_dangling", params=params, headers=headers + ) diff --git a/elasticsearch/client/indices.py b/elasticsearch/client/indices.py index 83642903..b4fc6ed8 100644 --- a/elasticsearch/client/indices.py +++ b/elasticsearch/client/indices.py @@ -1456,3 +1456,22 @@ class IndicesClient(NamespacedClient): headers=headers, body=body, ) + + @query_params("expand_wildcards") + def resolve_index(self, name, params=None, headers=None): + """ + Returns information about any matching indices, aliases, and data streams + ``_ + + :arg name: A comma-separated list of names or wildcard + expressions + :arg expand_wildcards: Whether wildcard expressions should get + expanded to open or closed indices (default: open) Valid choices: open, + closed, hidden, none, all Default: open + """ + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for a required argument 'name'.") + + return self.transport.perform_request( + "GET", _make_path("_resolve", "index", name), params=params, headers=headers + ) diff --git a/elasticsearch/client/ml.py b/elasticsearch/client/ml.py index 192261e7..7a5410b4 100644 --- a/elasticsearch/client/ml.py +++ b/elasticsearch/client/ml.py @@ -114,17 +114,23 @@ class MlClient(NamespacedClient): headers=headers, ) - @query_params() - def delete_expired_data(self, body=None, params=None, headers=None): + @query_params("requests_per_second", "timeout") + def delete_expired_data(self, body=None, job_id=None, params=None, headers=None): """ Deletes expired and unused machine learning data. ``_ :arg body: deleting expired data parameters + :arg job_id: The ID of the job(s) to perform expired data + hygiene for + :arg requests_per_second: The desired requests per second for + the deletion processes. + :arg timeout: How long can the underlying delete processes run + until they are canceled """ return self.transport.perform_request( "DELETE", - "/_ml/_delete_expired_data", + _make_path("_ml", "_delete_expired_data", job_id), params=params, headers=headers, body=body, @@ -436,7 +442,7 @@ class MlClient(NamespacedClient): body=body, ) - @query_params("from_", "size") + @query_params("from_", "partition_field_value", "size") def get_categories( self, job_id, body=None, category_id=None, params=None, headers=None ): @@ -449,6 +455,9 @@ class MlClient(NamespacedClient): :arg category_id: The identifier of the category definition of interest :arg from_: skips a number of categories + :arg partition_field_value: Specifies the partition to retrieve + categories for. This is optional, and should never be used for jobs + where per-partition categorization is disabled. :arg size: specifies a max number of categories to get """ # from is a reserved word so it cannot be used, use from_ instead @@ -1187,7 +1196,7 @@ class MlClient(NamespacedClient): body=body, ) - @query_params("force") + @query_params("force", "timeout") def delete_data_frame_analytics(self, id, params=None, headers=None): """ Deletes an existing data frame analytics job. @@ -1195,6 +1204,8 @@ class MlClient(NamespacedClient): :arg id: The ID of the data frame analytics to delete :arg force: True if the job should be forcefully deleted + :arg timeout: Controls the time to wait until a job is deleted. + Defaults to 1 minute """ if id in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'id'.")