Update supported ES API to 7.6

This commit is contained in:
Seth Michael Larson
2020-03-13 13:44:46 -05:00
committed by GitHub
parent ae74e1d0e6
commit 883287551a
22 changed files with 285 additions and 130 deletions
+56 -19
View File
@@ -438,7 +438,7 @@ class Elasticsearch(object):
provide one provide one
:arg pipeline: The pipeline id to preprocess incoming documents :arg pipeline: The pipeline id to preprocess incoming documents
with 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 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 to make this operation visible to search, if `false` (the default) then
do nothing with refreshes. Valid choices: true, false, wait_for 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 :arg if_seq_no: only perform the delete operation if the last
operation that has changed the document has the specified sequence operation that has changed the document has the specified sequence
number 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 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 to make this operation visible to search, if `false` (the default) then
do nothing with refreshes. Valid choices: true, false, wait_for do nothing with refreshes. Valid choices: true, false, wait_for
@@ -602,6 +602,7 @@ class Elasticsearch(object):
"_source_includes", "_source_includes",
"allow_no_indices", "allow_no_indices",
"analyze_wildcard", "analyze_wildcard",
"analyzer",
"conflicts", "conflicts",
"default_operator", "default_operator",
"df", "df",
@@ -651,6 +652,7 @@ class Elasticsearch(object):
string or when no indices have been specified) string or when no indices have been specified)
:arg analyze_wildcard: Specify whether wildcard and prefix :arg analyze_wildcard: Specify whether wildcard and prefix
queries should be analyzed (default: false) 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 :arg conflicts: What to do when the delete by query hits version
conflicts? Valid choices: abort, proceed Default: abort conflicts? Valid choices: abort, proceed Default: abort
:arg default_operator: The default operator for query string :arg default_operator: The default operator for query string
@@ -913,7 +915,7 @@ class Elasticsearch(object):
doc_type = "_doc" doc_type = "_doc"
return self.transport.perform_request( return self.transport.perform_request(
"GET", "POST",
_make_path(index, doc_type, id, "_explain"), _make_path(index, doc_type, id, "_explain"),
params=params, params=params,
headers=headers, headers=headers,
@@ -1109,7 +1111,7 @@ class Elasticsearch(object):
raise ValueError("Empty value passed for a required argument 'body'.") raise ValueError("Empty value passed for a required argument 'body'.")
return self.transport.perform_request( return self.transport.perform_request(
"GET", "POST",
_make_path(index, doc_type, "_mget"), _make_path(index, doc_type, "_mget"),
params=params, params=params,
headers=headers, headers=headers,
@@ -1165,7 +1167,7 @@ class Elasticsearch(object):
body = _bulk_body(self.transport.serializer, body) body = _bulk_body(self.transport.serializer, body)
return self.transport.perform_request( return self.transport.perform_request(
"GET", "POST",
_make_path(index, doc_type, "_msearch"), _make_path(index, doc_type, "_msearch"),
params=params, params=params,
headers=headers, headers=headers,
@@ -1173,7 +1175,11 @@ class Elasticsearch(object):
) )
@query_params( @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( def msearch_template(
self, body, index=None, doc_type=None, params=None, headers=None self, body, index=None, doc_type=None, params=None, headers=None
@@ -1188,6 +1194,9 @@ class Elasticsearch(object):
default default
:arg doc_type: A comma-separated list of document types to use :arg doc_type: A comma-separated list of document types to use
as default 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 :arg max_concurrent_searches: Controls the maximum number of
concurrent searches the multi search api will execute concurrent searches the multi search api will execute
:arg rest_total_hits_as_int: Indicates whether hits.total should :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) body = _bulk_body(self.transport.serializer, body)
return self.transport.perform_request( return self.transport.perform_request(
"GET", "POST",
_make_path(index, doc_type, "_msearch", "template"), _make_path(index, doc_type, "_msearch", "template"),
params=params, params=params,
headers=headers, headers=headers,
@@ -1269,7 +1278,7 @@ class Elasticsearch(object):
internal, external, external_gte, force internal, external, external_gte, force
""" """
return self.transport.perform_request( return self.transport.perform_request(
"GET", "POST",
_make_path(index, doc_type, "_mtermvectors"), _make_path(index, doc_type, "_mtermvectors"),
params=params, params=params,
headers=headers, headers=headers,
@@ -1301,7 +1310,9 @@ class Elasticsearch(object):
body=body, 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): 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 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 closed, none, all Default: open
:arg ignore_unavailable: Whether specified concrete indices :arg ignore_unavailable: Whether specified concrete indices
should be ignored when unavailable (missing or closed) 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: if body in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'body'.") raise ValueError("Empty value passed for a required argument 'body'.")
return self.transport.perform_request( return self.transport.perform_request(
"GET", "POST",
_make_path(index, "_rank_eval"), _make_path(index, "_rank_eval"),
params=params, params=params,
headers=headers, headers=headers,
@@ -1353,7 +1366,7 @@ class Elasticsearch(object):
prototype for the index request. prototype for the index request.
:arg max_docs: Maximum number of documents to process (default: :arg max_docs: Maximum number of documents to process (default:
all documents) 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 :arg requests_per_second: The throttle to set on this request in
sub-requests per second. -1 means no throttle. sub-requests per second. -1 means no throttle.
:arg scroll: Control how long to keep the search context alive :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 :arg id: The id of the stored search template
""" """
return self.transport.perform_request( return self.transport.perform_request(
"GET", "POST",
_make_path("_render", "template", id), _make_path("_render", "template", id),
params=params, params=params,
headers=headers, headers=headers,
@@ -1424,7 +1437,7 @@ class Elasticsearch(object):
:arg body: The script to execute :arg body: The script to execute
""" """
return self.transport.perform_request( return self.transport.perform_request(
"GET", "POST",
"/_scripts/painless/_execute", "/_scripts/painless/_execute",
params=params, params=params,
headers=headers, headers=headers,
@@ -1454,7 +1467,7 @@ class Elasticsearch(object):
params["scroll_id"] = scroll_id params["scroll_id"] = scroll_id
return self.transport.perform_request( 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( @query_params(
@@ -1607,7 +1620,7 @@ class Elasticsearch(object):
params["from"] = params.pop("from_") params["from"] = params.pop("from_")
return self.transport.perform_request( return self.transport.perform_request(
"GET", "POST",
_make_path(index, doc_type, "_search"), _make_path(index, doc_type, "_search"),
params=params, params=params,
headers=headers, headers=headers,
@@ -1650,6 +1663,7 @@ class Elasticsearch(object):
@query_params( @query_params(
"allow_no_indices", "allow_no_indices",
"ccs_minimize_roundtrips",
"expand_wildcards", "expand_wildcards",
"explain", "explain",
"ignore_throttled", "ignore_throttled",
@@ -1677,6 +1691,9 @@ class Elasticsearch(object):
:arg allow_no_indices: Whether to ignore if a wildcard indices :arg allow_no_indices: Whether to ignore if a wildcard indices
expression resolves into no concrete indices. (This includes `_all` expression resolves into no concrete indices. (This includes `_all`
string or when no indices have been specified) 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 :arg expand_wildcards: Whether to expand wildcard expression to
concrete indices that are open, closed or both. Valid choices: open, concrete indices that are open, closed or both. Valid choices: open,
closed, none, all Default: open closed, none, all Default: open
@@ -1704,7 +1721,7 @@ class Elasticsearch(object):
raise ValueError("Empty value passed for a required argument 'body'.") raise ValueError("Empty value passed for a required argument 'body'.")
return self.transport.perform_request( return self.transport.perform_request(
"GET", "POST",
_make_path(index, doc_type, "_search", "template"), _make_path(index, doc_type, "_search", "template"),
params=params, params=params,
headers=headers, headers=headers,
@@ -1766,7 +1783,7 @@ class Elasticsearch(object):
doc_type = "_doc" doc_type = "_doc"
return self.transport.perform_request( return self.transport.perform_request(
"GET", "POST",
_make_path(index, doc_type, id, "_termvectors"), _make_path(index, doc_type, id, "_termvectors"),
params=params, params=params,
headers=headers, headers=headers,
@@ -1809,7 +1826,7 @@ class Elasticsearch(object):
operation that has changed the document has the specified sequence operation that has changed the document has the specified sequence
number number
:arg lang: The script language (default: painless) :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 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 to make this operation visible to search, if `false` (the default) then
do nothing with refreshes. Valid choices: true, false, wait_for 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 :arg preference: Specify the node or shard the operation should
be performed on (default: random) be performed on (default: random)
:arg q: Query in the Lucene query string syntax :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 :arg request_cache: Specify if request cache should be used for
this request or not, defaults to index level setting this request or not, defaults to index level setting
:arg requests_per_second: The throttle to set on this request in :arg requests_per_second: The throttle to set on this request in
@@ -1995,3 +2012,23 @@ class Elasticsearch(object):
params=params, params=params,
headers=headers, 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
)
+3 -3
View File
@@ -134,7 +134,7 @@ class CatClient(NamespacedClient):
:arg index: A comma-separated list of index names to limit the :arg index: A comma-separated list of index names to limit the
returned information returned information
:arg bytes: The unit in which to display byte values Valid :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, :arg format: a short version of the Accept header, e.g. json,
yaml yaml
:arg h: Comma-separated list of column names to display :arg h: Comma-separated list of column names to display
@@ -208,8 +208,8 @@ class CatClient(NamespacedClient):
version (default: false) version (default: false)
:arg h: Comma-separated list of column names to display :arg h: Comma-separated list of column names to display
:arg help: Return help information :arg help: Return help information
:arg local: Return local information, do not retrieve the state :arg local: Calculate the selected nodes using the local cluster
from master node (default: false) state rather than the state from master node (default: false)
:arg master_timeout: Explicit operation timeout for connection :arg master_timeout: Explicit operation timeout for connection
to master node to master node
:arg s: Comma-separated list of column names or column aliases :arg s: Comma-separated list of column names or column aliases
+2 -2
View File
@@ -78,7 +78,7 @@ class CcrClient(NamespacedClient):
@query_params() @query_params()
def forget_follower(self, index, body, params=None, headers=None): def forget_follower(self, index, body, params=None, headers=None):
""" """
`<http://www.elastic.co/guide/en/elasticsearch/reference/current>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current>`_
:arg index: the name of the leader index for which specified :arg index: the name of the leader index for which specified
follower retention leases should be removed follower retention leases should be removed
@@ -184,7 +184,7 @@ class CcrClient(NamespacedClient):
@query_params() @query_params()
def unfollow(self, index, params=None, headers=None): def unfollow(self, index, params=None, headers=None):
""" """
`<http://www.elastic.co/guide/en/elasticsearch/reference/current>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current>`_
:arg index: The name of the follower index that should be turned :arg index: The name of the follower index that should be turned
into a regular index. into a regular index.
+1 -1
View File
@@ -229,7 +229,7 @@ class ClusterClient(NamespacedClient):
explanation (default: false) explanation (default: false)
""" """
return self.transport.perform_request( return self.transport.perform_request(
"GET", "POST",
"/_cluster/allocation/explain", "/_cluster/allocation/explain",
params=params, params=params,
headers=headers, headers=headers,
+1 -1
View File
@@ -43,7 +43,7 @@ class EnrichClient(NamespacedClient):
""" """
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/enrich-get-policy.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/enrich-get-policy.html>`_
:arg name: The name of the enrich policy :arg name: A comma-separated list of enrich policy names
""" """
return self.transport.perform_request( return self.transport.perform_request(
"GET", _make_path("_enrich", "policy", name), params=params, headers=headers "GET", _make_path("_enrich", "policy", name), params=params, headers=headers
+1 -1
View File
@@ -19,7 +19,7 @@ class GraphClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'index'.") raise ValueError("Empty value passed for a required argument 'index'.")
return self.transport.perform_request( return self.transport.perform_request(
"GET", "POST",
_make_path(index, doc_type, "_graph", "explore"), _make_path(index, doc_type, "_graph", "explore"),
params=params, params=params,
headers=headers, headers=headers,
+4 -3
View File
@@ -15,7 +15,7 @@ class IndicesClient(NamespacedClient):
:arg index: The name of the index to scope the operation :arg index: The name of the index to scope the operation
""" """
return self.transport.perform_request( return self.transport.perform_request(
"GET", "POST",
_make_path(index, "_analyze"), _make_path(index, "_analyze"),
params=params, params=params,
headers=headers, headers=headers,
@@ -884,7 +884,7 @@ class IndicesClient(NamespacedClient):
actual Lucene query that will be executed. actual Lucene query that will be executed.
""" """
return self.transport.perform_request( return self.transport.perform_request(
"GET", "POST",
_make_path(index, doc_type, "_validate", "query"), _make_path(index, doc_type, "_validate", "query"),
params=params, params=params,
headers=headers, headers=headers,
@@ -999,7 +999,8 @@ class IndicesClient(NamespacedClient):
@query_params("allow_no_indices", "expand_wildcards", "ignore_unavailable") @query_params("allow_no_indices", "expand_wildcards", "ignore_unavailable")
def flush_synced(self, index=None, params=None, headers=None): 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
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-synced-flush-api.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-synced-flush-api.html>`_
:arg index: A comma-separated list of index names; use `_all` or :arg index: A comma-separated list of index names; use `_all` or
+1 -1
View File
@@ -77,7 +77,7 @@ class IngestClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'body'.") raise ValueError("Empty value passed for a required argument 'body'.")
return self.transport.perform_request( return self.transport.perform_request(
"GET", "POST",
_make_path("_ingest", "pipeline", id, "_simulate"), _make_path("_ingest", "pipeline", id, "_simulate"),
params=params, params=params,
headers=headers, headers=headers,
+3 -1
View File
@@ -12,11 +12,13 @@ class LicenseClient(NamespacedClient):
"DELETE", "/_license", params=params, headers=headers "DELETE", "/_license", params=params, headers=headers
) )
@query_params("local") @query_params("accept_enterprise", "local")
def get(self, params=None, headers=None): def get(self, params=None, headers=None):
""" """
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/get-license.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/master/get-license.html>`_
: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 :arg local: Return local information, do not retrieve the state
from master node (default: false) from master node (default: false)
""" """
+1 -1
View File
@@ -5,7 +5,7 @@ class MigrationClient(NamespacedClient):
@query_params() @query_params()
def deprecations(self, index=None, params=None, headers=None): def deprecations(self, index=None, params=None, headers=None):
""" """
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/migration-api-deprecation.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/migration-api-deprecation.html>`_
:arg index: Index pattern :arg index: Index pattern
""" """
+159 -62
View File
@@ -5,7 +5,7 @@ class MlClient(NamespacedClient):
@query_params("allow_no_jobs", "force", "timeout") @query_params("allow_no_jobs", "force", "timeout")
def close_job(self, job_id, body=None, params=None, headers=None): def close_job(self, job_id, body=None, params=None, headers=None):
""" """
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-close-job.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-close-job.html>`_
:arg job_id: The name of the job to close :arg job_id: The name of the job to close
:arg body: The URL params optionally sent in the body :arg body: The URL params optionally sent in the body
@@ -84,7 +84,7 @@ class MlClient(NamespacedClient):
@query_params("force") @query_params("force")
def delete_datafeed(self, datafeed_id, params=None, headers=None): def delete_datafeed(self, datafeed_id, params=None, headers=None):
""" """
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-datafeed.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-datafeed.html>`_
:arg datafeed_id: The ID of the datafeed to delete :arg datafeed_id: The ID of the datafeed to delete
:arg force: True if the datafeed should be forcefully deleted :arg force: True if the datafeed should be forcefully deleted
@@ -129,7 +129,7 @@ class MlClient(NamespacedClient):
@query_params("allow_no_forecasts", "timeout") @query_params("allow_no_forecasts", "timeout")
def delete_forecast(self, job_id, forecast_id=None, params=None, headers=None): def delete_forecast(self, job_id, forecast_id=None, params=None, headers=None):
""" """
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-forecast.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-forecast.html>`_
:arg job_id: The ID of the job from which to delete forecasts :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 :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") @query_params("force", "wait_for_completion")
def delete_job(self, job_id, params=None, headers=None): def delete_job(self, job_id, params=None, headers=None):
""" """
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-job.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-job.html>`_
:arg job_id: The ID of the job to delete :arg job_id: The ID of the job to delete
:arg force: True if the job should be forcefully deleted :arg force: True if the job should be forcefully deleted
@@ -172,7 +172,7 @@ class MlClient(NamespacedClient):
@query_params() @query_params()
def delete_model_snapshot(self, job_id, snapshot_id, params=None, headers=None): def delete_model_snapshot(self, job_id, snapshot_id, params=None, headers=None):
""" """
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-snapshot.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-snapshot.html>`_
:arg job_id: The ID of the job to fetch :arg job_id: The ID of the job to fetch
:arg snapshot_id: The ID of the snapshot to delete :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): def find_file_structure(self, body, params=None, headers=None):
""" """
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-find-file-structure.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-find-file-structure.html>`_
:arg body: The contents of the file to be analyzed :arg body: The contents of the file to be analyzed
:arg charset: Optional parameter to specify the character set of :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") @query_params("advance_time", "calc_interim", "end", "skip_time", "start")
def flush_job(self, job_id, body=None, params=None, headers=None): def flush_job(self, job_id, body=None, params=None, headers=None):
""" """
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-flush-job.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-flush-job.html>`_
:arg job_id: The name of the job to flush :arg job_id: The name of the job to flush
:arg body: Flush parameters :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): def get_buckets(self, job_id, body=None, timestamp=None, params=None, headers=None):
""" """
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-bucket.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-bucket.html>`_
:arg job_id: ID of the job to get bucket results from :arg job_id: ID of the job to get bucket results from
:arg body: Bucket selection details if not provided in URI :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'.") raise ValueError("Empty value passed for a required argument 'job_id'.")
return self.transport.perform_request( return self.transport.perform_request(
"GET", "POST",
_make_path( _make_path(
"_ml", "anomaly_detectors", job_id, "results", "buckets", timestamp "_ml", "anomaly_detectors", job_id, "results", "buckets", timestamp
), ),
@@ -392,7 +392,7 @@ class MlClient(NamespacedClient):
params["from"] = params.pop("from_") params["from"] = params.pop("from_")
return self.transport.perform_request( return self.transport.perform_request(
"GET", "POST",
_make_path("_ml", "calendars", calendar_id), _make_path("_ml", "calendars", calendar_id),
params=params, params=params,
headers=headers, headers=headers,
@@ -404,7 +404,7 @@ class MlClient(NamespacedClient):
self, job_id, body=None, category_id=None, params=None, headers=None self, job_id, body=None, category_id=None, params=None, headers=None
): ):
""" """
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-category.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-category.html>`_
:arg job_id: The name of the job :arg job_id: The name of the job
:arg body: Category selection details if not provided in URI :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'.") raise ValueError("Empty value passed for a required argument 'job_id'.")
return self.transport.perform_request( return self.transport.perform_request(
"GET", "POST",
_make_path( _make_path(
"_ml", "anomaly_detectors", job_id, "results", "categories", category_id "_ml", "anomaly_detectors", job_id, "results", "categories", category_id
), ),
@@ -433,7 +433,7 @@ class MlClient(NamespacedClient):
@query_params("allow_no_datafeeds") @query_params("allow_no_datafeeds")
def get_datafeed_stats(self, datafeed_id=None, params=None, headers=None): def get_datafeed_stats(self, datafeed_id=None, params=None, headers=None):
""" """
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-datafeed-stats.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-datafeed-stats.html>`_
:arg datafeed_id: The ID of the datafeeds stats to fetch :arg datafeed_id: The ID of the datafeeds stats to fetch
:arg allow_no_datafeeds: Whether to ignore if a wildcard :arg allow_no_datafeeds: Whether to ignore if a wildcard
@@ -450,7 +450,7 @@ class MlClient(NamespacedClient):
@query_params("allow_no_datafeeds") @query_params("allow_no_datafeeds")
def get_datafeeds(self, datafeed_id=None, params=None, headers=None): def get_datafeeds(self, datafeed_id=None, params=None, headers=None):
""" """
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-datafeed.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-datafeed.html>`_
:arg datafeed_id: The ID of the datafeeds to fetch :arg datafeed_id: The ID of the datafeeds to fetch
:arg allow_no_datafeeds: Whether to ignore if a wildcard :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): def get_influencers(self, job_id, body=None, params=None, headers=None):
""" """
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-influencer.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-influencer.html>`_
:arg job_id: :arg job_id:
:arg body: Influencer selection criteria :arg body: Influencer selection criteria
@@ -518,7 +518,7 @@ class MlClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'job_id'.") raise ValueError("Empty value passed for a required argument 'job_id'.")
return self.transport.perform_request( return self.transport.perform_request(
"GET", "POST",
_make_path("_ml", "anomaly_detectors", job_id, "results", "influencers"), _make_path("_ml", "anomaly_detectors", job_id, "results", "influencers"),
params=params, params=params,
headers=headers, headers=headers,
@@ -528,7 +528,7 @@ class MlClient(NamespacedClient):
@query_params("allow_no_jobs") @query_params("allow_no_jobs")
def get_job_stats(self, job_id=None, params=None, headers=None): def get_job_stats(self, job_id=None, params=None, headers=None):
""" """
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-job-stats.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-job-stats.html>`_
:arg job_id: The ID of the jobs stats to fetch :arg job_id: The ID of the jobs stats to fetch
:arg allow_no_jobs: Whether to ignore if a wildcard expression :arg allow_no_jobs: Whether to ignore if a wildcard expression
@@ -545,7 +545,7 @@ class MlClient(NamespacedClient):
@query_params("allow_no_jobs") @query_params("allow_no_jobs")
def get_jobs(self, job_id=None, params=None, headers=None): def get_jobs(self, job_id=None, params=None, headers=None):
""" """
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-job.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-job.html>`_
:arg job_id: The ID of the jobs to fetch :arg job_id: The ID of the jobs to fetch
:arg allow_no_jobs: Whether to ignore if a wildcard expression :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 self, job_id, body=None, snapshot_id=None, params=None, headers=None
): ):
""" """
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-snapshot.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-snapshot.html>`_
:arg job_id: The ID of the job to fetch :arg job_id: The ID of the job to fetch
:arg body: Model snapshot selection criteria :arg body: Model snapshot selection criteria
@@ -586,7 +586,7 @@ class MlClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'job_id'.") raise ValueError("Empty value passed for a required argument 'job_id'.")
return self.transport.perform_request( return self.transport.perform_request(
"GET", "POST",
_make_path( _make_path(
"_ml", "anomaly_detectors", job_id, "model_snapshots", snapshot_id "_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): def get_overall_buckets(self, job_id, body=None, params=None, headers=None):
""" """
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-overall-buckets.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-overall-buckets.html>`_
:arg job_id: The job IDs for which to calculate overall bucket :arg job_id: The job IDs for which to calculate overall bucket
results results
@@ -632,7 +632,7 @@ class MlClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'job_id'.") raise ValueError("Empty value passed for a required argument 'job_id'.")
return self.transport.perform_request( return self.transport.perform_request(
"GET", "POST",
_make_path( _make_path(
"_ml", "anomaly_detectors", job_id, "results", "overall_buckets" "_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): def get_records(self, job_id, body=None, params=None, headers=None):
""" """
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-record.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-record.html>`_
:arg job_id: :arg job_id:
:arg body: Record selection criteria :arg body: Record selection criteria
@@ -674,7 +674,7 @@ class MlClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'job_id'.") raise ValueError("Empty value passed for a required argument 'job_id'.")
return self.transport.perform_request( return self.transport.perform_request(
"GET", "POST",
_make_path("_ml", "anomaly_detectors", job_id, "results", "records"), _make_path("_ml", "anomaly_detectors", job_id, "results", "records"),
params=params, params=params,
headers=headers, headers=headers,
@@ -693,7 +693,7 @@ class MlClient(NamespacedClient):
@query_params() @query_params()
def open_job(self, job_id, params=None, headers=None): def open_job(self, job_id, params=None, headers=None):
""" """
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-open-job.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-open-job.html>`_
:arg job_id: The ID of the job to open :arg job_id: The ID of the job to open
""" """
@@ -729,7 +729,7 @@ class MlClient(NamespacedClient):
@query_params("reset_end", "reset_start") @query_params("reset_end", "reset_start")
def post_data(self, job_id, body, params=None, headers=None): def post_data(self, job_id, body, params=None, headers=None):
""" """
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-post-data.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-post-data.html>`_
:arg job_id: The name of the job receiving the data :arg job_id: The name of the job receiving the data
:arg body: The data to process :arg body: The data to process
@@ -754,7 +754,7 @@ class MlClient(NamespacedClient):
@query_params() @query_params()
def preview_datafeed(self, datafeed_id, params=None, headers=None): def preview_datafeed(self, datafeed_id, params=None, headers=None):
""" """
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-preview-datafeed.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-preview-datafeed.html>`_
:arg datafeed_id: The ID of the datafeed to preview :arg datafeed_id: The ID of the datafeed to preview
""" """
@@ -811,7 +811,7 @@ class MlClient(NamespacedClient):
@query_params() @query_params()
def put_datafeed(self, datafeed_id, body, params=None, headers=None): def put_datafeed(self, datafeed_id, body, params=None, headers=None):
""" """
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-datafeed.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-datafeed.html>`_
:arg datafeed_id: The ID of the datafeed to create :arg datafeed_id: The ID of the datafeed to create
:arg body: The datafeed config :arg body: The datafeed config
@@ -850,7 +850,7 @@ class MlClient(NamespacedClient):
@query_params() @query_params()
def put_job(self, job_id, body, params=None, headers=None): def put_job(self, job_id, body, params=None, headers=None):
""" """
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-job.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-job.html>`_
:arg job_id: The ID of the job to create :arg job_id: The ID of the job to create
:arg body: The job :arg body: The job
@@ -872,7 +872,7 @@ class MlClient(NamespacedClient):
self, job_id, snapshot_id, body=None, params=None, headers=None self, job_id, snapshot_id, body=None, params=None, headers=None
): ):
""" """
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-revert-snapshot.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-revert-snapshot.html>`_
:arg job_id: The ID of the job to fetch :arg job_id: The ID of the job to fetch
:arg snapshot_id: The ID of the snapshot to revert to :arg snapshot_id: The ID of the snapshot to revert to
@@ -902,7 +902,7 @@ class MlClient(NamespacedClient):
@query_params("enabled", "timeout") @query_params("enabled", "timeout")
def set_upgrade_mode(self, params=None, headers=None): def set_upgrade_mode(self, params=None, headers=None):
""" """
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-set-upgrade-mode.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-set-upgrade-mode.html>`_
:arg enabled: Whether to enable upgrade_mode ML setting or not. :arg enabled: Whether to enable upgrade_mode ML setting or not.
Defaults to false. Defaults to false.
@@ -916,7 +916,7 @@ class MlClient(NamespacedClient):
@query_params("end", "start", "timeout") @query_params("end", "start", "timeout")
def start_datafeed(self, datafeed_id, body=None, params=None, headers=None): def start_datafeed(self, datafeed_id, body=None, params=None, headers=None):
""" """
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-start-datafeed.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-start-datafeed.html>`_
:arg datafeed_id: The ID of the datafeed to start :arg datafeed_id: The ID of the datafeed to start
:arg body: The start datafeed parameters :arg body: The start datafeed parameters
@@ -942,7 +942,7 @@ class MlClient(NamespacedClient):
@query_params("allow_no_datafeeds", "force", "timeout") @query_params("allow_no_datafeeds", "force", "timeout")
def stop_datafeed(self, datafeed_id, params=None, headers=None): def stop_datafeed(self, datafeed_id, params=None, headers=None):
""" """
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-stop-datafeed.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-stop-datafeed.html>`_
:arg datafeed_id: The ID of the datafeed to stop :arg datafeed_id: The ID of the datafeed to stop
:arg allow_no_datafeeds: Whether to ignore if a wildcard :arg allow_no_datafeeds: Whether to ignore if a wildcard
@@ -967,7 +967,7 @@ class MlClient(NamespacedClient):
@query_params() @query_params()
def update_datafeed(self, datafeed_id, body, params=None, headers=None): def update_datafeed(self, datafeed_id, body, params=None, headers=None):
""" """
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-datafeed.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-datafeed.html>`_
:arg datafeed_id: The ID of the datafeed to update :arg datafeed_id: The ID of the datafeed to update
:arg body: The datafeed update settings :arg body: The datafeed update settings
@@ -1006,7 +1006,7 @@ class MlClient(NamespacedClient):
@query_params() @query_params()
def update_job(self, job_id, body, params=None, headers=None): def update_job(self, job_id, body, params=None, headers=None):
""" """
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-job.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-job.html>`_
:arg job_id: The ID of the job to create :arg job_id: The ID of the job to create
:arg body: The job update settings :arg body: The job update settings
@@ -1028,7 +1028,7 @@ class MlClient(NamespacedClient):
self, job_id, snapshot_id, body, params=None, headers=None self, job_id, snapshot_id, body, params=None, headers=None
): ):
""" """
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-snapshot.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-snapshot.html>`_
:arg job_id: The ID of the job to fetch :arg job_id: The ID of the job to fetch
:arg snapshot_id: The ID of the snapshot to update :arg snapshot_id: The ID of the snapshot to update
@@ -1087,12 +1087,13 @@ class MlClient(NamespacedClient):
body=body, body=body,
) )
@query_params() @query_params("force")
def delete_data_frame_analytics(self, id, params=None, headers=None): def delete_data_frame_analytics(self, id, params=None, headers=None):
""" """
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/delete-dfanalytics.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-dfanalytics.html>`_
:arg id: The ID of the data frame analytics to delete :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: if id in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'id'.") raise ValueError("Empty value passed for a required argument 'id'.")
@@ -1104,28 +1105,10 @@ class MlClient(NamespacedClient):
headers=headers, headers=headers,
) )
@query_params()
def estimate_memory_usage(self, body, params=None, headers=None):
"""
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/estimate-memory-usage-dfanalytics.html>`_
: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() @query_params()
def evaluate_data_frame(self, body, params=None, headers=None): def evaluate_data_frame(self, body, params=None, headers=None):
""" """
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/evaluate-dfanalytics.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/evaluate-dfanalytics.html>`_
:arg body: The evaluation definition :arg body: The evaluation definition
""" """
@@ -1143,7 +1126,7 @@ class MlClient(NamespacedClient):
@query_params("allow_no_match", "from_", "size") @query_params("allow_no_match", "from_", "size")
def get_data_frame_analytics(self, id=None, params=None, headers=None): def get_data_frame_analytics(self, id=None, params=None, headers=None):
""" """
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/get-dfanalytics.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/get-dfanalytics.html>`_
:arg id: The ID of the data frame analytics to fetch :arg id: The ID of the data frame analytics to fetch
:arg allow_no_match: Whether to ignore if a wildcard expression :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") @query_params("allow_no_match", "from_", "size")
def get_data_frame_analytics_stats(self, id=None, params=None, headers=None): def get_data_frame_analytics_stats(self, id=None, params=None, headers=None):
""" """
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/get-dfanalytics-stats.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/get-dfanalytics-stats.html>`_
:arg id: The ID of the data frame analytics stats to fetch :arg id: The ID of the data frame analytics stats to fetch
:arg allow_no_match: Whether to ignore if a wildcard expression :arg allow_no_match: Whether to ignore if a wildcard expression
@@ -1191,7 +1174,7 @@ class MlClient(NamespacedClient):
@query_params() @query_params()
def put_data_frame_analytics(self, id, body, params=None, headers=None): def put_data_frame_analytics(self, id, body, params=None, headers=None):
""" """
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/put-dfanalytics.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/put-dfanalytics.html>`_
:arg id: The ID of the data frame analytics to create :arg id: The ID of the data frame analytics to create
:arg body: The data frame analytics configuration :arg body: The data frame analytics configuration
@@ -1211,7 +1194,7 @@ class MlClient(NamespacedClient):
@query_params("timeout") @query_params("timeout")
def start_data_frame_analytics(self, id, body=None, params=None, headers=None): def start_data_frame_analytics(self, id, body=None, params=None, headers=None):
""" """
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/start-dfanalytics.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/start-dfanalytics.html>`_
:arg id: The ID of the data frame analytics to start :arg id: The ID of the data frame analytics to start
:arg body: The start data frame analytics parameters :arg body: The start data frame analytics parameters
@@ -1232,7 +1215,7 @@ class MlClient(NamespacedClient):
@query_params("allow_no_match", "force", "timeout") @query_params("allow_no_match", "force", "timeout")
def stop_data_frame_analytics(self, id, body=None, params=None, headers=None): def stop_data_frame_analytics(self, id, body=None, params=None, headers=None):
""" """
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/stop-dfanalytics.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/stop-dfanalytics.html>`_
:arg id: The ID of the data frame analytics to stop :arg id: The ID of the data frame analytics to stop
:arg body: The stop data frame analytics parameters :arg body: The stop data frame analytics parameters
@@ -1254,3 +1237,117 @@ class MlClient(NamespacedClient):
headers=headers, headers=headers,
body=body, body=body,
) )
@query_params()
def delete_trained_model(self, model_id, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-inference.html>`_
: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
):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/explain-dfanalytics.html>`_
: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):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/get-inference.html>`_
: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):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/get-inference-stats.html>`_
: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,
)
+1 -1
View File
@@ -5,7 +5,7 @@ class MonitoringClient(NamespacedClient):
@query_params("interval", "system_api_version", "system_id") @query_params("interval", "system_api_version", "system_id")
def bulk(self, body, doc_type=None, params=None, headers=None): def bulk(self, body, doc_type=None, params=None, headers=None):
""" """
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/es-monitoring.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/master/monitor-elasticsearch-cluster.html>`_
:arg body: The operation definition and data (action-data :arg body: The operation definition and data (action-data
pairs), separated by newlines pairs), separated by newlines
+1 -1
View File
@@ -88,7 +88,7 @@ class RollupClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument.") raise ValueError("Empty value passed for a required argument.")
return self.transport.perform_request( return self.transport.perform_request(
"GET", "POST",
_make_path(index, doc_type, "_rollup_search"), _make_path(index, doc_type, "_rollup_search"),
params=params, params=params,
headers=headers, headers=headers,
+1 -3
View File
@@ -93,7 +93,6 @@ class SecurityClient(NamespacedClient):
@query_params("refresh") @query_params("refresh")
def delete_privileges(self, application, name, params=None, headers=None): def delete_privileges(self, application, name, params=None, headers=None):
""" """
`<TODO>`_
:arg application: Application name :arg application: Application name
:arg name: Privilege name :arg name: Privilege name
@@ -326,7 +325,7 @@ class SecurityClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'body'.") raise ValueError("Empty value passed for a required argument 'body'.")
return self.transport.perform_request( return self.transport.perform_request(
"GET", "POST",
_make_path("_security", "user", user, "_has_privileges"), _make_path("_security", "user", user, "_has_privileges"),
params=params, params=params,
headers=headers, headers=headers,
@@ -368,7 +367,6 @@ class SecurityClient(NamespacedClient):
@query_params("refresh") @query_params("refresh")
def put_privileges(self, body, params=None, headers=None): def put_privileges(self, body, params=None, headers=None):
""" """
`<TODO>`_
:arg body: The privilege(s) to add :arg body: The privilege(s) to add
:arg refresh: If `true` (the default) then refresh the affected :arg refresh: If `true` (the default) then refresh the affected
+8 -8
View File
@@ -5,7 +5,7 @@ class SlmClient(NamespacedClient):
@query_params() @query_params()
def delete_lifecycle(self, policy_id, params=None, headers=None): def delete_lifecycle(self, policy_id, params=None, headers=None):
""" """
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-delete.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-delete-policy.html>`_
:arg policy_id: The id of the snapshot lifecycle policy to :arg policy_id: The id of the snapshot lifecycle policy to
remove remove
@@ -23,7 +23,7 @@ class SlmClient(NamespacedClient):
@query_params() @query_params()
def execute_lifecycle(self, policy_id, params=None, headers=None): def execute_lifecycle(self, policy_id, params=None, headers=None):
""" """
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-execute.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-execute-lifecycle.html>`_
:arg policy_id: The id of the snapshot lifecycle policy to be :arg policy_id: The id of the snapshot lifecycle policy to be
executed executed
@@ -51,7 +51,7 @@ class SlmClient(NamespacedClient):
@query_params() @query_params()
def get_lifecycle(self, policy_id=None, params=None, headers=None): def get_lifecycle(self, policy_id=None, params=None, headers=None):
""" """
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-get.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-get-policy.html>`_
:arg policy_id: Comma-separated list of snapshot lifecycle :arg policy_id: Comma-separated list of snapshot lifecycle
policies to retrieve policies to retrieve
@@ -66,7 +66,7 @@ class SlmClient(NamespacedClient):
@query_params() @query_params()
def get_stats(self, params=None, headers=None): def get_stats(self, params=None, headers=None):
""" """
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/slm-get-stats.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/master/slm-api-get-stats.html>`_
""" """
return self.transport.perform_request( return self.transport.perform_request(
@@ -76,7 +76,7 @@ class SlmClient(NamespacedClient):
@query_params() @query_params()
def put_lifecycle(self, policy_id, body=None, params=None, headers=None): def put_lifecycle(self, policy_id, body=None, params=None, headers=None):
""" """
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-put.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-put-policy.html>`_
:arg policy_id: The id of the snapshot lifecycle policy :arg policy_id: The id of the snapshot lifecycle policy
:arg body: The snapshot lifecycle policy definition to register :arg body: The snapshot lifecycle policy definition to register
@@ -95,7 +95,7 @@ class SlmClient(NamespacedClient):
@query_params() @query_params()
def get_status(self, params=None, headers=None): def get_status(self, params=None, headers=None):
""" """
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-get-status.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-get-status.html>`_
""" """
return self.transport.perform_request( return self.transport.perform_request(
@@ -105,7 +105,7 @@ class SlmClient(NamespacedClient):
@query_params() @query_params()
def start(self, params=None, headers=None): def start(self, params=None, headers=None):
""" """
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-start.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-start.html>`_
""" """
return self.transport.perform_request( return self.transport.perform_request(
@@ -115,7 +115,7 @@ class SlmClient(NamespacedClient):
@query_params() @query_params()
def stop(self, params=None, headers=None): def stop(self, params=None, headers=None):
""" """
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-stop.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-stop.html>`_
""" """
return self.transport.perform_request( return self.transport.perform_request(
-3
View File
@@ -5,7 +5,6 @@ class SqlClient(NamespacedClient):
@query_params() @query_params()
def clear_cursor(self, body, params=None, headers=None): def clear_cursor(self, body, params=None, headers=None):
""" """
`<Clear SQL cursor>`_
:arg body: Specify the cursor value in the `cursor` element to :arg body: Specify the cursor value in the `cursor` element to
clean the cursor. clean the cursor.
@@ -20,7 +19,6 @@ class SqlClient(NamespacedClient):
@query_params("format") @query_params("format")
def query(self, body, params=None, headers=None): def query(self, body, params=None, headers=None):
""" """
`<Execute SQL>`_
:arg body: Use the `query` element to start a query. Use the :arg body: Use the `query` element to start a query. Use the
`cursor` element to continue a query. `cursor` element to continue a query.
@@ -37,7 +35,6 @@ class SqlClient(NamespacedClient):
@query_params() @query_params()
def translate(self, body, params=None, headers=None): def translate(self, body, params=None, headers=None):
""" """
`<Translate SQL into Elasticsearch queries>`_
:arg body: Specify the query in the `query` element. :arg body: Specify the query in the `query` element.
""" """
+11 -1
View File
@@ -137,7 +137,13 @@ class TransformClient(NamespacedClient):
headers=headers, 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): def stop_transform(self, transform_id, params=None, headers=None):
""" """
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/stop-transform.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/stop-transform.html>`_
@@ -146,8 +152,12 @@ class TransformClient(NamespacedClient):
:arg allow_no_match: Whether to ignore if a wildcard expression :arg allow_no_match: Whether to ignore if a wildcard expression
matches no transforms. (This includes `_all` string or when no matches no transforms. (This includes `_all` string or when no
transforms have been specified) 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 :arg timeout: Controls the time to wait until the transform has
stopped. Default to 30 seconds 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 :arg wait_for_completion: Whether to wait for the transform to
fully stop before returning or not. Default to false fully stop before returning or not. Default to false
""" """
+8 -8
View File
@@ -5,7 +5,7 @@ class WatcherClient(NamespacedClient):
@query_params() @query_params()
def ack_watch(self, watch_id, action_id=None, params=None, headers=None): def ack_watch(self, watch_id, action_id=None, params=None, headers=None):
""" """
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-ack-watch.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-ack-watch.html>`_
:arg watch_id: Watch ID :arg watch_id: Watch ID
:arg action_id: A comma-separated list of the action ids to be :arg action_id: A comma-separated list of the action ids to be
@@ -58,7 +58,7 @@ class WatcherClient(NamespacedClient):
@query_params() @query_params()
def delete_watch(self, id, params=None, headers=None): def delete_watch(self, id, params=None, headers=None):
""" """
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-delete-watch.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-delete-watch.html>`_
:arg id: Watch ID :arg id: Watch ID
""" """
@@ -75,7 +75,7 @@ class WatcherClient(NamespacedClient):
@query_params("debug") @query_params("debug")
def execute_watch(self, body=None, id=None, params=None, headers=None): def execute_watch(self, body=None, id=None, params=None, headers=None):
""" """
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-execute-watch.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-execute-watch.html>`_
:arg body: Execution control :arg body: Execution control
:arg id: Watch ID :arg id: Watch ID
@@ -93,7 +93,7 @@ class WatcherClient(NamespacedClient):
@query_params() @query_params()
def get_watch(self, id, params=None, headers=None): def get_watch(self, id, params=None, headers=None):
""" """
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-get-watch.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-get-watch.html>`_
:arg id: Watch ID :arg id: Watch ID
""" """
@@ -107,7 +107,7 @@ class WatcherClient(NamespacedClient):
@query_params("active", "if_primary_term", "if_seq_no", "version") @query_params("active", "if_primary_term", "if_seq_no", "version")
def put_watch(self, id, body=None, params=None, headers=None): def put_watch(self, id, body=None, params=None, headers=None):
""" """
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-put-watch.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-put-watch.html>`_
:arg id: Watch ID :arg id: Watch ID
:arg body: The watch :arg body: The watch
@@ -132,7 +132,7 @@ class WatcherClient(NamespacedClient):
@query_params() @query_params()
def start(self, params=None, headers=None): def start(self, params=None, headers=None):
""" """
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-start.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-start.html>`_
""" """
return self.transport.perform_request( return self.transport.perform_request(
@@ -142,7 +142,7 @@ class WatcherClient(NamespacedClient):
@query_params("emit_stacktraces") @query_params("emit_stacktraces")
def stats(self, metric=None, params=None, headers=None): def stats(self, metric=None, params=None, headers=None):
""" """
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-stats.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-stats.html>`_
:arg metric: Controls what additional stat metrics should be :arg metric: Controls what additional stat metrics should be
include in the response Valid choices: _all, queued_watches, include in the response Valid choices: _all, queued_watches,
@@ -163,7 +163,7 @@ class WatcherClient(NamespacedClient):
@query_params() @query_params()
def stop(self, params=None, headers=None): def stop(self, params=None, headers=None):
""" """
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-stop.html>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-stop.html>`_
""" """
return self.transport.perform_request( return self.transport.perform_request(
+1 -1
View File
@@ -21,7 +21,7 @@ class XPackClient(NamespacedClient):
@query_params("master_timeout") @query_params("master_timeout")
def usage(self, params=None, headers=None): def usage(self, params=None, headers=None):
""" """
`<Retrieve information about xpack features usage>`_ `<https://www.elastic.co/guide/en/elasticsearch/reference/current/usage-api.html>`_
:arg master_timeout: Specify timeout for watch write operation :arg master_timeout: Specify timeout for watch write operation
""" """
+1 -1
View File
@@ -80,7 +80,7 @@ class TestClient(ElasticsearchTestCase):
def test_from_in_search(self): def test_from_in_search(self):
self.client.search(index="i", from_=10) 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) self.assertEquals([({"from": "10"}, {}, None)], calls)
def test_repr_contains_hosts(self): def test_repr_contains_hosts(self):
@@ -37,9 +37,6 @@ SKIP_TESTS = {
"*": { "*": {
# Can't figure out the get_alias(expand_wildcards=open) failure. # Can't figure out the get_alias(expand_wildcards=open) failure.
"TestIndicesGetAlias10Basic", "TestIndicesGetAlias10Basic",
# Scripts are 7.6+
"TestScripts20GetScriptContext",
"TestScripts25GetScriptLanguages",
# Disallowing expensive queries is 7.7+ # Disallowing expensive queries is 7.7+
"TestSearch320DisallowQueries", "TestSearch320DisallowQueries",
} }
+21 -5
View File
@@ -82,12 +82,11 @@ class Module:
if line.startswith("class"): if line.startswith("class"):
break break
self.header = "\n".join(header_lines) self.header = "\n".join(header_lines)
defined_apis = re.findall( self.orders = re.findall(
r'\n def ([a-z_]+)\([^\n]*\n *"""\n *([\w\W]*?)(?:`<|""")', r'\n def ([a-z_]+)\(',
content, content,
re.MULTILINE, re.MULTILINE
) )
self.orders = list(map(lambda x: x[0], defined_apis))
def _position(self, api): def _position(self, api):
try: try:
@@ -128,6 +127,14 @@ class API:
self.description = definition["documentation"].get("description", "") self.description = definition["documentation"].get("description", "")
self.doc_url = definition["documentation"].get("url", "") 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 @property
def all_parts(self): def all_parts(self):
parts = {} parts = {}
@@ -188,7 +195,12 @@ class API:
@property @property
def method(self): 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 @property
def url_parts(self): def url_parts(self):
@@ -246,6 +258,10 @@ def read_modules():
if "." in name: if "." in name:
namespace, name = name.rsplit(".", 1) 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: if namespace not in modules:
modules[namespace] = Module(namespace) modules[namespace] = Module(namespace)