From f8b005f62e377407695d3fb009df55b324db8e28 Mon Sep 17 00:00:00 2001 From: Seth Michael Larson Date: Tue, 19 May 2020 12:59:40 -0500 Subject: [PATCH] Update 7.x REST APIs --- elasticsearch/__init__.py | 4 +-- elasticsearch/client/__init__.py | 12 ------- elasticsearch/client/cluster.py | 8 ++--- elasticsearch/client/indices.py | 61 ++++++++++++++++++++------------ elasticsearch/client/ml.py | 12 +++++-- elasticsearch/client/snapshot.py | 2 +- setup.py | 4 +-- 7 files changed, 57 insertions(+), 46 deletions(-) diff --git a/elasticsearch/__init__.py b/elasticsearch/__init__.py index cf5b580a..d681ff97 100644 --- a/elasticsearch/__init__.py +++ b/elasticsearch/__init__.py @@ -5,9 +5,9 @@ # flake8: noqa from __future__ import absolute_import -VERSION = (7, 8, 0) +VERSION = (7, 9, 0) __version__ = VERSION -__versionstr__ = "7.8.0" +__versionstr__ = "7.9.0a1" import logging import warnings diff --git a/elasticsearch/client/__init__.py b/elasticsearch/client/__init__.py index 9d581ab8..98744ecc 100644 --- a/elasticsearch/client/__init__.py +++ b/elasticsearch/client/__init__.py @@ -306,7 +306,6 @@ class Elasticsearch(object): @query_params( "pipeline", - "prefer_v2_templates", "refresh", "routing", "timeout", @@ -326,8 +325,6 @@ class Elasticsearch(object): :arg doc_type: The type of the document :arg pipeline: The pipeline id to preprocess incoming documents with - :arg prefer_v2_templates: favor V2 templates instead of V1 - templates during automatic index creation :arg refresh: If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then @@ -363,7 +360,6 @@ class Elasticsearch(object): "if_seq_no", "op_type", "pipeline", - "prefer_v2_templates", "refresh", "routing", "timeout", @@ -391,8 +387,6 @@ class Elasticsearch(object): without an explicit document ID Valid choices: index, create :arg pipeline: The pipeline id to preprocess incoming documents with - :arg prefer_v2_templates: favor V2 templates instead of V1 - templates during automatic index creation :arg refresh: If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then @@ -428,7 +422,6 @@ class Elasticsearch(object): "_source_excludes", "_source_includes", "pipeline", - "prefer_v2_templates", "refresh", "routing", "timeout", @@ -453,8 +446,6 @@ class Elasticsearch(object): return from the _source field, can be overridden on each sub-request :arg pipeline: The pipeline id to preprocess incoming documents with - :arg prefer_v2_templates: favor V2 templates instead of V1 - templates during automatic index creation :arg refresh: If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then @@ -1812,7 +1803,6 @@ class Elasticsearch(object): "if_primary_term", "if_seq_no", "lang", - "prefer_v2_templates", "refresh", "retry_on_conflict", "routing", @@ -1842,8 +1832,6 @@ class Elasticsearch(object): operation that has changed the document has the specified sequence number :arg lang: The script language (default: painless) - :arg prefer_v2_templates: favor V2 templates instead of V1 - templates during automatic index creation :arg refresh: If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then diff --git a/elasticsearch/client/cluster.py b/elasticsearch/client/cluster.py index be661e7f..bb69e014 100644 --- a/elasticsearch/client/cluster.py +++ b/elasticsearch/client/cluster.py @@ -243,7 +243,7 @@ class ClusterClient(NamespacedClient): def delete_component_template(self, name, params=None, headers=None): """ Deletes a component template - ``_ + ``_ :arg name: The name of the template :arg master_timeout: Specify timeout for connection to master @@ -263,7 +263,7 @@ class ClusterClient(NamespacedClient): def get_component_template(self, name=None, params=None, headers=None): """ Returns one or more component templates - ``_ + ``_ :arg name: The comma separated names of the component templates :arg local: Return local information, do not retrieve the state @@ -282,7 +282,7 @@ class ClusterClient(NamespacedClient): def put_component_template(self, name, body, params=None, headers=None): """ Creates or updates a component template - ``_ + ``_ :arg name: The name of the template :arg body: The template definition @@ -307,7 +307,7 @@ class ClusterClient(NamespacedClient): def exists_component_template(self, name, params=None, headers=None): """ Returns information about whether a particular component template exist - ``_ + ``_ :arg name: The name of the template :arg local: Return local information, do not retrieve the state diff --git a/elasticsearch/client/indices.py b/elasticsearch/client/indices.py index 0dbd64e9..2d426b93 100644 --- a/elasticsearch/client/indices.py +++ b/elasticsearch/client/indices.py @@ -83,11 +83,7 @@ class IndicesClient(NamespacedClient): ) @query_params( - "include_type_name", - "master_timeout", - "prefer_v2_templates", - "timeout", - "wait_for_active_shards", + "include_type_name", "master_timeout", "timeout", "wait_for_active_shards" ) def create(self, index, body=None, params=None, headers=None): """ @@ -100,8 +96,6 @@ class IndicesClient(NamespacedClient): :arg include_type_name: Whether a type should be expected in the body of the mappings. :arg master_timeout: Specify timeout for connection to master - :arg prefer_v2_templates: favor V2 templates instead of V1 - templates during index creation :arg timeout: Explicit operation timeout :arg wait_for_active_shards: Set the number of active shards to wait for before the operation returns. @@ -1145,7 +1139,6 @@ class IndicesClient(NamespacedClient): "dry_run", "include_type_name", "master_timeout", - "prefer_v2_templates", "timeout", "wait_for_active_shards", ) @@ -1165,8 +1158,6 @@ class IndicesClient(NamespacedClient): :arg include_type_name: Whether a type should be included in the body of the mappings. :arg master_timeout: Specify timeout for connection to master - :arg prefer_v2_templates: favor V2 templates instead of V1 - templates during automatic index creation :arg timeout: Explicit operation timeout :arg wait_for_active_shards: Set the number of active shards to wait for on the newly created rollover index before the operation @@ -1316,19 +1307,6 @@ class IndicesClient(NamespacedClient): "DELETE", _make_path("_data_stream", name), params=params, headers=headers ) - @query_params() - def get_data_streams(self, name=None, params=None, headers=None): - """ - Returns data streams. - ``_ - - :arg name: The name or wildcard expression of the requested data - streams - """ - return self.transport.perform_request( - "GET", _make_path("_data_streams", name), params=params, headers=headers - ) - @query_params("master_timeout", "timeout") def delete_index_template(self, name, params=None, headers=None): """ @@ -1442,3 +1420,40 @@ class IndicesClient(NamespacedClient): headers=headers, body=body, ) + + @query_params() + def get_data_stream(self, name=None, params=None, headers=None): + """ + Returns data streams. + ``_ + + :arg name: The name or wildcard expression of the requested data + streams + """ + return self.transport.perform_request( + "GET", _make_path("_data_stream", name), params=params, headers=headers + ) + + @query_params("cause", "create", "master_timeout") + def simulate_template(self, body=None, name=None, params=None, headers=None): + """ + Simulate resolving the given template name or body + ``_ + + :arg body: New index template definition to be simulated, if no + index template name is specified + :arg name: The name of the index template + :arg cause: User defined reason for dry-run creating the new + template for simulation purposes + :arg create: Whether the index template we optionally defined in + the body should only be dry-run added if new or can also replace an + existing one + :arg master_timeout: Specify timeout for connection to master + """ + return self.transport.perform_request( + "POST", + _make_path("_index_template", "_simulate", name), + params=params, + headers=headers, + body=body, + ) diff --git a/elasticsearch/client/ml.py b/elasticsearch/client/ml.py index e3e2919b..6f5341e4 100644 --- a/elasticsearch/client/ml.py +++ b/elasticsearch/client/ml.py @@ -115,13 +115,19 @@ class MlClient(NamespacedClient): ) @query_params() - def delete_expired_data(self, params=None, headers=None): + def delete_expired_data(self, body=None, params=None, headers=None): """ Deletes expired and unused machine learning data. ``_ + + :arg body: deleting expired data parameters """ return self.transport.perform_request( - "DELETE", "/_ml/_delete_expired_data", params=params, headers=headers + "DELETE", + "/_ml/_delete_expired_data", + params=params, + headers=headers, + body=body, ) @query_params() @@ -1145,6 +1151,7 @@ class MlClient(NamespacedClient): def validate(self, body, params=None, headers=None): """ Validates an anomaly detection job. + ``_ :arg body: The job config """ @@ -1163,6 +1170,7 @@ class MlClient(NamespacedClient): def validate_detector(self, body, params=None, headers=None): """ Validates an anomaly detection detector. + ``_ :arg body: The detector """ diff --git a/elasticsearch/client/snapshot.py b/elasticsearch/client/snapshot.py index 40f81b2b..d4d71e0b 100644 --- a/elasticsearch/client/snapshot.py +++ b/elasticsearch/client/snapshot.py @@ -215,7 +215,7 @@ class SnapshotClient(NamespacedClient): def cleanup_repository(self, repository, params=None, headers=None): """ Removes stale data from repository. - ``_ + ``_ :arg repository: A repository name :arg master_timeout: Explicit operation timeout for connection diff --git a/setup.py b/setup.py index 0a684aed..08e79678 100644 --- a/setup.py +++ b/setup.py @@ -6,9 +6,9 @@ from os.path import join, dirname from setuptools import setup, find_packages -VERSION = (7, 7, 0) +VERSION = (7, 9, 0) __version__ = VERSION -__versionstr__ = "7.7.0a2" +__versionstr__ = "7.9.0a1" with open(join(dirname(__file__), "README")) as f: long_description = f.read().strip()