From 883287551ab37f8197e6a02459c647cb08f9ba84 Mon Sep 17 00:00:00 2001 From: Seth Michael Larson Date: Fri, 13 Mar 2020 13:44:46 -0500 Subject: [PATCH] Update supported ES API to 7.6 --- elasticsearch/client/__init__.py | 75 ++++-- elasticsearch/client/cat.py | 6 +- elasticsearch/client/ccr.py | 4 +- elasticsearch/client/cluster.py | 2 +- elasticsearch/client/enrich.py | 2 +- elasticsearch/client/graph.py | 2 +- elasticsearch/client/indices.py | 7 +- elasticsearch/client/ingest.py | 2 +- elasticsearch/client/license.py | 4 +- elasticsearch/client/migration.py | 2 +- elasticsearch/client/ml.py | 221 +++++++++++++----- elasticsearch/client/monitoring.py | 2 +- elasticsearch/client/rollup.py | 2 +- elasticsearch/client/security.py | 4 +- elasticsearch/client/slm.py | 16 +- elasticsearch/client/sql.py | 3 - elasticsearch/client/transform.py | 12 +- elasticsearch/client/watcher.py | 16 +- elasticsearch/client/xpack.py | 2 +- test_elasticsearch/test_client/__init__.py | 2 +- test_elasticsearch/test_server/test_common.py | 3 - utils/generate_api.py | 26 ++- 22 files changed, 285 insertions(+), 130 deletions(-) diff --git a/elasticsearch/client/__init__.py b/elasticsearch/client/__init__.py index 43239f6e..7b4568ed 100644 --- a/elasticsearch/client/__init__.py +++ b/elasticsearch/client/__init__.py @@ -438,7 +438,7 @@ class Elasticsearch(object): provide one :arg pipeline: The pipeline id to preprocess incoming documents with - :arg refresh: If `true` then refresh the effected shards to make + :arg refresh: If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. Valid choices: true, false, wait_for @@ -570,7 +570,7 @@ class Elasticsearch(object): :arg if_seq_no: only perform the delete operation if the last operation that has changed the document has the specified sequence number - :arg refresh: If `true` then refresh the effected shards to make + :arg refresh: If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. Valid choices: true, false, wait_for @@ -602,6 +602,7 @@ class Elasticsearch(object): "_source_includes", "allow_no_indices", "analyze_wildcard", + "analyzer", "conflicts", "default_operator", "df", @@ -651,6 +652,7 @@ class Elasticsearch(object): string or when no indices have been specified) :arg analyze_wildcard: Specify whether wildcard and prefix queries should be analyzed (default: false) + :arg analyzer: The analyzer to use for the query string :arg conflicts: What to do when the delete by query hits version conflicts? Valid choices: abort, proceed Default: abort :arg default_operator: The default operator for query string @@ -913,7 +915,7 @@ class Elasticsearch(object): doc_type = "_doc" return self.transport.perform_request( - "GET", + "POST", _make_path(index, doc_type, id, "_explain"), params=params, headers=headers, @@ -1109,7 +1111,7 @@ class Elasticsearch(object): raise ValueError("Empty value passed for a required argument 'body'.") return self.transport.perform_request( - "GET", + "POST", _make_path(index, doc_type, "_mget"), params=params, headers=headers, @@ -1165,7 +1167,7 @@ class Elasticsearch(object): body = _bulk_body(self.transport.serializer, body) return self.transport.perform_request( - "GET", + "POST", _make_path(index, doc_type, "_msearch"), params=params, headers=headers, @@ -1173,7 +1175,11 @@ class Elasticsearch(object): ) @query_params( - "max_concurrent_searches", "rest_total_hits_as_int", "search_type", "typed_keys" + "ccs_minimize_roundtrips", + "max_concurrent_searches", + "rest_total_hits_as_int", + "search_type", + "typed_keys", ) def msearch_template( self, body, index=None, doc_type=None, params=None, headers=None @@ -1188,6 +1194,9 @@ class Elasticsearch(object): default :arg doc_type: A comma-separated list of document types to use as default + :arg ccs_minimize_roundtrips: Indicates whether network round- + trips should be minimized as part of cross-cluster search requests + execution Default: true :arg max_concurrent_searches: Controls the maximum number of concurrent searches the multi search api will execute :arg rest_total_hits_as_int: Indicates whether hits.total should @@ -1203,7 +1212,7 @@ class Elasticsearch(object): body = _bulk_body(self.transport.serializer, body) return self.transport.perform_request( - "GET", + "POST", _make_path(index, doc_type, "_msearch", "template"), params=params, headers=headers, @@ -1269,7 +1278,7 @@ class Elasticsearch(object): internal, external, external_gte, force """ return self.transport.perform_request( - "GET", + "POST", _make_path(index, doc_type, "_mtermvectors"), params=params, headers=headers, @@ -1301,7 +1310,9 @@ class Elasticsearch(object): body=body, ) - @query_params("allow_no_indices", "expand_wildcards", "ignore_unavailable") + @query_params( + "allow_no_indices", "expand_wildcards", "ignore_unavailable", "search_type" + ) def rank_eval(self, body, index=None, params=None, headers=None): """ Allows to evaluate the quality of ranked search results over a set of typical @@ -1320,12 +1331,14 @@ class Elasticsearch(object): closed, none, all Default: open :arg ignore_unavailable: Whether specified concrete indices should be ignored when unavailable (missing or closed) + :arg search_type: Search operation type Valid choices: + query_then_fetch, dfs_query_then_fetch """ if body in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'body'.") return self.transport.perform_request( - "GET", + "POST", _make_path(index, "_rank_eval"), params=params, headers=headers, @@ -1353,7 +1366,7 @@ class Elasticsearch(object): prototype for the index request. :arg max_docs: Maximum number of documents to process (default: all documents) - :arg refresh: Should the effected indexes be refreshed? + :arg refresh: Should the affected indexes be refreshed? :arg requests_per_second: The throttle to set on this request in sub-requests per second. -1 means no throttle. :arg scroll: Control how long to keep the search context alive @@ -1408,7 +1421,7 @@ class Elasticsearch(object): :arg id: The id of the stored search template """ return self.transport.perform_request( - "GET", + "POST", _make_path("_render", "template", id), params=params, headers=headers, @@ -1424,7 +1437,7 @@ class Elasticsearch(object): :arg body: The script to execute """ return self.transport.perform_request( - "GET", + "POST", "/_scripts/painless/_execute", params=params, headers=headers, @@ -1454,7 +1467,7 @@ class Elasticsearch(object): params["scroll_id"] = scroll_id return self.transport.perform_request( - "GET", "/_search/scroll", params=params, headers=headers, body=body + "POST", "/_search/scroll", params=params, headers=headers, body=body ) @query_params( @@ -1607,7 +1620,7 @@ class Elasticsearch(object): params["from"] = params.pop("from_") return self.transport.perform_request( - "GET", + "POST", _make_path(index, doc_type, "_search"), params=params, headers=headers, @@ -1650,6 +1663,7 @@ class Elasticsearch(object): @query_params( "allow_no_indices", + "ccs_minimize_roundtrips", "expand_wildcards", "explain", "ignore_throttled", @@ -1677,6 +1691,9 @@ class Elasticsearch(object): :arg allow_no_indices: Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + :arg ccs_minimize_roundtrips: Indicates whether network round- + trips should be minimized as part of cross-cluster search requests + execution Default: true :arg expand_wildcards: Whether to expand wildcard expression to concrete indices that are open, closed or both. Valid choices: open, closed, none, all Default: open @@ -1704,7 +1721,7 @@ class Elasticsearch(object): raise ValueError("Empty value passed for a required argument 'body'.") return self.transport.perform_request( - "GET", + "POST", _make_path(index, doc_type, "_search", "template"), params=params, headers=headers, @@ -1766,7 +1783,7 @@ class Elasticsearch(object): doc_type = "_doc" return self.transport.perform_request( - "GET", + "POST", _make_path(index, doc_type, id, "_termvectors"), params=params, headers=headers, @@ -1809,7 +1826,7 @@ class Elasticsearch(object): operation that has changed the document has the specified sequence number :arg lang: The script language (default: painless) - :arg refresh: If `true` then refresh the effected shards to make + :arg refresh: If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. Valid choices: true, false, wait_for @@ -1921,7 +1938,7 @@ class Elasticsearch(object): :arg preference: Specify the node or shard the operation should be performed on (default: random) :arg q: Query in the Lucene query string syntax - :arg refresh: Should the effected indexes be refreshed? + :arg refresh: Should the affected indexes be refreshed? :arg request_cache: Specify if request cache should be used for this request or not, defaults to index level setting :arg requests_per_second: The throttle to set on this request in @@ -1995,3 +2012,23 @@ class Elasticsearch(object): params=params, headers=headers, ) + + @query_params() + def get_script_context(self, params=None, headers=None): + """ + Returns all script contexts. + + """ + return self.transport.perform_request( + "GET", "/_script_context", params=params, headers=headers + ) + + @query_params() + def get_script_languages(self, params=None, headers=None): + """ + Returns available script types, languages and contexts + + """ + return self.transport.perform_request( + "GET", "/_script_language", params=params, headers=headers + ) diff --git a/elasticsearch/client/cat.py b/elasticsearch/client/cat.py index 81a3fc2c..6c4ae760 100644 --- a/elasticsearch/client/cat.py +++ b/elasticsearch/client/cat.py @@ -134,7 +134,7 @@ class CatClient(NamespacedClient): :arg index: A comma-separated list of index names to limit the returned information :arg bytes: The unit in which to display byte values Valid - choices: b, k, m, g + choices: b, k, kb, m, mb, g, gb, t, tb, p, pb :arg format: a short version of the Accept header, e.g. json, yaml :arg h: Comma-separated list of column names to display @@ -208,8 +208,8 @@ class CatClient(NamespacedClient): version (default: false) :arg h: Comma-separated list of column names to display :arg help: Return help information - :arg local: Return local information, do not retrieve the state - from master node (default: false) + :arg local: Calculate the selected nodes using the local cluster + state rather than the state from master node (default: false) :arg master_timeout: Explicit operation timeout for connection to master node :arg s: Comma-separated list of column names or column aliases diff --git a/elasticsearch/client/ccr.py b/elasticsearch/client/ccr.py index 1f7cc29b..4f44c6e3 100644 --- a/elasticsearch/client/ccr.py +++ b/elasticsearch/client/ccr.py @@ -78,7 +78,7 @@ class CcrClient(NamespacedClient): @query_params() def forget_follower(self, index, body, params=None, headers=None): """ - ``_ + ``_ :arg index: the name of the leader index for which specified follower retention leases should be removed @@ -184,7 +184,7 @@ class CcrClient(NamespacedClient): @query_params() def unfollow(self, index, params=None, headers=None): """ - ``_ + ``_ :arg index: The name of the follower index that should be turned into a regular index. diff --git a/elasticsearch/client/cluster.py b/elasticsearch/client/cluster.py index 285201a7..4cbcddc7 100644 --- a/elasticsearch/client/cluster.py +++ b/elasticsearch/client/cluster.py @@ -229,7 +229,7 @@ class ClusterClient(NamespacedClient): explanation (default: false) """ return self.transport.perform_request( - "GET", + "POST", "/_cluster/allocation/explain", params=params, headers=headers, diff --git a/elasticsearch/client/enrich.py b/elasticsearch/client/enrich.py index 2f38adb3..48f30902 100644 --- a/elasticsearch/client/enrich.py +++ b/elasticsearch/client/enrich.py @@ -43,7 +43,7 @@ class EnrichClient(NamespacedClient): """ ``_ - :arg name: The name of the enrich policy + :arg name: A comma-separated list of enrich policy names """ return self.transport.perform_request( "GET", _make_path("_enrich", "policy", name), params=params, headers=headers diff --git a/elasticsearch/client/graph.py b/elasticsearch/client/graph.py index 4f5bce45..526d1d27 100644 --- a/elasticsearch/client/graph.py +++ b/elasticsearch/client/graph.py @@ -19,7 +19,7 @@ class GraphClient(NamespacedClient): raise ValueError("Empty value passed for a required argument 'index'.") return self.transport.perform_request( - "GET", + "POST", _make_path(index, doc_type, "_graph", "explore"), params=params, headers=headers, diff --git a/elasticsearch/client/indices.py b/elasticsearch/client/indices.py index b6518bff..4e42e6da 100644 --- a/elasticsearch/client/indices.py +++ b/elasticsearch/client/indices.py @@ -15,7 +15,7 @@ class IndicesClient(NamespacedClient): :arg index: The name of the index to scope the operation """ return self.transport.perform_request( - "GET", + "POST", _make_path(index, "_analyze"), params=params, headers=headers, @@ -884,7 +884,7 @@ class IndicesClient(NamespacedClient): actual Lucene query that will be executed. """ return self.transport.perform_request( - "GET", + "POST", _make_path(index, doc_type, "_validate", "query"), params=params, headers=headers, @@ -999,7 +999,8 @@ class IndicesClient(NamespacedClient): @query_params("allow_no_indices", "expand_wildcards", "ignore_unavailable") def flush_synced(self, index=None, params=None, headers=None): """ - Performs a synced flush operation on one or more indices. + Performs a synced flush operation on one or more indices. Synced flush is + deprecated and will be removed in 8.0. Use flush instead ``_ :arg index: A comma-separated list of index names; use `_all` or diff --git a/elasticsearch/client/ingest.py b/elasticsearch/client/ingest.py index 09ad3efa..50bd8831 100644 --- a/elasticsearch/client/ingest.py +++ b/elasticsearch/client/ingest.py @@ -77,7 +77,7 @@ class IngestClient(NamespacedClient): raise ValueError("Empty value passed for a required argument 'body'.") return self.transport.perform_request( - "GET", + "POST", _make_path("_ingest", "pipeline", id, "_simulate"), params=params, headers=headers, diff --git a/elasticsearch/client/license.py b/elasticsearch/client/license.py index 0b33f0c8..dc2d52fe 100644 --- a/elasticsearch/client/license.py +++ b/elasticsearch/client/license.py @@ -12,11 +12,13 @@ class LicenseClient(NamespacedClient): "DELETE", "/_license", params=params, headers=headers ) - @query_params("local") + @query_params("accept_enterprise", "local") def get(self, params=None, headers=None): """ ``_ + :arg accept_enterprise: If the active license is an enterprise + license, return type as 'enterprise' (default: false) :arg local: Return local information, do not retrieve the state from master node (default: false) """ diff --git a/elasticsearch/client/migration.py b/elasticsearch/client/migration.py index 3e888cf6..1ab4e41c 100644 --- a/elasticsearch/client/migration.py +++ b/elasticsearch/client/migration.py @@ -5,7 +5,7 @@ class MigrationClient(NamespacedClient): @query_params() def deprecations(self, index=None, params=None, headers=None): """ - ``_ + ``_ :arg index: Index pattern """ diff --git a/elasticsearch/client/ml.py b/elasticsearch/client/ml.py index 0c1c6058..340c31ce 100644 --- a/elasticsearch/client/ml.py +++ b/elasticsearch/client/ml.py @@ -5,7 +5,7 @@ class MlClient(NamespacedClient): @query_params("allow_no_jobs", "force", "timeout") def close_job(self, job_id, body=None, params=None, headers=None): """ - ``_ + ``_ :arg job_id: The name of the job to close :arg body: The URL params optionally sent in the body @@ -84,7 +84,7 @@ class MlClient(NamespacedClient): @query_params("force") def delete_datafeed(self, datafeed_id, params=None, headers=None): """ - ``_ + ``_ :arg datafeed_id: The ID of the datafeed to delete :arg force: True if the datafeed should be forcefully deleted @@ -129,7 +129,7 @@ class MlClient(NamespacedClient): @query_params("allow_no_forecasts", "timeout") def delete_forecast(self, job_id, forecast_id=None, params=None, headers=None): """ - ``_ + ``_ :arg job_id: The ID of the job from which to delete forecasts :arg forecast_id: The ID of the forecast to delete, can be comma @@ -152,7 +152,7 @@ class MlClient(NamespacedClient): @query_params("force", "wait_for_completion") def delete_job(self, job_id, params=None, headers=None): """ - ``_ + ``_ :arg job_id: The ID of the job to delete :arg force: True if the job should be forcefully deleted @@ -172,7 +172,7 @@ class MlClient(NamespacedClient): @query_params() def delete_model_snapshot(self, job_id, snapshot_id, params=None, headers=None): """ - ``_ + ``_ :arg job_id: The ID of the job to fetch :arg snapshot_id: The ID of the snapshot to delete @@ -208,7 +208,7 @@ class MlClient(NamespacedClient): ) def find_file_structure(self, body, params=None, headers=None): """ - ``_ + ``_ :arg body: The contents of the file to be analyzed :arg charset: Optional parameter to specify the character set of @@ -258,7 +258,7 @@ class MlClient(NamespacedClient): @query_params("advance_time", "calc_interim", "end", "skip_time", "start") def flush_job(self, job_id, body=None, params=None, headers=None): """ - ``_ + ``_ :arg job_id: The name of the job to flush :arg body: Flush parameters @@ -316,7 +316,7 @@ class MlClient(NamespacedClient): ) def get_buckets(self, job_id, body=None, timestamp=None, params=None, headers=None): """ - ``_ + ``_ :arg job_id: ID of the job to get bucket results from :arg body: Bucket selection details if not provided in URI @@ -340,7 +340,7 @@ class MlClient(NamespacedClient): raise ValueError("Empty value passed for a required argument 'job_id'.") return self.transport.perform_request( - "GET", + "POST", _make_path( "_ml", "anomaly_detectors", job_id, "results", "buckets", timestamp ), @@ -392,7 +392,7 @@ class MlClient(NamespacedClient): params["from"] = params.pop("from_") return self.transport.perform_request( - "GET", + "POST", _make_path("_ml", "calendars", calendar_id), params=params, headers=headers, @@ -404,7 +404,7 @@ class MlClient(NamespacedClient): self, job_id, body=None, category_id=None, params=None, headers=None ): """ - ``_ + ``_ :arg job_id: The name of the job :arg body: Category selection details if not provided in URI @@ -421,7 +421,7 @@ class MlClient(NamespacedClient): raise ValueError("Empty value passed for a required argument 'job_id'.") return self.transport.perform_request( - "GET", + "POST", _make_path( "_ml", "anomaly_detectors", job_id, "results", "categories", category_id ), @@ -433,7 +433,7 @@ class MlClient(NamespacedClient): @query_params("allow_no_datafeeds") def get_datafeed_stats(self, datafeed_id=None, params=None, headers=None): """ - ``_ + ``_ :arg datafeed_id: The ID of the datafeeds stats to fetch :arg allow_no_datafeeds: Whether to ignore if a wildcard @@ -450,7 +450,7 @@ class MlClient(NamespacedClient): @query_params("allow_no_datafeeds") def get_datafeeds(self, datafeed_id=None, params=None, headers=None): """ - ``_ + ``_ :arg datafeed_id: The ID of the datafeeds to fetch :arg allow_no_datafeeds: Whether to ignore if a wildcard @@ -495,7 +495,7 @@ class MlClient(NamespacedClient): ) def get_influencers(self, job_id, body=None, params=None, headers=None): """ - ``_ + ``_ :arg job_id: :arg body: Influencer selection criteria @@ -518,7 +518,7 @@ class MlClient(NamespacedClient): raise ValueError("Empty value passed for a required argument 'job_id'.") return self.transport.perform_request( - "GET", + "POST", _make_path("_ml", "anomaly_detectors", job_id, "results", "influencers"), params=params, headers=headers, @@ -528,7 +528,7 @@ class MlClient(NamespacedClient): @query_params("allow_no_jobs") def get_job_stats(self, job_id=None, params=None, headers=None): """ - ``_ + ``_ :arg job_id: The ID of the jobs stats to fetch :arg allow_no_jobs: Whether to ignore if a wildcard expression @@ -545,7 +545,7 @@ class MlClient(NamespacedClient): @query_params("allow_no_jobs") def get_jobs(self, job_id=None, params=None, headers=None): """ - ``_ + ``_ :arg job_id: The ID of the jobs to fetch :arg allow_no_jobs: Whether to ignore if a wildcard expression @@ -564,7 +564,7 @@ class MlClient(NamespacedClient): self, job_id, body=None, snapshot_id=None, params=None, headers=None ): """ - ``_ + ``_ :arg job_id: The ID of the job to fetch :arg body: Model snapshot selection criteria @@ -586,7 +586,7 @@ class MlClient(NamespacedClient): raise ValueError("Empty value passed for a required argument 'job_id'.") return self.transport.perform_request( - "GET", + "POST", _make_path( "_ml", "anomaly_detectors", job_id, "model_snapshots", snapshot_id ), @@ -606,7 +606,7 @@ class MlClient(NamespacedClient): ) def get_overall_buckets(self, job_id, body=None, params=None, headers=None): """ - ``_ + ``_ :arg job_id: The job IDs for which to calculate overall bucket results @@ -632,7 +632,7 @@ class MlClient(NamespacedClient): raise ValueError("Empty value passed for a required argument 'job_id'.") return self.transport.perform_request( - "GET", + "POST", _make_path( "_ml", "anomaly_detectors", job_id, "results", "overall_buckets" ), @@ -653,7 +653,7 @@ class MlClient(NamespacedClient): ) def get_records(self, job_id, body=None, params=None, headers=None): """ - ``_ + ``_ :arg job_id: :arg body: Record selection criteria @@ -674,7 +674,7 @@ class MlClient(NamespacedClient): raise ValueError("Empty value passed for a required argument 'job_id'.") return self.transport.perform_request( - "GET", + "POST", _make_path("_ml", "anomaly_detectors", job_id, "results", "records"), params=params, headers=headers, @@ -693,7 +693,7 @@ class MlClient(NamespacedClient): @query_params() def open_job(self, job_id, params=None, headers=None): """ - ``_ + ``_ :arg job_id: The ID of the job to open """ @@ -729,7 +729,7 @@ class MlClient(NamespacedClient): @query_params("reset_end", "reset_start") def post_data(self, job_id, body, params=None, headers=None): """ - ``_ + ``_ :arg job_id: The name of the job receiving the data :arg body: The data to process @@ -754,7 +754,7 @@ class MlClient(NamespacedClient): @query_params() def preview_datafeed(self, datafeed_id, params=None, headers=None): """ - ``_ + ``_ :arg datafeed_id: The ID of the datafeed to preview """ @@ -811,7 +811,7 @@ class MlClient(NamespacedClient): @query_params() def put_datafeed(self, datafeed_id, body, params=None, headers=None): """ - ``_ + ``_ :arg datafeed_id: The ID of the datafeed to create :arg body: The datafeed config @@ -850,7 +850,7 @@ class MlClient(NamespacedClient): @query_params() def put_job(self, job_id, body, params=None, headers=None): """ - ``_ + ``_ :arg job_id: The ID of the job to create :arg body: The job @@ -872,7 +872,7 @@ class MlClient(NamespacedClient): self, job_id, snapshot_id, body=None, params=None, headers=None ): """ - ``_ + ``_ :arg job_id: The ID of the job to fetch :arg snapshot_id: The ID of the snapshot to revert to @@ -902,7 +902,7 @@ class MlClient(NamespacedClient): @query_params("enabled", "timeout") def set_upgrade_mode(self, params=None, headers=None): """ - ``_ + ``_ :arg enabled: Whether to enable upgrade_mode ML setting or not. Defaults to false. @@ -916,7 +916,7 @@ class MlClient(NamespacedClient): @query_params("end", "start", "timeout") def start_datafeed(self, datafeed_id, body=None, params=None, headers=None): """ - ``_ + ``_ :arg datafeed_id: The ID of the datafeed to start :arg body: The start datafeed parameters @@ -942,7 +942,7 @@ class MlClient(NamespacedClient): @query_params("allow_no_datafeeds", "force", "timeout") def stop_datafeed(self, datafeed_id, params=None, headers=None): """ - ``_ + ``_ :arg datafeed_id: The ID of the datafeed to stop :arg allow_no_datafeeds: Whether to ignore if a wildcard @@ -967,7 +967,7 @@ class MlClient(NamespacedClient): @query_params() def update_datafeed(self, datafeed_id, body, params=None, headers=None): """ - ``_ + ``_ :arg datafeed_id: The ID of the datafeed to update :arg body: The datafeed update settings @@ -1006,7 +1006,7 @@ class MlClient(NamespacedClient): @query_params() def update_job(self, job_id, body, params=None, headers=None): """ - ``_ + ``_ :arg job_id: The ID of the job to create :arg body: The job update settings @@ -1028,7 +1028,7 @@ class MlClient(NamespacedClient): self, job_id, snapshot_id, body, params=None, headers=None ): """ - ``_ + ``_ :arg job_id: The ID of the job to fetch :arg snapshot_id: The ID of the snapshot to update @@ -1087,12 +1087,13 @@ class MlClient(NamespacedClient): body=body, ) - @query_params() + @query_params("force") def delete_data_frame_analytics(self, id, params=None, headers=None): """ - ``_ + ``_ :arg id: The ID of the data frame analytics to delete + :arg force: True if the job should be forcefully deleted """ if id in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'id'.") @@ -1104,28 +1105,10 @@ class MlClient(NamespacedClient): headers=headers, ) - @query_params() - def estimate_memory_usage(self, body, params=None, headers=None): - """ - ``_ - - :arg body: Memory usage estimation definition - """ - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - return self.transport.perform_request( - "POST", - "/_ml/data_frame/analytics/_estimate_memory_usage", - params=params, - headers=headers, - body=body, - ) - @query_params() def evaluate_data_frame(self, body, params=None, headers=None): """ - ``_ + ``_ :arg body: The evaluation definition """ @@ -1143,7 +1126,7 @@ class MlClient(NamespacedClient): @query_params("allow_no_match", "from_", "size") def get_data_frame_analytics(self, id=None, params=None, headers=None): """ - ``_ + ``_ :arg id: The ID of the data frame analytics to fetch :arg allow_no_match: Whether to ignore if a wildcard expression @@ -1167,7 +1150,7 @@ class MlClient(NamespacedClient): @query_params("allow_no_match", "from_", "size") def get_data_frame_analytics_stats(self, id=None, params=None, headers=None): """ - ``_ + ``_ :arg id: The ID of the data frame analytics stats to fetch :arg allow_no_match: Whether to ignore if a wildcard expression @@ -1191,7 +1174,7 @@ class MlClient(NamespacedClient): @query_params() def put_data_frame_analytics(self, id, body, params=None, headers=None): """ - ``_ + ``_ :arg id: The ID of the data frame analytics to create :arg body: The data frame analytics configuration @@ -1211,7 +1194,7 @@ class MlClient(NamespacedClient): @query_params("timeout") def start_data_frame_analytics(self, id, body=None, params=None, headers=None): """ - ``_ + ``_ :arg id: The ID of the data frame analytics to start :arg body: The start data frame analytics parameters @@ -1232,7 +1215,7 @@ class MlClient(NamespacedClient): @query_params("allow_no_match", "force", "timeout") def stop_data_frame_analytics(self, id, body=None, params=None, headers=None): """ - ``_ + ``_ :arg id: The ID of the data frame analytics to stop :arg body: The stop data frame analytics parameters @@ -1254,3 +1237,117 @@ class MlClient(NamespacedClient): headers=headers, body=body, ) + + @query_params() + def delete_trained_model(self, model_id, params=None, headers=None): + """ + ``_ + + :arg model_id: The ID of the trained model to delete + """ + if model_id in SKIP_IN_PATH: + raise ValueError("Empty value passed for a required argument 'model_id'.") + + return self.transport.perform_request( + "DELETE", + _make_path("_ml", "inference", model_id), + params=params, + headers=headers, + ) + + @query_params() + def explain_data_frame_analytics( + self, body=None, id=None, params=None, headers=None + ): + """ + ``_ + + :arg body: The data frame analytics config to explain + :arg id: The ID of the data frame analytics to explain + """ + return self.transport.perform_request( + "POST", + _make_path("_ml", "data_frame", "analytics", id, "_explain"), + params=params, + headers=headers, + body=body, + ) + + @query_params( + "allow_no_match", + "decompress_definition", + "from_", + "include_model_definition", + "size", + ) + def get_trained_models(self, model_id=None, params=None, headers=None): + """ + ``_ + + :arg model_id: The ID of the trained models to fetch + :arg allow_no_match: Whether to ignore if a wildcard expression + matches no trained models. (This includes `_all` string or when no + trained models have been specified) Default: True + :arg decompress_definition: Should the model definition be + decompressed into valid JSON or returned in a custom compressed format. + Defaults to true. Default: True + :arg from_: skips a number of trained models + :arg include_model_definition: Should the full model definition + be included in the results. These definitions can be large. So be + cautious when including them. Defaults to false. + :arg size: specifies a max number of trained models to get + Default: 100 + """ + # from is a reserved word so it cannot be used, use from_ instead + if "from_" in params: + params["from"] = params.pop("from_") + + return self.transport.perform_request( + "GET", + _make_path("_ml", "inference", model_id), + params=params, + headers=headers, + ) + + @query_params("allow_no_match", "from_", "size") + def get_trained_models_stats(self, model_id=None, params=None, headers=None): + """ + ``_ + + :arg model_id: The ID of the trained models stats to fetch + :arg allow_no_match: Whether to ignore if a wildcard expression + matches no trained models. (This includes `_all` string or when no + trained models have been specified) Default: True + :arg from_: skips a number of trained models + :arg size: specifies a max number of trained models to get + Default: 100 + """ + # from is a reserved word so it cannot be used, use from_ instead + if "from_" in params: + params["from"] = params.pop("from_") + + return self.transport.perform_request( + "GET", + _make_path("_ml", "inference", model_id, "_stats"), + params=params, + headers=headers, + ) + + @query_params() + def put_trained_model(self, model_id, body, params=None, headers=None): + """ + + :arg model_id: The ID of the trained models to store + :arg body: The trained model configuration + """ + for param in (model_id, body): + if param in SKIP_IN_PATH: + raise ValueError("Empty value passed for a required argument.") + + return self.transport.perform_request( + "PUT", + _make_path("_ml", "inference", model_id), + params=params, + headers=headers, + body=body, + ) diff --git a/elasticsearch/client/monitoring.py b/elasticsearch/client/monitoring.py index 3be40eac..c5bd2066 100644 --- a/elasticsearch/client/monitoring.py +++ b/elasticsearch/client/monitoring.py @@ -5,7 +5,7 @@ class MonitoringClient(NamespacedClient): @query_params("interval", "system_api_version", "system_id") def bulk(self, body, doc_type=None, params=None, headers=None): """ - ``_ + ``_ :arg body: The operation definition and data (action-data pairs), separated by newlines diff --git a/elasticsearch/client/rollup.py b/elasticsearch/client/rollup.py index a9b6b9e7..e26288c6 100644 --- a/elasticsearch/client/rollup.py +++ b/elasticsearch/client/rollup.py @@ -88,7 +88,7 @@ class RollupClient(NamespacedClient): raise ValueError("Empty value passed for a required argument.") return self.transport.perform_request( - "GET", + "POST", _make_path(index, doc_type, "_rollup_search"), params=params, headers=headers, diff --git a/elasticsearch/client/security.py b/elasticsearch/client/security.py index 472c6bd4..eaf8e467 100644 --- a/elasticsearch/client/security.py +++ b/elasticsearch/client/security.py @@ -93,7 +93,6 @@ class SecurityClient(NamespacedClient): @query_params("refresh") def delete_privileges(self, application, name, params=None, headers=None): """ - ``_ :arg application: Application name :arg name: Privilege name @@ -326,7 +325,7 @@ class SecurityClient(NamespacedClient): raise ValueError("Empty value passed for a required argument 'body'.") return self.transport.perform_request( - "GET", + "POST", _make_path("_security", "user", user, "_has_privileges"), params=params, headers=headers, @@ -368,7 +367,6 @@ class SecurityClient(NamespacedClient): @query_params("refresh") def put_privileges(self, body, params=None, headers=None): """ - ``_ :arg body: The privilege(s) to add :arg refresh: If `true` (the default) then refresh the affected diff --git a/elasticsearch/client/slm.py b/elasticsearch/client/slm.py index baf80bc5..a2c0a0ca 100644 --- a/elasticsearch/client/slm.py +++ b/elasticsearch/client/slm.py @@ -5,7 +5,7 @@ class SlmClient(NamespacedClient): @query_params() def delete_lifecycle(self, policy_id, params=None, headers=None): """ - ``_ + ``_ :arg policy_id: The id of the snapshot lifecycle policy to remove @@ -23,7 +23,7 @@ class SlmClient(NamespacedClient): @query_params() def execute_lifecycle(self, policy_id, params=None, headers=None): """ - ``_ + ``_ :arg policy_id: The id of the snapshot lifecycle policy to be executed @@ -51,7 +51,7 @@ class SlmClient(NamespacedClient): @query_params() def get_lifecycle(self, policy_id=None, params=None, headers=None): """ - ``_ + ``_ :arg policy_id: Comma-separated list of snapshot lifecycle policies to retrieve @@ -66,7 +66,7 @@ class SlmClient(NamespacedClient): @query_params() def get_stats(self, params=None, headers=None): """ - ``_ + ``_ """ return self.transport.perform_request( @@ -76,7 +76,7 @@ class SlmClient(NamespacedClient): @query_params() def put_lifecycle(self, policy_id, body=None, params=None, headers=None): """ - ``_ + ``_ :arg policy_id: The id of the snapshot lifecycle policy :arg body: The snapshot lifecycle policy definition to register @@ -95,7 +95,7 @@ class SlmClient(NamespacedClient): @query_params() def get_status(self, params=None, headers=None): """ - ``_ + ``_ """ return self.transport.perform_request( @@ -105,7 +105,7 @@ class SlmClient(NamespacedClient): @query_params() def start(self, params=None, headers=None): """ - ``_ + ``_ """ return self.transport.perform_request( @@ -115,7 +115,7 @@ class SlmClient(NamespacedClient): @query_params() def stop(self, params=None, headers=None): """ - ``_ + ``_ """ return self.transport.perform_request( diff --git a/elasticsearch/client/sql.py b/elasticsearch/client/sql.py index 8211c672..103f6865 100644 --- a/elasticsearch/client/sql.py +++ b/elasticsearch/client/sql.py @@ -5,7 +5,6 @@ class SqlClient(NamespacedClient): @query_params() def clear_cursor(self, body, params=None, headers=None): """ - ``_ :arg body: Specify the cursor value in the `cursor` element to clean the cursor. @@ -20,7 +19,6 @@ class SqlClient(NamespacedClient): @query_params("format") def query(self, body, params=None, headers=None): """ - ``_ :arg body: Use the `query` element to start a query. Use the `cursor` element to continue a query. @@ -37,7 +35,6 @@ class SqlClient(NamespacedClient): @query_params() def translate(self, body, params=None, headers=None): """ - ``_ :arg body: Specify the query in the `query` element. """ diff --git a/elasticsearch/client/transform.py b/elasticsearch/client/transform.py index 0d9aadcf..6cab5377 100644 --- a/elasticsearch/client/transform.py +++ b/elasticsearch/client/transform.py @@ -137,7 +137,13 @@ class TransformClient(NamespacedClient): headers=headers, ) - @query_params("allow_no_match", "timeout", "wait_for_completion") + @query_params( + "allow_no_match", + "force", + "timeout", + "wait_for_checkpoint", + "wait_for_completion", + ) def stop_transform(self, transform_id, params=None, headers=None): """ ``_ @@ -146,8 +152,12 @@ class TransformClient(NamespacedClient): :arg allow_no_match: Whether to ignore if a wildcard expression matches no transforms. (This includes `_all` string or when no transforms have been specified) + :arg force: Whether to force stop a failed transform or not. + Default to false :arg timeout: Controls the time to wait until the transform has stopped. Default to 30 seconds + :arg wait_for_checkpoint: Whether to wait for the transform to + reach a checkpoint before stopping. Default to false :arg wait_for_completion: Whether to wait for the transform to fully stop before returning or not. Default to false """ diff --git a/elasticsearch/client/watcher.py b/elasticsearch/client/watcher.py index 5cc707cb..591d0abc 100644 --- a/elasticsearch/client/watcher.py +++ b/elasticsearch/client/watcher.py @@ -5,7 +5,7 @@ class WatcherClient(NamespacedClient): @query_params() def ack_watch(self, watch_id, action_id=None, params=None, headers=None): """ - ``_ + ``_ :arg watch_id: Watch ID :arg action_id: A comma-separated list of the action ids to be @@ -58,7 +58,7 @@ class WatcherClient(NamespacedClient): @query_params() def delete_watch(self, id, params=None, headers=None): """ - ``_ + ``_ :arg id: Watch ID """ @@ -75,7 +75,7 @@ class WatcherClient(NamespacedClient): @query_params("debug") def execute_watch(self, body=None, id=None, params=None, headers=None): """ - ``_ + ``_ :arg body: Execution control :arg id: Watch ID @@ -93,7 +93,7 @@ class WatcherClient(NamespacedClient): @query_params() def get_watch(self, id, params=None, headers=None): """ - ``_ + ``_ :arg id: Watch ID """ @@ -107,7 +107,7 @@ class WatcherClient(NamespacedClient): @query_params("active", "if_primary_term", "if_seq_no", "version") def put_watch(self, id, body=None, params=None, headers=None): """ - ``_ + ``_ :arg id: Watch ID :arg body: The watch @@ -132,7 +132,7 @@ class WatcherClient(NamespacedClient): @query_params() def start(self, params=None, headers=None): """ - ``_ + ``_ """ return self.transport.perform_request( @@ -142,7 +142,7 @@ class WatcherClient(NamespacedClient): @query_params("emit_stacktraces") def stats(self, metric=None, params=None, headers=None): """ - ``_ + ``_ :arg metric: Controls what additional stat metrics should be include in the response Valid choices: _all, queued_watches, @@ -163,7 +163,7 @@ class WatcherClient(NamespacedClient): @query_params() def stop(self, params=None, headers=None): """ - ``_ + ``_ """ return self.transport.perform_request( diff --git a/elasticsearch/client/xpack.py b/elasticsearch/client/xpack.py index de0aa80f..769e6817 100644 --- a/elasticsearch/client/xpack.py +++ b/elasticsearch/client/xpack.py @@ -21,7 +21,7 @@ class XPackClient(NamespacedClient): @query_params("master_timeout") def usage(self, params=None, headers=None): """ - ``_ + ``_ :arg master_timeout: Specify timeout for watch write operation """ diff --git a/test_elasticsearch/test_client/__init__.py b/test_elasticsearch/test_client/__init__.py index a43e9427..b7fa18ad 100644 --- a/test_elasticsearch/test_client/__init__.py +++ b/test_elasticsearch/test_client/__init__.py @@ -80,7 +80,7 @@ class TestClient(ElasticsearchTestCase): def test_from_in_search(self): self.client.search(index="i", from_=10) - calls = self.assert_url_called("GET", "/i/_search") + calls = self.assert_url_called("POST", "/i/_search") self.assertEquals([({"from": "10"}, {}, None)], calls) def test_repr_contains_hosts(self): diff --git a/test_elasticsearch/test_server/test_common.py b/test_elasticsearch/test_server/test_common.py index 9d159336..d364f0db 100644 --- a/test_elasticsearch/test_server/test_common.py +++ b/test_elasticsearch/test_server/test_common.py @@ -37,9 +37,6 @@ SKIP_TESTS = { "*": { # Can't figure out the get_alias(expand_wildcards=open) failure. "TestIndicesGetAlias10Basic", - # Scripts are 7.6+ - "TestScripts20GetScriptContext", - "TestScripts25GetScriptLanguages", # Disallowing expensive queries is 7.7+ "TestSearch320DisallowQueries", } diff --git a/utils/generate_api.py b/utils/generate_api.py index db653809..0e76617d 100644 --- a/utils/generate_api.py +++ b/utils/generate_api.py @@ -82,12 +82,11 @@ class Module: if line.startswith("class"): break self.header = "\n".join(header_lines) - defined_apis = re.findall( - r'\n def ([a-z_]+)\([^\n]*\n *"""\n *([\w\W]*?)(?:`<|""")', + self.orders = re.findall( + r'\n def ([a-z_]+)\(', content, - re.MULTILINE, + re.MULTILINE ) - self.orders = list(map(lambda x: x[0], defined_apis)) def _position(self, api): try: @@ -128,6 +127,14 @@ class API: self.description = definition["documentation"].get("description", "") self.doc_url = definition["documentation"].get("url", "") + # Filter out bad URL refs like 'TODO' + # and serve all docs over HTTPS. + if self.doc_url: + if not self.doc_url.startswith("http"): + self.doc_url = "" + if self.doc_url.startswith("http://"): + self.doc_url = self.doc_url.replace("http://", "https://") + @property def all_parts(self): parts = {} @@ -188,7 +195,12 @@ class API: @property def method(self): - return self.path["methods"][0] + # To adhere to the HTTP RFC we shouldn't send + # bodies in GET requests. + default_method = self.path["methods"][0] + if self.body and default_method == "GET" and "POST" in self.path["methods"]: + return "POST" + return default_method @property def url_parts(self): @@ -246,6 +258,10 @@ def read_modules(): if "." in name: namespace, name = name.rsplit(".", 1) + # The data_frame API has been changed to transform. + if namespace == "data_frame_transform_deprecated": + continue + if namespace not in modules: modules[namespace] = Module(namespace)