[7.x] Add Dangling Indices API

This commit is contained in:
Seth Michael Larson
2020-06-23 15:34:31 -05:00
committed by GitHub
parent cb3d1a8234
commit d73d7a0d8f
9 changed files with 250 additions and 50 deletions
+6
View File
@@ -142,3 +142,9 @@ Tasks
.. autoclass:: TasksClient
:members:
Dangling Indices
----------------
.. autoclass:: DanglingIndicesClient
:members:
+28 -20
View File
@@ -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.
`<https://www.elastic.co/guide/en/elasticsearch/reference/7.x/search-field-caps.html>`_
: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(
@@ -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
`<https://www.elastic.co/guide/en/elasticsearch/reference/7.x/modules-gateway-dangling-indices.html>`_
: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
`<https://www.elastic.co/guide/en/elasticsearch/reference/7.x/modules-gateway-dangling-indices.html>`_
: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.
`<https://www.elastic.co/guide/en/elasticsearch/reference/7.x/modules-gateway-dangling-indices.html>`_
"""
return await self.transport.perform_request(
"GET", "/_dangling", params=params, headers=headers
)
+19
View File
@@ -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
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-resolve-index.html>`_
: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
)
+18 -5
View File
@@ -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.
`<https://www.elastic.co/guide/en/elasticsearch/reference/7.x/ml-delete-expired-data.html>`_
: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'.")
+28 -20
View File
@@ -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.
`<https://www.elastic.co/guide/en/elasticsearch/reference/7.x/search-field-caps.html>`_
: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(
+58
View File
@@ -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
`<https://www.elastic.co/guide/en/elasticsearch/reference/7.x/modules-gateway-dangling-indices.html>`_
: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
`<https://www.elastic.co/guide/en/elasticsearch/reference/7.x/modules-gateway-dangling-indices.html>`_
: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.
`<https://www.elastic.co/guide/en/elasticsearch/reference/7.x/modules-gateway-dangling-indices.html>`_
"""
return self.transport.perform_request(
"GET", "/_dangling", params=params, headers=headers
)
+19
View File
@@ -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
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-resolve-index.html>`_
: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
)
+16 -5
View File
@@ -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.
`<https://www.elastic.co/guide/en/elasticsearch/reference/7.x/ml-delete-expired-data.html>`_
: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'.")