[7.x] Add support for X-Opaque-Id

This commit is contained in:
Seth Michael Larson
2020-03-11 16:33:15 -05:00
committed by GitHub
parent 8074ff294b
commit 9219c92779
45 changed files with 1193 additions and 541 deletions
+18
View File
@@ -60,6 +60,24 @@ connection class::
Elasticsearch server. This timeout is internal and doesn't guarantee that the
request will end in the specified time.
Tracking Requests with Opaque ID
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You can enrich your requests against Elasticsearch with an identifier string, that allows you to discover this identifier
in `deprecation logs <https://www.elastic.co/guide/en/elasticsearch/reference/7.4/logging.html#deprecation-logging>`_, to support you with
`identifying search slow log origin <https://www.elastic.co/guide/en/elasticsearch/reference/7.4/index-modules-slowlog.html#_identifying_search_slow_log_origin>`_
or to help with `identifying running tasks <https://www.elastic.co/guide/en/elasticsearch/reference/current/tasks.html#_identifying_running_tasks>`_.
.. code-block:: python
import elasticsearch
# You can add to the client to apply to all requests
client = elasticsearch.Elasticsearch(opaque_id="[email protected]_user1234")
# Or you can apply per-request for more granularity.
resp = client.get(index="test", id="1", opaque_id="[email protected]_user1234")
.. py:module:: elasticsearch
+143 -63
View File
@@ -270,25 +270,29 @@ class Elasticsearch(object):
# AUTO-GENERATED-API-DEFINITIONS #
@query_params()
def ping(self, params=None):
def ping(self, params=None, headers=None):
"""
Returns whether the cluster is running.
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html>`_
"""
try:
return self.transport.perform_request("HEAD", "/", params=params)
return self.transport.perform_request(
"HEAD", "/", params=params, headers=headers
)
except TransportError:
return False
@query_params()
def info(self, params=None):
def info(self, params=None, headers=None):
"""
Returns basic information about the cluster.
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html>`_
"""
return self.transport.perform_request("GET", "/", params=params)
return self.transport.perform_request(
"GET", "/", params=params, headers=headers
)
@query_params(
"pipeline",
@@ -299,7 +303,7 @@ class Elasticsearch(object):
"version_type",
"wait_for_active_shards",
)
def create(self, index, id, body, doc_type=None, params=None):
def create(self, index, id, body, doc_type=None, params=None, headers=None):
"""
Creates a new document in the index. Returns a 409 response when a document
with a same ID already exists in the index.
@@ -334,7 +338,11 @@ class Elasticsearch(object):
doc_type = "_doc"
return self.transport.perform_request(
"PUT", _make_path(index, doc_type, id, "_create"), params=params, body=body
"PUT",
_make_path(index, doc_type, id, "_create"),
params=params,
headers=headers,
body=body,
)
@query_params(
@@ -349,7 +357,7 @@ class Elasticsearch(object):
"version_type",
"wait_for_active_shards",
)
def index(self, index, body, doc_type=None, id=None, params=None):
def index(self, index, body, doc_type=None, id=None, params=None, headers=None):
"""
Creates or updates a document in an index.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-index_.html>`_
@@ -395,6 +403,7 @@ class Elasticsearch(object):
"POST" if id in SKIP_IN_PATH else "PUT",
_make_path(index, doc_type, id),
params=params,
headers=headers,
body=body,
)
@@ -408,7 +417,7 @@ class Elasticsearch(object):
"timeout",
"wait_for_active_shards",
)
def bulk(self, body, index=None, doc_type=None, params=None):
def bulk(self, body, index=None, doc_type=None, params=None, headers=None):
"""
Allows to perform multiple index/update/delete operations in a single request.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-bulk.html>`_
@@ -446,11 +455,15 @@ class Elasticsearch(object):
body = _bulk_body(self.transport.serializer, body)
return self.transport.perform_request(
"POST", _make_path(index, doc_type, "_bulk"), params=params, body=body
"POST",
_make_path(index, doc_type, "_bulk"),
params=params,
headers=headers,
body=body,
)
@query_params()
def clear_scroll(self, body=None, scroll_id=None, params=None):
def clear_scroll(self, body=None, scroll_id=None, params=None, headers=None):
"""
Explicitly clears the search context for a scroll.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/search-request-body.html#_clear_scroll_api>`_
@@ -467,7 +480,7 @@ class Elasticsearch(object):
params["scroll_id"] = scroll_id
return self.transport.perform_request(
"DELETE", "/_search/scroll", params=params, body=body
"DELETE", "/_search/scroll", params=params, headers=headers, body=body
)
@query_params(
@@ -486,7 +499,7 @@ class Elasticsearch(object):
"routing",
"terminate_after",
)
def count(self, body=None, index=None, doc_type=None, params=None):
def count(self, body=None, index=None, doc_type=None, params=None, headers=None):
"""
Returns number of documents matching a query.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/search-count.html>`_
@@ -526,7 +539,11 @@ class Elasticsearch(object):
reaching which the query execution will terminate early
"""
return self.transport.perform_request(
"POST", _make_path(index, doc_type, "_count"), params=params, body=body
"POST",
_make_path(index, doc_type, "_count"),
params=params,
headers=headers,
body=body,
)
@query_params(
@@ -539,7 +556,7 @@ class Elasticsearch(object):
"version_type",
"wait_for_active_shards",
)
def delete(self, index, id, doc_type=None, params=None):
def delete(self, index, id, doc_type=None, params=None, headers=None):
"""
Removes a document from the index.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-delete.html>`_
@@ -576,7 +593,7 @@ class Elasticsearch(object):
doc_type = "_doc"
return self.transport.perform_request(
"DELETE", _make_path(index, doc_type, id), params=params
"DELETE", _make_path(index, doc_type, id), params=params, headers=headers
)
@query_params(
@@ -613,7 +630,7 @@ class Elasticsearch(object):
"wait_for_active_shards",
"wait_for_completion",
)
def delete_by_query(self, index, body, doc_type=None, params=None):
def delete_by_query(self, index, body, doc_type=None, params=None, headers=None):
"""
Deletes documents matching the provided query.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-delete-by-query.html>`_
@@ -702,11 +719,12 @@ class Elasticsearch(object):
"POST",
_make_path(index, doc_type, "_delete_by_query"),
params=params,
headers=headers,
body=body,
)
@query_params("requests_per_second")
def delete_by_query_rethrottle(self, task_id, params=None):
def delete_by_query_rethrottle(self, task_id, params=None, headers=None):
"""
Changes the number of requests per second for a particular Delete By Query
operation.
@@ -723,10 +741,11 @@ class Elasticsearch(object):
"POST",
_make_path("_delete_by_query", task_id, "_rethrottle"),
params=params,
headers=headers,
)
@query_params("master_timeout", "timeout")
def delete_script(self, id, params=None):
def delete_script(self, id, params=None, headers=None):
"""
Deletes a script.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html>`_
@@ -739,7 +758,7 @@ class Elasticsearch(object):
raise ValueError("Empty value passed for a required argument 'id'.")
return self.transport.perform_request(
"DELETE", _make_path("_scripts", id), params=params
"DELETE", _make_path("_scripts", id), params=params, headers=headers
)
@query_params(
@@ -754,7 +773,7 @@ class Elasticsearch(object):
"version",
"version_type",
)
def exists(self, index, id, doc_type=None, params=None):
def exists(self, index, id, doc_type=None, params=None, headers=None):
"""
Returns information about whether a document exists in an index.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html>`_
@@ -790,7 +809,7 @@ class Elasticsearch(object):
doc_type = "_doc"
return self.transport.perform_request(
"HEAD", _make_path(index, doc_type, id), params=params
"HEAD", _make_path(index, doc_type, id), params=params, headers=headers
)
@query_params(
@@ -804,7 +823,7 @@ class Elasticsearch(object):
"version",
"version_type",
)
def exists_source(self, index, id, doc_type=None, params=None):
def exists_source(self, index, id, doc_type=None, params=None, headers=None):
"""
Returns information about whether a document source exists in an index.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html>`_
@@ -835,7 +854,10 @@ class Elasticsearch(object):
raise ValueError("Empty value passed for a required argument.")
return self.transport.perform_request(
"HEAD", _make_path(index, doc_type, id, "_source"), params=params
"HEAD",
_make_path(index, doc_type, id, "_source"),
params=params,
headers=headers,
)
@query_params(
@@ -852,7 +874,7 @@ class Elasticsearch(object):
"routing",
"stored_fields",
)
def explain(self, index, id, body=None, doc_type=None, params=None):
def explain(self, index, id, body=None, doc_type=None, params=None, headers=None):
"""
Returns information about why a specific matches (or doesn't match) a query.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/search-explain.html>`_
@@ -891,7 +913,11 @@ class Elasticsearch(object):
doc_type = "_doc"
return self.transport.perform_request(
"GET", _make_path(index, doc_type, id, "_explain"), params=params, body=body
"GET",
_make_path(index, doc_type, id, "_explain"),
params=params,
headers=headers,
body=body,
)
@query_params(
@@ -901,7 +927,7 @@ class Elasticsearch(object):
"ignore_unavailable",
"include_unmapped",
)
def field_caps(self, index=None, params=None):
def field_caps(self, index=None, params=None, headers=None):
"""
Returns the information about the capabilities of fields among multiple
indices.
@@ -922,7 +948,7 @@ class Elasticsearch(object):
be included in the response.
"""
return self.transport.perform_request(
"GET", _make_path(index, "_field_caps"), params=params
"GET", _make_path(index, "_field_caps"), params=params, headers=headers
)
@query_params(
@@ -937,7 +963,7 @@ class Elasticsearch(object):
"version",
"version_type",
)
def get(self, index, id, doc_type=None, params=None):
def get(self, index, id, doc_type=None, params=None, headers=None):
"""
Returns a document.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html>`_
@@ -973,11 +999,11 @@ class Elasticsearch(object):
doc_type = "_doc"
return self.transport.perform_request(
"GET", _make_path(index, doc_type, id), params=params
"GET", _make_path(index, doc_type, id), params=params, headers=headers
)
@query_params("master_timeout")
def get_script(self, id, params=None):
def get_script(self, id, params=None, headers=None):
"""
Returns a script.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html>`_
@@ -989,7 +1015,7 @@ class Elasticsearch(object):
raise ValueError("Empty value passed for a required argument 'id'.")
return self.transport.perform_request(
"GET", _make_path("_scripts", id), params=params
"GET", _make_path("_scripts", id), params=params, headers=headers
)
@query_params(
@@ -1003,7 +1029,7 @@ class Elasticsearch(object):
"version",
"version_type",
)
def get_source(self, index, id, doc_type=None, params=None):
def get_source(self, index, id, doc_type=None, params=None, headers=None):
"""
Returns the source of a document.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html>`_
@@ -1037,7 +1063,10 @@ class Elasticsearch(object):
doc_type = "_doc"
return self.transport.perform_request(
"GET", _make_path(index, doc_type, id, "_source"), params=params
"GET",
_make_path(index, doc_type, id, "_source"),
params=params,
headers=headers,
)
@query_params(
@@ -1050,7 +1079,7 @@ class Elasticsearch(object):
"routing",
"stored_fields",
)
def mget(self, body, index=None, doc_type=None, params=None):
def mget(self, body, index=None, doc_type=None, params=None, headers=None):
"""
Allows to get multiple documents in one request.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-multi-get.html>`_
@@ -1080,7 +1109,11 @@ class Elasticsearch(object):
raise ValueError("Empty value passed for a required argument 'body'.")
return self.transport.perform_request(
"GET", _make_path(index, doc_type, "_mget"), params=params, body=body
"GET",
_make_path(index, doc_type, "_mget"),
params=params,
headers=headers,
body=body,
)
@query_params(
@@ -1092,7 +1125,7 @@ class Elasticsearch(object):
"search_type",
"typed_keys",
)
def msearch(self, body, index=None, doc_type=None, params=None):
def msearch(self, body, index=None, doc_type=None, params=None, headers=None):
"""
Allows to execute several search operations in one request.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/search-multi-search.html>`_
@@ -1132,13 +1165,19 @@ class Elasticsearch(object):
body = _bulk_body(self.transport.serializer, body)
return self.transport.perform_request(
"GET", _make_path(index, doc_type, "_msearch"), params=params, body=body
"GET",
_make_path(index, doc_type, "_msearch"),
params=params,
headers=headers,
body=body,
)
@query_params(
"max_concurrent_searches", "rest_total_hits_as_int", "search_type", "typed_keys"
)
def msearch_template(self, body, index=None, doc_type=None, params=None):
def msearch_template(
self, body, index=None, doc_type=None, params=None, headers=None
):
"""
Allows to execute several search template operations in one request.
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html>`_
@@ -1167,6 +1206,7 @@ class Elasticsearch(object):
"GET",
_make_path(index, doc_type, "_msearch", "template"),
params=params,
headers=headers,
body=body,
)
@@ -1184,7 +1224,9 @@ class Elasticsearch(object):
"version",
"version_type",
)
def mtermvectors(self, body=None, index=None, doc_type=None, params=None):
def mtermvectors(
self, body=None, index=None, doc_type=None, params=None, headers=None
):
"""
Returns multiple termvectors in one request.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-multi-termvectors.html>`_
@@ -1230,11 +1272,12 @@ class Elasticsearch(object):
"GET",
_make_path(index, doc_type, "_mtermvectors"),
params=params,
headers=headers,
body=body,
)
@query_params("master_timeout", "timeout")
def put_script(self, id, body, context=None, params=None):
def put_script(self, id, body, context=None, params=None, headers=None):
"""
Creates or updates a script.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html>`_
@@ -1251,11 +1294,15 @@ class Elasticsearch(object):
raise ValueError("Empty value passed for a required argument.")
return self.transport.perform_request(
"PUT", _make_path("_scripts", id, context), params=params, body=body
"PUT",
_make_path("_scripts", id, context),
params=params,
headers=headers,
body=body,
)
@query_params("allow_no_indices", "expand_wildcards", "ignore_unavailable")
def rank_eval(self, body, index=None, params=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
search queries
@@ -1278,7 +1325,11 @@ class Elasticsearch(object):
raise ValueError("Empty value passed for a required argument 'body'.")
return self.transport.perform_request(
"GET", _make_path(index, "_rank_eval"), params=params, body=body
"GET",
_make_path(index, "_rank_eval"),
params=params,
headers=headers,
body=body,
)
@query_params(
@@ -1291,7 +1342,7 @@ class Elasticsearch(object):
"wait_for_active_shards",
"wait_for_completion",
)
def reindex(self, body, params=None):
def reindex(self, body, params=None, headers=None):
"""
Allows to copy documents from one index to another, optionally filtering the
source documents by a query, changing the destination index settings, or
@@ -1324,11 +1375,11 @@ class Elasticsearch(object):
raise ValueError("Empty value passed for a required argument 'body'.")
return self.transport.perform_request(
"POST", "/_reindex", params=params, body=body
"POST", "/_reindex", params=params, headers=headers, body=body
)
@query_params("requests_per_second")
def reindex_rethrottle(self, task_id, params=None):
def reindex_rethrottle(self, task_id, params=None, headers=None):
"""
Changes the number of requests per second for a particular Reindex operation.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-reindex.html>`_
@@ -1341,11 +1392,14 @@ class Elasticsearch(object):
raise ValueError("Empty value passed for a required argument 'task_id'.")
return self.transport.perform_request(
"POST", _make_path("_reindex", task_id, "_rethrottle"), params=params
"POST",
_make_path("_reindex", task_id, "_rethrottle"),
params=params,
headers=headers,
)
@query_params()
def render_search_template(self, body=None, id=None, params=None):
def render_search_template(self, body=None, id=None, params=None, headers=None):
"""
Allows to use the Mustache language to pre-render a search definition.
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html#_validating_templates>`_
@@ -1354,11 +1408,15 @@ class Elasticsearch(object):
:arg id: The id of the stored search template
"""
return self.transport.perform_request(
"GET", _make_path("_render", "template", id), params=params, body=body
"GET",
_make_path("_render", "template", id),
params=params,
headers=headers,
body=body,
)
@query_params()
def scripts_painless_execute(self, body=None, params=None):
def scripts_painless_execute(self, body=None, params=None, headers=None):
"""
Allows an arbitrary script to be executed and a result to be returned
`<https://www.elastic.co/guide/en/elasticsearch/painless/master/painless-execute-api.html>`_
@@ -1366,11 +1424,15 @@ class Elasticsearch(object):
:arg body: The script to execute
"""
return self.transport.perform_request(
"GET", "/_scripts/painless/_execute", params=params, body=body
"GET",
"/_scripts/painless/_execute",
params=params,
headers=headers,
body=body,
)
@query_params("rest_total_hits_as_int", "scroll")
def scroll(self, body=None, scroll_id=None, params=None):
def scroll(self, body=None, scroll_id=None, params=None, headers=None):
"""
Allows to retrieve a large numbers of results from a single search request.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/search-request-body.html#request-body-search-scroll>`_
@@ -1392,7 +1454,7 @@ class Elasticsearch(object):
params["scroll_id"] = scroll_id
return self.transport.perform_request(
"GET", "/_search/scroll", params=params, body=body
"GET", "/_search/scroll", params=params, headers=headers, body=body
)
@query_params(
@@ -1439,7 +1501,7 @@ class Elasticsearch(object):
"typed_keys",
"version",
)
def search(self, body=None, index=None, doc_type=None, params=None):
def search(self, body=None, index=None, doc_type=None, params=None, headers=None):
"""
Returns results matching a query.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/search-search.html>`_
@@ -1545,7 +1607,11 @@ class Elasticsearch(object):
params["from"] = params.pop("from_")
return self.transport.perform_request(
"GET", _make_path(index, doc_type, "_search"), params=params, body=body
"GET",
_make_path(index, doc_type, "_search"),
params=params,
headers=headers,
body=body,
)
@query_params(
@@ -1556,7 +1622,7 @@ class Elasticsearch(object):
"preference",
"routing",
)
def search_shards(self, index=None, params=None):
def search_shards(self, index=None, params=None, headers=None):
"""
Returns information about the indices and shards that a search request would be
executed against.
@@ -1579,7 +1645,7 @@ class Elasticsearch(object):
:arg routing: Specific routing value
"""
return self.transport.perform_request(
"GET", _make_path(index, "_search_shards"), params=params
"GET", _make_path(index, "_search_shards"), params=params, headers=headers
)
@query_params(
@@ -1596,7 +1662,9 @@ class Elasticsearch(object):
"search_type",
"typed_keys",
)
def search_template(self, body, index=None, doc_type=None, params=None):
def search_template(
self, body, index=None, doc_type=None, params=None, headers=None
):
"""
Allows to use the Mustache language to pre-render a search definition.
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html>`_
@@ -1639,6 +1707,7 @@ class Elasticsearch(object):
"GET",
_make_path(index, doc_type, "_search", "template"),
params=params,
headers=headers,
body=body,
)
@@ -1655,7 +1724,9 @@ class Elasticsearch(object):
"version",
"version_type",
)
def termvectors(self, index, body=None, doc_type=None, id=None, params=None):
def termvectors(
self, index, body=None, doc_type=None, id=None, params=None, headers=None
):
"""
Returns information and statistics about terms in the fields of a particular
document.
@@ -1698,6 +1769,7 @@ class Elasticsearch(object):
"GET",
_make_path(index, doc_type, id, "_termvectors"),
params=params,
headers=headers,
body=body,
)
@@ -1714,7 +1786,7 @@ class Elasticsearch(object):
"timeout",
"wait_for_active_shards",
)
def update(self, index, id, body, doc_type=None, params=None):
def update(self, index, id, body, doc_type=None, params=None, headers=None):
"""
Updates a document with a script or partial document.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-update.html>`_
@@ -1759,7 +1831,11 @@ class Elasticsearch(object):
doc_type = "_doc"
return self.transport.perform_request(
"POST", _make_path(index, doc_type, id, "_update"), params=params, body=body
"POST",
_make_path(index, doc_type, id, "_update"),
params=params,
headers=headers,
body=body,
)
@query_params(
@@ -1799,7 +1875,9 @@ class Elasticsearch(object):
"wait_for_active_shards",
"wait_for_completion",
)
def update_by_query(self, index, body=None, doc_type=None, params=None):
def update_by_query(
self, index, body=None, doc_type=None, params=None, headers=None
):
"""
Performs an update on every document in the index without changing the source,
for example to pick up a mapping change.
@@ -1893,11 +1971,12 @@ class Elasticsearch(object):
"POST",
_make_path(index, doc_type, "_update_by_query"),
params=params,
headers=headers,
body=body,
)
@query_params("requests_per_second")
def update_by_query_rethrottle(self, task_id, params=None):
def update_by_query_rethrottle(self, task_id, params=None, headers=None):
"""
Changes the number of requests per second for a particular Update By Query
operation.
@@ -1914,4 +1993,5 @@ class Elasticsearch(object):
"POST",
_make_path("_update_by_query", task_id, "_rethrottle"),
params=params,
headers=headers,
)
+63 -39
View File
@@ -3,7 +3,7 @@ from .utils import NamespacedClient, query_params, _make_path
class CatClient(NamespacedClient):
@query_params("format", "h", "help", "local", "s", "v")
def aliases(self, name=None, params=None):
def aliases(self, name=None, params=None, headers=None):
"""
Shows information about currently configured aliases to indices including
filter and routing infos.
@@ -21,11 +21,11 @@ class CatClient(NamespacedClient):
:arg v: Verbose mode. Display column headers
"""
return self.transport.perform_request(
"GET", _make_path("_cat", "aliases", name), params=params
"GET", _make_path("_cat", "aliases", name), params=params, headers=headers
)
@query_params("bytes", "format", "h", "help", "local", "master_timeout", "s", "v")
def allocation(self, node_id=None, params=None):
def allocation(self, node_id=None, params=None, headers=None):
"""
Provides a snapshot of how many shards are allocated to each data node and how
much disk space they are using.
@@ -48,11 +48,14 @@ class CatClient(NamespacedClient):
:arg v: Verbose mode. Display column headers
"""
return self.transport.perform_request(
"GET", _make_path("_cat", "allocation", node_id), params=params
"GET",
_make_path("_cat", "allocation", node_id),
params=params,
headers=headers,
)
@query_params("format", "h", "help", "s", "v")
def count(self, index=None, params=None):
def count(self, index=None, params=None, headers=None):
"""
Provides quick access to the document count of the entire cluster, or
individual indices.
@@ -69,11 +72,11 @@ class CatClient(NamespacedClient):
:arg v: Verbose mode. Display column headers
"""
return self.transport.perform_request(
"GET", _make_path("_cat", "count", index), params=params
"GET", _make_path("_cat", "count", index), params=params, headers=headers
)
@query_params("format", "h", "help", "s", "time", "ts", "v")
def health(self, params=None):
def health(self, params=None, headers=None):
"""
Returns a concise representation of the cluster health.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-health.html>`_
@@ -90,10 +93,12 @@ class CatClient(NamespacedClient):
:arg ts: Set to false to disable timestamping Default: True
:arg v: Verbose mode. Display column headers
"""
return self.transport.perform_request("GET", "/_cat/health", params=params)
return self.transport.perform_request(
"GET", "/_cat/health", params=params, headers=headers
)
@query_params("help", "s")
def help(self, params=None):
def help(self, params=None, headers=None):
"""
Returns help for the Cat APIs.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/cat.html>`_
@@ -102,7 +107,9 @@ class CatClient(NamespacedClient):
:arg s: Comma-separated list of column names or column aliases
to sort by
"""
return self.transport.perform_request("GET", "/_cat", params=params)
return self.transport.perform_request(
"GET", "/_cat", params=params, headers=headers
)
@query_params(
"bytes",
@@ -118,7 +125,7 @@ class CatClient(NamespacedClient):
"time",
"v",
)
def indices(self, index=None, params=None):
def indices(self, index=None, params=None, headers=None):
"""
Returns information about indices: number of primaries and replicas, document
counts, disk size, ...
@@ -151,11 +158,11 @@ class CatClient(NamespacedClient):
:arg v: Verbose mode. Display column headers
"""
return self.transport.perform_request(
"GET", _make_path("_cat", "indices", index), params=params
"GET", _make_path("_cat", "indices", index), params=params, headers=headers
)
@query_params("format", "h", "help", "local", "master_timeout", "s", "v")
def master(self, params=None):
def master(self, params=None, headers=None):
"""
Returns information about the master node.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-master.html>`_
@@ -172,7 +179,9 @@ class CatClient(NamespacedClient):
to sort by
:arg v: Verbose mode. Display column headers
"""
return self.transport.perform_request("GET", "/_cat/master", params=params)
return self.transport.perform_request(
"GET", "/_cat/master", params=params, headers=headers
)
@query_params(
"bytes",
@@ -186,7 +195,7 @@ class CatClient(NamespacedClient):
"time",
"v",
)
def nodes(self, params=None):
def nodes(self, params=None, headers=None):
"""
Returns basic statistics about performance of cluster nodes.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-nodes.html>`_
@@ -210,12 +219,14 @@ class CatClient(NamespacedClient):
(Milliseconds), micros (Microseconds), nanos (Nanoseconds)
:arg v: Verbose mode. Display column headers
"""
return self.transport.perform_request("GET", "/_cat/nodes", params=params)
return self.transport.perform_request(
"GET", "/_cat/nodes", params=params, headers=headers
)
@query_params(
"active_only", "bytes", "detailed", "format", "h", "help", "s", "time", "v"
)
def recovery(self, index=None, params=None):
def recovery(self, index=None, params=None, headers=None):
"""
Returns information about index shard recoveries, both on-going completed.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-recovery.html>`_
@@ -242,13 +253,13 @@ class CatClient(NamespacedClient):
:arg v: Verbose mode. Display column headers
"""
return self.transport.perform_request(
"GET", _make_path("_cat", "recovery", index), params=params
"GET", _make_path("_cat", "recovery", index), params=params, headers=headers
)
@query_params(
"bytes", "format", "h", "help", "local", "master_timeout", "s", "time", "v"
)
def shards(self, index=None, params=None):
def shards(self, index=None, params=None, headers=None):
"""
Provides a detailed view of shard allocation on nodes.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-shards.html>`_
@@ -273,11 +284,11 @@ class CatClient(NamespacedClient):
:arg v: Verbose mode. Display column headers
"""
return self.transport.perform_request(
"GET", _make_path("_cat", "shards", index), params=params
"GET", _make_path("_cat", "shards", index), params=params, headers=headers
)
@query_params("bytes", "format", "h", "help", "s", "v")
def segments(self, index=None, params=None):
def segments(self, index=None, params=None, headers=None):
"""
Provides low-level information about the segments in the shards of an index.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-segments.html>`_
@@ -295,11 +306,11 @@ class CatClient(NamespacedClient):
:arg v: Verbose mode. Display column headers
"""
return self.transport.perform_request(
"GET", _make_path("_cat", "segments", index), params=params
"GET", _make_path("_cat", "segments", index), params=params, headers=headers
)
@query_params("format", "h", "help", "local", "master_timeout", "s", "time", "v")
def pending_tasks(self, params=None):
def pending_tasks(self, params=None, headers=None):
"""
Returns a concise representation of the cluster pending tasks.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-pending-tasks.html>`_
@@ -320,11 +331,11 @@ class CatClient(NamespacedClient):
:arg v: Verbose mode. Display column headers
"""
return self.transport.perform_request(
"GET", "/_cat/pending_tasks", params=params
"GET", "/_cat/pending_tasks", params=params, headers=headers
)
@query_params("format", "h", "help", "local", "master_timeout", "s", "size", "v")
def thread_pool(self, thread_pool_patterns=None, params=None):
def thread_pool(self, thread_pool_patterns=None, params=None, headers=None):
"""
Returns cluster-wide thread pool statistics per node. By default the active,
queue and rejected statistics are returned for all thread pools.
@@ -350,10 +361,11 @@ class CatClient(NamespacedClient):
"GET",
_make_path("_cat", "thread_pool", thread_pool_patterns),
params=params,
headers=headers,
)
@query_params("bytes", "format", "h", "help", "s", "v")
def fielddata(self, fields=None, params=None):
def fielddata(self, fields=None, params=None, headers=None):
"""
Shows how much heap memory is currently being used by fielddata on every data
node in the cluster.
@@ -374,11 +386,14 @@ class CatClient(NamespacedClient):
:arg v: Verbose mode. Display column headers
"""
return self.transport.perform_request(
"GET", _make_path("_cat", "fielddata", fields), params=params
"GET",
_make_path("_cat", "fielddata", fields),
params=params,
headers=headers,
)
@query_params("format", "h", "help", "local", "master_timeout", "s", "v")
def plugins(self, params=None):
def plugins(self, params=None, headers=None):
"""
Returns information about installed plugins across nodes node.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-plugins.html>`_
@@ -395,10 +410,12 @@ class CatClient(NamespacedClient):
to sort by
:arg v: Verbose mode. Display column headers
"""
return self.transport.perform_request("GET", "/_cat/plugins", params=params)
return self.transport.perform_request(
"GET", "/_cat/plugins", params=params, headers=headers
)
@query_params("format", "h", "help", "local", "master_timeout", "s", "v")
def nodeattrs(self, params=None):
def nodeattrs(self, params=None, headers=None):
"""
Returns information about custom node attributes.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-nodeattrs.html>`_
@@ -415,10 +432,12 @@ class CatClient(NamespacedClient):
to sort by
:arg v: Verbose mode. Display column headers
"""
return self.transport.perform_request("GET", "/_cat/nodeattrs", params=params)
return self.transport.perform_request(
"GET", "/_cat/nodeattrs", params=params, headers=headers
)
@query_params("format", "h", "help", "local", "master_timeout", "s", "v")
def repositories(self, params=None):
def repositories(self, params=None, headers=None):
"""
Returns information about snapshot repositories registered in the cluster.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-repositories.html>`_
@@ -436,13 +455,13 @@ class CatClient(NamespacedClient):
:arg v: Verbose mode. Display column headers
"""
return self.transport.perform_request(
"GET", "/_cat/repositories", params=params
"GET", "/_cat/repositories", params=params, headers=headers
)
@query_params(
"format", "h", "help", "ignore_unavailable", "master_timeout", "s", "time", "v"
)
def snapshots(self, repository=None, params=None):
def snapshots(self, repository=None, params=None, headers=None):
"""
Returns all snapshots in a specific repository.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-snapshots.html>`_
@@ -465,7 +484,10 @@ class CatClient(NamespacedClient):
:arg v: Verbose mode. Display column headers
"""
return self.transport.perform_request(
"GET", _make_path("_cat", "snapshots", repository), params=params
"GET",
_make_path("_cat", "snapshots", repository),
params=params,
headers=headers,
)
@query_params(
@@ -480,7 +502,7 @@ class CatClient(NamespacedClient):
"time",
"v",
)
def tasks(self, params=None):
def tasks(self, params=None, headers=None):
"""
Returns information about the tasks currently executing on one or more nodes in
the cluster.
@@ -506,10 +528,12 @@ class CatClient(NamespacedClient):
(Milliseconds), micros (Microseconds), nanos (Nanoseconds)
:arg v: Verbose mode. Display column headers
"""
return self.transport.perform_request("GET", "/_cat/tasks", params=params)
return self.transport.perform_request(
"GET", "/_cat/tasks", params=params, headers=headers
)
@query_params("format", "h", "help", "local", "master_timeout", "s", "v")
def templates(self, name=None, params=None):
def templates(self, name=None, params=None, headers=None):
"""
Returns information about existing templates.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-templates.html>`_
@@ -528,5 +552,5 @@ class CatClient(NamespacedClient):
:arg v: Verbose mode. Display column headers
"""
return self.transport.perform_request(
"GET", _make_path("_cat", "templates", name), params=params
"GET", _make_path("_cat", "templates", name), params=params, headers=headers
)
+58 -25
View File
@@ -3,7 +3,7 @@ from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH
class CcrClient(NamespacedClient):
@query_params()
def delete_auto_follow_pattern(self, name, params=None):
def delete_auto_follow_pattern(self, name, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-delete-auto-follow-pattern.html>`_
@@ -13,11 +13,14 @@ class CcrClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'name'.")
return self.transport.perform_request(
"DELETE", _make_path("_ccr", "auto_follow", name), params=params
"DELETE",
_make_path("_ccr", "auto_follow", name),
params=params,
headers=headers,
)
@query_params("wait_for_active_shards")
def follow(self, index, body, params=None):
def follow(self, index, body, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-follow.html>`_
@@ -35,11 +38,15 @@ class CcrClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument.")
return self.transport.perform_request(
"PUT", _make_path(index, "_ccr", "follow"), params=params, body=body
"PUT",
_make_path(index, "_ccr", "follow"),
params=params,
headers=headers,
body=body,
)
@query_params()
def follow_info(self, index, params=None):
def follow_info(self, index, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-follow-info.html>`_
@@ -50,11 +57,11 @@ class CcrClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'index'.")
return self.transport.perform_request(
"GET", _make_path(index, "_ccr", "info"), params=params
"GET", _make_path(index, "_ccr", "info"), params=params, headers=headers
)
@query_params()
def follow_stats(self, index, params=None):
def follow_stats(self, index, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-follow-stats.html>`_
@@ -65,11 +72,11 @@ class CcrClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'index'.")
return self.transport.perform_request(
"GET", _make_path(index, "_ccr", "stats"), params=params
"GET", _make_path(index, "_ccr", "stats"), params=params, headers=headers
)
@query_params()
def forget_follower(self, index, body, params=None):
def forget_follower(self, index, body, params=None, headers=None):
"""
`<http://www.elastic.co/guide/en/elasticsearch/reference/current>`_
@@ -88,22 +95,26 @@ class CcrClient(NamespacedClient):
"POST",
_make_path(index, "_ccr", "forget_follower"),
params=params,
headers=headers,
body=body,
)
@query_params()
def get_auto_follow_pattern(self, name=None, params=None):
def get_auto_follow_pattern(self, name=None, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-auto-follow-pattern.html>`_
:arg name: The name of the auto follow pattern.
"""
return self.transport.perform_request(
"GET", _make_path("_ccr", "auto_follow", name), params=params
"GET",
_make_path("_ccr", "auto_follow", name),
params=params,
headers=headers,
)
@query_params()
def pause_follow(self, index, params=None):
def pause_follow(self, index, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-pause-follow.html>`_
@@ -114,11 +125,14 @@ class CcrClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'index'.")
return self.transport.perform_request(
"POST", _make_path(index, "_ccr", "pause_follow"), params=params
"POST",
_make_path(index, "_ccr", "pause_follow"),
params=params,
headers=headers,
)
@query_params()
def put_auto_follow_pattern(self, name, body, params=None):
def put_auto_follow_pattern(self, name, body, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-auto-follow-pattern.html>`_
@@ -130,11 +144,15 @@ class CcrClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument.")
return self.transport.perform_request(
"PUT", _make_path("_ccr", "auto_follow", name), params=params, body=body
"PUT",
_make_path("_ccr", "auto_follow", name),
params=params,
headers=headers,
body=body,
)
@query_params()
def resume_follow(self, index, body=None, params=None):
def resume_follow(self, index, body=None, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-resume-follow.html>`_
@@ -146,19 +164,25 @@ class CcrClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'index'.")
return self.transport.perform_request(
"POST", _make_path(index, "_ccr", "resume_follow"), params=params, body=body
"POST",
_make_path(index, "_ccr", "resume_follow"),
params=params,
headers=headers,
body=body,
)
@query_params()
def stats(self, params=None):
def stats(self, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-stats.html>`_
"""
return self.transport.perform_request("GET", "/_ccr/stats", params=params)
return self.transport.perform_request(
"GET", "/_ccr/stats", params=params, headers=headers
)
@query_params()
def unfollow(self, index, params=None):
def unfollow(self, index, params=None, headers=None):
"""
`<http://www.elastic.co/guide/en/elasticsearch/reference/current>`_
@@ -169,11 +193,14 @@ class CcrClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'index'.")
return self.transport.perform_request(
"POST", _make_path(index, "_ccr", "unfollow"), params=params
"POST",
_make_path(index, "_ccr", "unfollow"),
params=params,
headers=headers,
)
@query_params()
def pause_auto_follow_pattern(self, name, params=None):
def pause_auto_follow_pattern(self, name, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-pause-auto-follow-pattern.html>`_
@@ -184,11 +211,14 @@ class CcrClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'name'.")
return self.transport.perform_request(
"POST", _make_path("_ccr", "auto_follow", name, "pause"), params=params
"POST",
_make_path("_ccr", "auto_follow", name, "pause"),
params=params,
headers=headers,
)
@query_params()
def resume_auto_follow_pattern(self, name, params=None):
def resume_auto_follow_pattern(self, name, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-resume-auto-follow-pattern.html>`_
@@ -199,5 +229,8 @@ class CcrClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'name'.")
return self.transport.perform_request(
"POST", _make_path("_ccr", "auto_follow", name, "resume"), params=params
"POST",
_make_path("_ccr", "auto_follow", name, "resume"),
params=params,
headers=headers,
)
+30 -17
View File
@@ -15,7 +15,7 @@ class ClusterClient(NamespacedClient):
"wait_for_nodes",
"wait_for_status",
)
def health(self, index=None, params=None):
def health(self, index=None, params=None, headers=None):
"""
Returns basic information about the health of the cluster.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-health.html>`_
@@ -46,11 +46,14 @@ class ClusterClient(NamespacedClient):
Valid choices: green, yellow, red
"""
return self.transport.perform_request(
"GET", _make_path("_cluster", "health", index), params=params
"GET",
_make_path("_cluster", "health", index),
params=params,
headers=headers,
)
@query_params("local", "master_timeout")
def pending_tasks(self, params=None):
def pending_tasks(self, params=None, headers=None):
"""
Returns a list of any cluster-level changes (e.g. create index, update mapping,
allocate or fail shard) which have not yet been executed.
@@ -61,7 +64,7 @@ class ClusterClient(NamespacedClient):
:arg master_timeout: Specify timeout for connection to master
"""
return self.transport.perform_request(
"GET", "/_cluster/pending_tasks", params=params
"GET", "/_cluster/pending_tasks", params=params, headers=headers
)
@query_params(
@@ -74,7 +77,7 @@ class ClusterClient(NamespacedClient):
"wait_for_metadata_version",
"wait_for_timeout",
)
def state(self, metric=None, index=None, params=None):
def state(self, metric=None, index=None, params=None, headers=None):
"""
Returns a comprehensive information about the state of the cluster.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-state.html>`_
@@ -106,11 +109,14 @@ class ClusterClient(NamespacedClient):
metric = "_all"
return self.transport.perform_request(
"GET", _make_path("_cluster", "state", metric, index), params=params
"GET",
_make_path("_cluster", "state", metric, index),
params=params,
headers=headers,
)
@query_params("flat_settings", "timeout")
def stats(self, node_id=None, params=None):
def stats(self, node_id=None, params=None, headers=None):
"""
Returns high-level overview of cluster statistics.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-stats.html>`_
@@ -129,12 +135,13 @@ class ClusterClient(NamespacedClient):
if node_id in SKIP_IN_PATH
else _make_path("_cluster", "stats", "nodes", node_id),
params=params,
headers=headers,
)
@query_params(
"dry_run", "explain", "master_timeout", "metric", "retry_failed", "timeout"
)
def reroute(self, body=None, params=None):
def reroute(self, body=None, params=None, headers=None):
"""
Allows to manually change the allocation of individual shards in the cluster.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-reroute.html>`_
@@ -155,11 +162,11 @@ class ClusterClient(NamespacedClient):
:arg timeout: Explicit operation timeout
"""
return self.transport.perform_request(
"POST", "/_cluster/reroute", params=params, body=body
"POST", "/_cluster/reroute", params=params, headers=headers, body=body
)
@query_params("flat_settings", "include_defaults", "master_timeout", "timeout")
def get_settings(self, params=None):
def get_settings(self, params=None, headers=None):
"""
Returns cluster settings.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-update-settings.html>`_
@@ -173,11 +180,11 @@ class ClusterClient(NamespacedClient):
:arg timeout: Explicit operation timeout
"""
return self.transport.perform_request(
"GET", "/_cluster/settings", params=params
"GET", "/_cluster/settings", params=params, headers=headers
)
@query_params("flat_settings", "master_timeout", "timeout")
def put_settings(self, body, params=None):
def put_settings(self, body, params=None, headers=None):
"""
Updates the cluster settings.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-update-settings.html>`_
@@ -194,20 +201,22 @@ class ClusterClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'body'.")
return self.transport.perform_request(
"PUT", "/_cluster/settings", params=params, body=body
"PUT", "/_cluster/settings", params=params, headers=headers, body=body
)
@query_params()
def remote_info(self, params=None):
def remote_info(self, params=None, headers=None):
"""
Returns the information about configured remote clusters.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-remote-info.html>`_
"""
return self.transport.perform_request("GET", "/_remote/info", params=params)
return self.transport.perform_request(
"GET", "/_remote/info", params=params, headers=headers
)
@query_params("include_disk_info", "include_yes_decisions")
def allocation_explain(self, body=None, params=None):
def allocation_explain(self, body=None, params=None, headers=None):
"""
Provides explanations for shard allocations in the cluster.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-allocation-explain.html>`_
@@ -220,5 +229,9 @@ class ClusterClient(NamespacedClient):
explanation (default: false)
"""
return self.transport.perform_request(
"GET", "/_cluster/allocation/explain", params=params, body=body
"GET",
"/_cluster/allocation/explain",
params=params,
headers=headers,
body=body,
)
+22 -9
View File
@@ -3,7 +3,7 @@ from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH
class Data_FrameClient(NamespacedClient):
@query_params()
def delete_data_frame_transform(self, transform_id, params=None):
def delete_data_frame_transform(self, transform_id, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-data-frame-transform.html>`_
@@ -17,10 +17,11 @@ class Data_FrameClient(NamespacedClient):
"DELETE",
_make_path("_data_frame", "transforms", transform_id),
params=params,
headers=headers,
)
@query_params("from_", "size")
def get_data_frame_transform(self, transform_id=None, params=None):
def get_data_frame_transform(self, transform_id=None, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/get-data-frame-transform.html>`_
@@ -30,11 +31,16 @@ class Data_FrameClient(NamespacedClient):
:arg size: specifies a max number of transforms to get, defaults to 100
"""
return self.transport.perform_request(
"GET", _make_path("_data_frame", "transforms", transform_id), params=params
"GET",
_make_path("_data_frame", "transforms", transform_id),
params=params,
headers=headers,
)
@query_params()
def get_data_frame_transform_stats(self, transform_id=None, params=None):
def get_data_frame_transform_stats(
self, transform_id=None, params=None, headers=None
):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/get-data-frame-transform-stats.html>`_
@@ -48,7 +54,7 @@ class Data_FrameClient(NamespacedClient):
)
@query_params()
def preview_data_frame_transform(self, body, params=None):
def preview_data_frame_transform(self, body, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/preview-data-frame-transform.html>`_
@@ -57,11 +63,15 @@ class Data_FrameClient(NamespacedClient):
if body in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'body'.")
return self.transport.perform_request(
"POST", "/_data_frame/transforms/_preview", params=params, body=body
"POST",
"/_data_frame/transforms/_preview",
params=params,
headers=headers,
body=body,
)
@query_params()
def put_data_frame_transform(self, transform_id, body, params=None):
def put_data_frame_transform(self, transform_id, body, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/put-data-frame-transform.html>`_
@@ -75,11 +85,12 @@ class Data_FrameClient(NamespacedClient):
"PUT",
_make_path("_data_frame", "transforms", transform_id),
params=params,
headers=headers,
body=body,
)
@query_params("timeout")
def start_data_frame_transform(self, transform_id, params=None):
def start_data_frame_transform(self, transform_id, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/start-data-frame-transform.html>`_
@@ -94,10 +105,11 @@ class Data_FrameClient(NamespacedClient):
"POST",
_make_path("_data_frame", "transforms", transform_id, "_start"),
params=params,
headers=headers,
)
@query_params("timeout", "wait_for_completion")
def stop_data_frame_transform(self, transform_id, params=None):
def stop_data_frame_transform(self, transform_id, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/stop-data-frame-transform.html>`_
@@ -115,4 +127,5 @@ class Data_FrameClient(NamespacedClient):
"POST",
_make_path("_data_frame", "transforms", transform_id, "_stop"),
params=params,
headers=headers,
)
+2 -1
View File
@@ -3,7 +3,7 @@ from .utils import NamespacedClient, query_params, _make_path
class DeprecationClient(NamespacedClient):
@query_params()
def info(self, index=None, params=None):
def info(self, index=None, params=None, headers=None):
"""
`<http://www.elastic.co/guide/en/migration/current/migration-api-deprecation.html>`_
@@ -13,4 +13,5 @@ class DeprecationClient(NamespacedClient):
"GET",
_make_path(index, "_xpack", "migration", "deprecations"),
params=params,
headers=headers,
)
+22 -10
View File
@@ -3,7 +3,7 @@ from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH
class EnrichClient(NamespacedClient):
@query_params()
def delete_policy(self, name, params=None):
def delete_policy(self, name, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/enrich-delete-policy.html>`_
@@ -13,11 +13,14 @@ class EnrichClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'name'.")
return self.transport.perform_request(
"DELETE", _make_path("_enrich", "policy", name), params=params
"DELETE",
_make_path("_enrich", "policy", name),
params=params,
headers=headers,
)
@query_params("wait_for_completion")
def execute_policy(self, name, params=None):
def execute_policy(self, name, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/enrich-execute-policy.html>`_
@@ -29,22 +32,25 @@ class EnrichClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'name'.")
return self.transport.perform_request(
"PUT", _make_path("_enrich", "policy", name, "_execute"), params=params
"PUT",
_make_path("_enrich", "policy", name, "_execute"),
params=params,
headers=headers,
)
@query_params()
def get_policy(self, name=None, params=None):
def get_policy(self, name=None, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/enrich-get-policy.html>`_
:arg name: The name of the enrich policy
"""
return self.transport.perform_request(
"GET", _make_path("_enrich", "policy", name), params=params
"GET", _make_path("_enrich", "policy", name), params=params, headers=headers
)
@query_params()
def put_policy(self, name, body, params=None):
def put_policy(self, name, body, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/enrich-put-policy.html>`_
@@ -56,13 +62,19 @@ class EnrichClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument.")
return self.transport.perform_request(
"PUT", _make_path("_enrich", "policy", name), params=params, body=body
"PUT",
_make_path("_enrich", "policy", name),
params=params,
headers=headers,
body=body,
)
@query_params()
def stats(self, params=None):
def stats(self, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/enrich-stats.html>`_
"""
return self.transport.perform_request("GET", "/_enrich/_stats", params=params)
return self.transport.perform_request(
"GET", "/_enrich/_stats", params=params, headers=headers
)
+2 -1
View File
@@ -3,7 +3,7 @@ from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH
class GraphClient(NamespacedClient):
@query_params("routing", "timeout")
def explore(self, index, body=None, doc_type=None, params=None):
def explore(self, index, body=None, doc_type=None, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/graph-explore-api.html>`_
@@ -22,5 +22,6 @@ class GraphClient(NamespacedClient):
"GET",
_make_path(index, doc_type, "_graph", "explore"),
params=params,
headers=headers,
body=body,
)
+37 -20
View File
@@ -3,7 +3,7 @@ from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH
class IlmClient(NamespacedClient):
@query_params()
def delete_lifecycle(self, policy, params=None):
def delete_lifecycle(self, policy, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-delete-lifecycle.html>`_
@@ -13,11 +13,14 @@ class IlmClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'policy'.")
return self.transport.perform_request(
"DELETE", _make_path("_ilm", "policy", policy), params=params
"DELETE",
_make_path("_ilm", "policy", policy),
params=params,
headers=headers,
)
@query_params("only_errors", "only_managed")
def explain_lifecycle(self, index, params=None):
def explain_lifecycle(self, index, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-explain-lifecycle.html>`_
@@ -31,30 +34,32 @@ class IlmClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'index'.")
return self.transport.perform_request(
"GET", _make_path(index, "_ilm", "explain"), params=params
"GET", _make_path(index, "_ilm", "explain"), params=params, headers=headers
)
@query_params()
def get_lifecycle(self, policy=None, params=None):
def get_lifecycle(self, policy=None, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-get-lifecycle.html>`_
:arg policy: The name of the index lifecycle policy
"""
return self.transport.perform_request(
"GET", _make_path("_ilm", "policy", policy), params=params
"GET", _make_path("_ilm", "policy", policy), params=params, headers=headers
)
@query_params()
def get_status(self, params=None):
def get_status(self, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-get-status.html>`_
"""
return self.transport.perform_request("GET", "/_ilm/status", params=params)
return self.transport.perform_request(
"GET", "/_ilm/status", params=params, headers=headers
)
@query_params()
def move_to_step(self, index, body=None, params=None):
def move_to_step(self, index, body=None, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-move-to-step.html>`_
@@ -66,11 +71,15 @@ class IlmClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'index'.")
return self.transport.perform_request(
"POST", _make_path("_ilm", "move", index), params=params, body=body
"POST",
_make_path("_ilm", "move", index),
params=params,
headers=headers,
body=body,
)
@query_params()
def put_lifecycle(self, policy, body=None, params=None):
def put_lifecycle(self, policy, body=None, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-put-lifecycle.html>`_
@@ -81,11 +90,15 @@ class IlmClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'policy'.")
return self.transport.perform_request(
"PUT", _make_path("_ilm", "policy", policy), params=params, body=body
"PUT",
_make_path("_ilm", "policy", policy),
params=params,
headers=headers,
body=body,
)
@query_params()
def remove_policy(self, index, params=None):
def remove_policy(self, index, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-remove-policy.html>`_
@@ -95,11 +108,11 @@ class IlmClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'index'.")
return self.transport.perform_request(
"POST", _make_path(index, "_ilm", "remove"), params=params
"POST", _make_path(index, "_ilm", "remove"), params=params, headers=headers
)
@query_params()
def retry(self, index, params=None):
def retry(self, index, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-retry-policy.html>`_
@@ -110,21 +123,25 @@ class IlmClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'index'.")
return self.transport.perform_request(
"POST", _make_path(index, "_ilm", "retry"), params=params
"POST", _make_path(index, "_ilm", "retry"), params=params, headers=headers
)
@query_params()
def start(self, params=None):
def start(self, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-start.html>`_
"""
return self.transport.perform_request("POST", "/_ilm/start", params=params)
return self.transport.perform_request(
"POST", "/_ilm/start", params=params, headers=headers
)
@query_params()
def stop(self, params=None):
def stop(self, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-stop.html>`_
"""
return self.transport.perform_request("POST", "/_ilm/stop", params=params)
return self.transport.perform_request(
"POST", "/_ilm/stop", params=params, headers=headers
)
+138 -80
View File
@@ -3,7 +3,7 @@ from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH
class IndicesClient(NamespacedClient):
@query_params()
def analyze(self, body=None, index=None, params=None):
def analyze(self, body=None, index=None, params=None, headers=None):
"""
Performs the analysis process on a text and return the tokens breakdown of the
text.
@@ -15,11 +15,15 @@ class IndicesClient(NamespacedClient):
:arg index: The name of the index to scope the operation
"""
return self.transport.perform_request(
"GET", _make_path(index, "_analyze"), params=params, body=body
"GET",
_make_path(index, "_analyze"),
params=params,
headers=headers,
body=body,
)
@query_params("allow_no_indices", "expand_wildcards", "ignore_unavailable")
def refresh(self, index=None, params=None):
def refresh(self, index=None, params=None, headers=None):
"""
Performs the refresh operation in one or more indices.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-refresh.html>`_
@@ -36,7 +40,7 @@ class IndicesClient(NamespacedClient):
should be ignored when unavailable (missing or closed)
"""
return self.transport.perform_request(
"POST", _make_path(index, "_refresh"), params=params
"POST", _make_path(index, "_refresh"), params=params, headers=headers
)
@query_params(
@@ -46,7 +50,7 @@ class IndicesClient(NamespacedClient):
"ignore_unavailable",
"wait_if_ongoing",
)
def flush(self, index=None, params=None):
def flush(self, index=None, params=None, headers=None):
"""
Performs the flush operation on one or more indices.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-flush.html>`_
@@ -72,13 +76,13 @@ class IndicesClient(NamespacedClient):
be skipped iff if another flush operation is already running.
"""
return self.transport.perform_request(
"POST", _make_path(index, "_flush"), params=params
"POST", _make_path(index, "_flush"), params=params, headers=headers
)
@query_params(
"include_type_name", "master_timeout", "timeout", "wait_for_active_shards"
)
def create(self, index, body=None, params=None):
def create(self, index, body=None, params=None, headers=None):
"""
Creates an index with optional settings and mappings.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-create-index.html>`_
@@ -97,11 +101,11 @@ class IndicesClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'index'.")
return self.transport.perform_request(
"PUT", _make_path(index), params=params, body=body
"PUT", _make_path(index), params=params, headers=headers, body=body
)
@query_params("master_timeout", "timeout", "wait_for_active_shards")
def clone(self, index, target, body=None, params=None):
def clone(self, index, target, body=None, params=None, headers=None):
"""
Clones an index
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-clone-index.html>`_
@@ -120,7 +124,11 @@ class IndicesClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument.")
return self.transport.perform_request(
"PUT", _make_path(index, "_clone", target), params=params, body=body
"PUT",
_make_path(index, "_clone", target),
params=params,
headers=headers,
body=body,
)
@query_params(
@@ -133,7 +141,7 @@ class IndicesClient(NamespacedClient):
"local",
"master_timeout",
)
def get(self, index, params=None):
def get(self, index, params=None, headers=None):
"""
Returns information about one or more indices.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-index.html>`_
@@ -159,7 +167,9 @@ class IndicesClient(NamespacedClient):
if index in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'index'.")
return self.transport.perform_request("GET", _make_path(index), params=params)
return self.transport.perform_request(
"GET", _make_path(index), params=params, headers=headers
)
@query_params(
"allow_no_indices",
@@ -169,7 +179,7 @@ class IndicesClient(NamespacedClient):
"timeout",
"wait_for_active_shards",
)
def open(self, index, params=None):
def open(self, index, params=None, headers=None):
"""
Opens an index.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-open-close.html>`_
@@ -192,7 +202,7 @@ class IndicesClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'index'.")
return self.transport.perform_request(
"POST", _make_path(index, "_open"), params=params
"POST", _make_path(index, "_open"), params=params, headers=headers
)
@query_params(
@@ -203,7 +213,7 @@ class IndicesClient(NamespacedClient):
"timeout",
"wait_for_active_shards",
)
def close(self, index, params=None):
def close(self, index, params=None, headers=None):
"""
Closes an index.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-open-close.html>`_
@@ -226,7 +236,7 @@ class IndicesClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'index'.")
return self.transport.perform_request(
"POST", _make_path(index, "_close"), params=params
"POST", _make_path(index, "_close"), params=params, headers=headers
)
@query_params(
@@ -236,7 +246,7 @@ class IndicesClient(NamespacedClient):
"master_timeout",
"timeout",
)
def delete(self, index, params=None):
def delete(self, index, params=None, headers=None):
"""
Deletes an index.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-delete-index.html>`_
@@ -257,7 +267,7 @@ class IndicesClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'index'.")
return self.transport.perform_request(
"DELETE", _make_path(index), params=params
"DELETE", _make_path(index), params=params, headers=headers
)
@query_params(
@@ -268,7 +278,7 @@ class IndicesClient(NamespacedClient):
"include_defaults",
"local",
)
def exists(self, index, params=None):
def exists(self, index, params=None, headers=None):
"""
Returns information about whether a particular index exists.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-exists.html>`_
@@ -291,10 +301,12 @@ class IndicesClient(NamespacedClient):
if index in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'index'.")
return self.transport.perform_request("HEAD", _make_path(index), params=params)
return self.transport.perform_request(
"HEAD", _make_path(index), params=params, headers=headers
)
@query_params("allow_no_indices", "expand_wildcards", "ignore_unavailable", "local")
def exists_type(self, index, doc_type, params=None):
def exists_type(self, index, doc_type, params=None, headers=None):
"""
Returns information about whether a particular document type exists.
(DEPRECATED)
@@ -319,7 +331,10 @@ class IndicesClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument.")
return self.transport.perform_request(
"HEAD", _make_path(index, "_mapping", doc_type), params=params
"HEAD",
_make_path(index, "_mapping", doc_type),
params=params,
headers=headers,
)
@query_params(
@@ -330,7 +345,7 @@ class IndicesClient(NamespacedClient):
"master_timeout",
"timeout",
)
def put_mapping(self, body, index=None, doc_type=None, params=None):
def put_mapping(self, body, index=None, doc_type=None, params=None, headers=None):
"""
Updates the index mappings.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-put-mapping.html>`_
@@ -360,7 +375,11 @@ class IndicesClient(NamespacedClient):
index = "_all"
return self.transport.perform_request(
"PUT", _make_path(index, doc_type, "_mapping"), params=params, body=body
"PUT",
_make_path(index, doc_type, "_mapping"),
params=params,
headers=headers,
body=body,
)
@query_params(
@@ -371,7 +390,7 @@ class IndicesClient(NamespacedClient):
"local",
"master_timeout",
)
def get_mapping(self, index=None, doc_type=None, params=None):
def get_mapping(self, index=None, doc_type=None, params=None, headers=None):
"""
Returns mappings for one or more indices.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-mapping.html>`_
@@ -393,7 +412,10 @@ class IndicesClient(NamespacedClient):
:arg master_timeout: Specify timeout for connection to master
"""
return self.transport.perform_request(
"GET", _make_path(index, "_mapping", doc_type), params=params
"GET",
_make_path(index, "_mapping", doc_type),
params=params,
headers=headers,
)
@query_params(
@@ -404,7 +426,9 @@ class IndicesClient(NamespacedClient):
"include_type_name",
"local",
)
def get_field_mapping(self, fields, index=None, doc_type=None, params=None):
def get_field_mapping(
self, fields, index=None, doc_type=None, params=None, headers=None
):
"""
Returns mapping for one or more fields.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-field-mapping.html>`_
@@ -434,10 +458,11 @@ class IndicesClient(NamespacedClient):
"GET",
_make_path(index, "_mapping", doc_type, "field", fields),
params=params,
headers=headers,
)
@query_params("master_timeout", "timeout")
def put_alias(self, index, name, body=None, params=None):
def put_alias(self, index, name, body=None, params=None, headers=None):
"""
Creates or updates an alias.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html>`_
@@ -456,11 +481,15 @@ class IndicesClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument.")
return self.transport.perform_request(
"PUT", _make_path(index, "_alias", name), params=params, body=body
"PUT",
_make_path(index, "_alias", name),
params=params,
headers=headers,
body=body,
)
@query_params("allow_no_indices", "expand_wildcards", "ignore_unavailable", "local")
def exists_alias(self, name, index=None, params=None):
def exists_alias(self, name, index=None, params=None, headers=None):
"""
Returns information about whether a particular alias exists.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html>`_
@@ -483,11 +512,11 @@ class IndicesClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'name'.")
return self.transport.perform_request(
"HEAD", _make_path(index, "_alias", name), params=params
"HEAD", _make_path(index, "_alias", name), params=params, headers=headers
)
@query_params("allow_no_indices", "expand_wildcards", "ignore_unavailable", "local")
def get_alias(self, index=None, name=None, params=None):
def get_alias(self, index=None, name=None, params=None, headers=None):
"""
Returns an alias.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html>`_
@@ -507,11 +536,11 @@ class IndicesClient(NamespacedClient):
from master node (default: false)
"""
return self.transport.perform_request(
"GET", _make_path(index, "_alias", name), params=params
"GET", _make_path(index, "_alias", name), params=params, headers=headers
)
@query_params("master_timeout", "timeout")
def update_aliases(self, body, params=None):
def update_aliases(self, body, params=None, headers=None):
"""
Updates index aliases.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html>`_
@@ -524,11 +553,11 @@ class IndicesClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'body'.")
return self.transport.perform_request(
"POST", "/_aliases", params=params, body=body
"POST", "/_aliases", params=params, headers=headers, body=body
)
@query_params("master_timeout", "timeout")
def delete_alias(self, index, name, params=None):
def delete_alias(self, index, name, params=None, headers=None):
"""
Deletes an alias.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html>`_
@@ -545,7 +574,7 @@ class IndicesClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument.")
return self.transport.perform_request(
"DELETE", _make_path(index, "_alias", name), params=params
"DELETE", _make_path(index, "_alias", name), params=params, headers=headers
)
@query_params(
@@ -556,7 +585,7 @@ class IndicesClient(NamespacedClient):
"order",
"timeout",
)
def put_template(self, name, body, params=None):
def put_template(self, name, body, params=None, headers=None):
"""
Creates or updates an index template.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html>`_
@@ -580,11 +609,15 @@ class IndicesClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument.")
return self.transport.perform_request(
"PUT", _make_path("_template", name), params=params, body=body
"PUT",
_make_path("_template", name),
params=params,
headers=headers,
body=body,
)
@query_params("flat_settings", "local", "master_timeout")
def exists_template(self, name, params=None):
def exists_template(self, name, params=None, headers=None):
"""
Returns information about whether a particular index template exists.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html>`_
@@ -601,11 +634,11 @@ class IndicesClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'name'.")
return self.transport.perform_request(
"HEAD", _make_path("_template", name), params=params
"HEAD", _make_path("_template", name), params=params, headers=headers
)
@query_params("flat_settings", "include_type_name", "local", "master_timeout")
def get_template(self, name=None, params=None):
def get_template(self, name=None, params=None, headers=None):
"""
Returns an index template.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html>`_
@@ -621,11 +654,11 @@ class IndicesClient(NamespacedClient):
to master node
"""
return self.transport.perform_request(
"GET", _make_path("_template", name), params=params
"GET", _make_path("_template", name), params=params, headers=headers
)
@query_params("master_timeout", "timeout")
def delete_template(self, name, params=None):
def delete_template(self, name, params=None, headers=None):
"""
Deletes an index template.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html>`_
@@ -638,7 +671,7 @@ class IndicesClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'name'.")
return self.transport.perform_request(
"DELETE", _make_path("_template", name), params=params
"DELETE", _make_path("_template", name), params=params, headers=headers
)
@query_params(
@@ -650,7 +683,7 @@ class IndicesClient(NamespacedClient):
"local",
"master_timeout",
)
def get_settings(self, index=None, name=None, params=None):
def get_settings(self, index=None, name=None, params=None, headers=None):
"""
Returns settings for one or more indices.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-settings.html>`_
@@ -675,7 +708,7 @@ class IndicesClient(NamespacedClient):
:arg master_timeout: Specify timeout for connection to master
"""
return self.transport.perform_request(
"GET", _make_path(index, "_settings", name), params=params
"GET", _make_path(index, "_settings", name), params=params, headers=headers
)
@query_params(
@@ -687,7 +720,7 @@ class IndicesClient(NamespacedClient):
"preserve_existing",
"timeout",
)
def put_settings(self, body, index=None, params=None):
def put_settings(self, body, index=None, params=None, headers=None):
"""
Updates the index settings.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-update-settings.html>`_
@@ -715,7 +748,11 @@ class IndicesClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'body'.")
return self.transport.perform_request(
"PUT", _make_path(index, "_settings"), params=params, body=body
"PUT",
_make_path(index, "_settings"),
params=params,
headers=headers,
body=body,
)
@query_params(
@@ -730,7 +767,7 @@ class IndicesClient(NamespacedClient):
"level",
"types",
)
def stats(self, index=None, metric=None, params=None):
def stats(self, index=None, metric=None, params=None, headers=None):
"""
Provides statistics on operations happening in an index.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-stats.html>`_
@@ -767,13 +804,13 @@ class IndicesClient(NamespacedClient):
`indexing` index metric
"""
return self.transport.perform_request(
"GET", _make_path(index, "_stats", metric), params=params
"GET", _make_path(index, "_stats", metric), params=params, headers=headers
)
@query_params(
"allow_no_indices", "expand_wildcards", "ignore_unavailable", "verbose"
)
def segments(self, index=None, params=None):
def segments(self, index=None, params=None, headers=None):
"""
Provides low-level information about segments in a Lucene index.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-segments.html>`_
@@ -791,7 +828,7 @@ class IndicesClient(NamespacedClient):
:arg verbose: Includes detailed memory usage by Lucene.
"""
return self.transport.perform_request(
"GET", _make_path(index, "_segments"), params=params
"GET", _make_path(index, "_segments"), params=params, headers=headers
)
@query_params(
@@ -808,7 +845,9 @@ class IndicesClient(NamespacedClient):
"q",
"rewrite",
)
def validate_query(self, body=None, index=None, doc_type=None, params=None):
def validate_query(
self, body=None, index=None, doc_type=None, params=None, headers=None
):
"""
Allows a user to validate a potentially expensive query without executing it.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/search-validate.html>`_
@@ -848,6 +887,7 @@ class IndicesClient(NamespacedClient):
"GET",
_make_path(index, doc_type, "_validate", "query"),
params=params,
headers=headers,
body=body,
)
@@ -860,7 +900,7 @@ class IndicesClient(NamespacedClient):
"query",
"request",
)
def clear_cache(self, index=None, params=None):
def clear_cache(self, index=None, params=None, headers=None):
"""
Clears all or specific caches for one or more indices.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-clearcache.html>`_
@@ -884,11 +924,11 @@ class IndicesClient(NamespacedClient):
:arg request: Clear request cache
"""
return self.transport.perform_request(
"POST", _make_path(index, "_cache", "clear"), params=params
"POST", _make_path(index, "_cache", "clear"), params=params, headers=headers
)
@query_params("active_only", "detailed")
def recovery(self, index=None, params=None):
def recovery(self, index=None, params=None, headers=None):
"""
Returns information about ongoing index shard recoveries.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-recovery.html>`_
@@ -901,7 +941,7 @@ class IndicesClient(NamespacedClient):
shard recovery
"""
return self.transport.perform_request(
"GET", _make_path(index, "_recovery"), params=params
"GET", _make_path(index, "_recovery"), params=params, headers=headers
)
@query_params(
@@ -911,7 +951,7 @@ class IndicesClient(NamespacedClient):
"only_ancient_segments",
"wait_for_completion",
)
def upgrade(self, index=None, params=None):
def upgrade(self, index=None, params=None, headers=None):
"""
The _upgrade API is no longer useful and will be removed.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-upgrade.html>`_
@@ -932,11 +972,11 @@ class IndicesClient(NamespacedClient):
block until the all segments are upgraded (default: false)
"""
return self.transport.perform_request(
"POST", _make_path(index, "_upgrade"), params=params
"POST", _make_path(index, "_upgrade"), params=params, headers=headers
)
@query_params("allow_no_indices", "expand_wildcards", "ignore_unavailable")
def get_upgrade(self, index=None, params=None):
def get_upgrade(self, index=None, params=None, headers=None):
"""
The _upgrade API is no longer useful and will be removed.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-upgrade.html>`_
@@ -953,11 +993,11 @@ class IndicesClient(NamespacedClient):
should be ignored when unavailable (missing or closed)
"""
return self.transport.perform_request(
"GET", _make_path(index, "_upgrade"), params=params
"GET", _make_path(index, "_upgrade"), params=params, headers=headers
)
@query_params("allow_no_indices", "expand_wildcards", "ignore_unavailable")
def flush_synced(self, index=None, params=None):
def flush_synced(self, index=None, params=None, headers=None):
"""
Performs a synced flush operation on one or more indices.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-synced-flush-api.html>`_
@@ -974,13 +1014,16 @@ class IndicesClient(NamespacedClient):
should be ignored when unavailable (missing or closed)
"""
return self.transport.perform_request(
"POST", _make_path(index, "_flush", "synced"), params=params
"POST",
_make_path(index, "_flush", "synced"),
params=params,
headers=headers,
)
@query_params(
"allow_no_indices", "expand_wildcards", "ignore_unavailable", "status"
)
def shard_stores(self, index=None, params=None):
def shard_stores(self, index=None, params=None, headers=None):
"""
Provides store information for shard copies of indices.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-shards-stores.html>`_
@@ -1000,7 +1043,7 @@ class IndicesClient(NamespacedClient):
red, all
"""
return self.transport.perform_request(
"GET", _make_path(index, "_shard_stores"), params=params
"GET", _make_path(index, "_shard_stores"), params=params, headers=headers
)
@query_params(
@@ -1011,7 +1054,7 @@ class IndicesClient(NamespacedClient):
"max_num_segments",
"only_expunge_deletes",
)
def forcemerge(self, index=None, params=None):
def forcemerge(self, index=None, params=None, headers=None):
"""
Performs the force merge operation on one or more indices.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-forcemerge.html>`_
@@ -1034,13 +1077,13 @@ class IndicesClient(NamespacedClient):
only expunge deleted documents
"""
return self.transport.perform_request(
"POST", _make_path(index, "_forcemerge"), params=params
"POST", _make_path(index, "_forcemerge"), params=params, headers=headers
)
@query_params(
"copy_settings", "master_timeout", "timeout", "wait_for_active_shards"
)
def shrink(self, index, target, body=None, params=None):
def shrink(self, index, target, body=None, params=None, headers=None):
"""
Allow to shrink an existing index into a new index with fewer primary shards.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-shrink-index.html>`_
@@ -1061,13 +1104,17 @@ class IndicesClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument.")
return self.transport.perform_request(
"PUT", _make_path(index, "_shrink", target), params=params, body=body
"PUT",
_make_path(index, "_shrink", target),
params=params,
headers=headers,
body=body,
)
@query_params(
"copy_settings", "master_timeout", "timeout", "wait_for_active_shards"
)
def split(self, index, target, body=None, params=None):
def split(self, index, target, body=None, params=None, headers=None):
"""
Allows you to split an existing index into a new index with more primary
shards.
@@ -1089,7 +1136,11 @@ class IndicesClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument.")
return self.transport.perform_request(
"PUT", _make_path(index, "_split", target), params=params, body=body
"PUT",
_make_path(index, "_split", target),
params=params,
headers=headers,
body=body,
)
@query_params(
@@ -1099,7 +1150,7 @@ class IndicesClient(NamespacedClient):
"timeout",
"wait_for_active_shards",
)
def rollover(self, alias, body=None, new_index=None, params=None):
def rollover(self, alias, body=None, new_index=None, params=None, headers=None):
"""
Updates an alias to point to a new index when the existing index is considered
to be too large or too old.
@@ -1124,7 +1175,11 @@ class IndicesClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'alias'.")
return self.transport.perform_request(
"POST", _make_path(alias, "_rollover", new_index), params=params, body=body
"POST",
_make_path(alias, "_rollover", new_index),
params=params,
headers=headers,
body=body,
)
@query_params(
@@ -1135,7 +1190,7 @@ class IndicesClient(NamespacedClient):
"timeout",
"wait_for_active_shards",
)
def freeze(self, index, params=None):
def freeze(self, index, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/frozen.html>`_
@@ -1157,7 +1212,7 @@ class IndicesClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'index'.")
return self.transport.perform_request(
"POST", _make_path(index, "_freeze"), params=params
"POST", _make_path(index, "_freeze"), params=params, headers=headers
)
@query_params(
@@ -1168,7 +1223,7 @@ class IndicesClient(NamespacedClient):
"timeout",
"wait_for_active_shards",
)
def unfreeze(self, index, params=None):
def unfreeze(self, index, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/frozen.html>`_
@@ -1190,11 +1245,11 @@ class IndicesClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'index'.")
return self.transport.perform_request(
"POST", _make_path(index, "_unfreeze"), params=params
"POST", _make_path(index, "_unfreeze"), params=params, headers=headers
)
@query_params("allow_no_indices", "expand_wildcards", "ignore_unavailable")
def reload_search_analyzers(self, index, params=None):
def reload_search_analyzers(self, index, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-reload-analyzers.html>`_
@@ -1213,5 +1268,8 @@ class IndicesClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'index'.")
return self.transport.perform_request(
"GET", _make_path(index, "_reload_search_analyzers"), params=params
"GET",
_make_path(index, "_reload_search_analyzers"),
params=params,
headers=headers,
)
+17 -9
View File
@@ -3,7 +3,7 @@ from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH
class IngestClient(NamespacedClient):
@query_params("master_timeout")
def get_pipeline(self, id=None, params=None):
def get_pipeline(self, id=None, params=None, headers=None):
"""
Returns a pipeline.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/get-pipeline-api.html>`_
@@ -14,11 +14,11 @@ class IngestClient(NamespacedClient):
to master node
"""
return self.transport.perform_request(
"GET", _make_path("_ingest", "pipeline", id), params=params
"GET", _make_path("_ingest", "pipeline", id), params=params, headers=headers
)
@query_params("master_timeout", "timeout")
def put_pipeline(self, id, body, params=None):
def put_pipeline(self, id, body, params=None, headers=None):
"""
Creates or updates a pipeline.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/put-pipeline-api.html>`_
@@ -34,11 +34,15 @@ class IngestClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument.")
return self.transport.perform_request(
"PUT", _make_path("_ingest", "pipeline", id), params=params, body=body
"PUT",
_make_path("_ingest", "pipeline", id),
params=params,
headers=headers,
body=body,
)
@query_params("master_timeout", "timeout")
def delete_pipeline(self, id, params=None):
def delete_pipeline(self, id, params=None, headers=None):
"""
Deletes a pipeline.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-pipeline-api.html>`_
@@ -52,11 +56,14 @@ class IngestClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'id'.")
return self.transport.perform_request(
"DELETE", _make_path("_ingest", "pipeline", id), params=params
"DELETE",
_make_path("_ingest", "pipeline", id),
params=params,
headers=headers,
)
@query_params("verbose")
def simulate(self, body, id=None, params=None):
def simulate(self, body, id=None, params=None, headers=None):
"""
Allows to simulate a pipeline with example documents.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/simulate-pipeline-api.html>`_
@@ -73,16 +80,17 @@ class IngestClient(NamespacedClient):
"GET",
_make_path("_ingest", "pipeline", id, "_simulate"),
params=params,
headers=headers,
body=body,
)
@query_params()
def processor_grok(self, params=None):
def processor_grok(self, params=None, headers=None):
"""
Returns a list of the built-in patterns.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/grok-processor.html#grok-processor-rest-get>`_
"""
return self.transport.perform_request(
"GET", "/_ingest/processor/grok", params=params
"GET", "/_ingest/processor/grok", params=params, headers=headers
)
+18 -14
View File
@@ -3,45 +3,49 @@ from .utils import NamespacedClient, query_params
class LicenseClient(NamespacedClient):
@query_params()
def delete(self, params=None):
def delete(self, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-license.html>`_
"""
return self.transport.perform_request("DELETE", "/_license", params=params)
return self.transport.perform_request(
"DELETE", "/_license", params=params, headers=headers
)
@query_params("local")
def get(self, params=None):
def get(self, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/get-license.html>`_
:arg local: Return local information, do not retrieve the state
from master node (default: false)
"""
return self.transport.perform_request("GET", "/_license", params=params)
return self.transport.perform_request(
"GET", "/_license", params=params, headers=headers
)
@query_params()
def get_basic_status(self, params=None):
def get_basic_status(self, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/get-basic-status.html>`_
"""
return self.transport.perform_request(
"GET", "/_license/basic_status", params=params
"GET", "/_license/basic_status", params=params, headers=headers
)
@query_params()
def get_trial_status(self, params=None):
def get_trial_status(self, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/get-trial-status.html>`_
"""
return self.transport.perform_request(
"GET", "/_license/trial_status", params=params
"GET", "/_license/trial_status", params=params, headers=headers
)
@query_params("acknowledge")
def post(self, body=None, params=None):
def post(self, body=None, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/update-license.html>`_
@@ -50,11 +54,11 @@ class LicenseClient(NamespacedClient):
messages (default: false)
"""
return self.transport.perform_request(
"PUT", "/_license", params=params, body=body
"PUT", "/_license", params=params, headers=headers, body=body
)
@query_params("acknowledge")
def post_start_basic(self, params=None):
def post_start_basic(self, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/start-basic.html>`_
@@ -62,11 +66,11 @@ class LicenseClient(NamespacedClient):
messages (default: false)
"""
return self.transport.perform_request(
"POST", "/_license/start_basic", params=params
"POST", "/_license/start_basic", params=params, headers=headers
)
@query_params("acknowledge", "doc_type")
def post_start_trial(self, params=None):
def post_start_trial(self, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/start-trial.html>`_
@@ -80,5 +84,5 @@ class LicenseClient(NamespacedClient):
params["type"] = params.pop("doc_type")
return self.transport.perform_request(
"POST", "/_license/start_trial", params=params
"POST", "/_license/start_trial", params=params, headers=headers
)
+5 -2
View File
@@ -3,12 +3,15 @@ from .utils import NamespacedClient, query_params, _make_path
class MigrationClient(NamespacedClient):
@query_params()
def deprecations(self, index=None, params=None):
def deprecations(self, index=None, params=None, headers=None):
"""
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/migration-api-deprecation.html>`_
:arg index: Index pattern
"""
return self.transport.perform_request(
"GET", _make_path(index, "_migration", "deprecations"), params=params
"GET",
_make_path(index, "_migration", "deprecations"),
params=params,
headers=headers,
)
+182 -76
View File
@@ -3,7 +3,7 @@ from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH, _bu
class MlClient(NamespacedClient):
@query_params("allow_no_jobs", "force", "timeout")
def close_job(self, job_id, body=None, params=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>`_
@@ -23,11 +23,12 @@ class MlClient(NamespacedClient):
"POST",
_make_path("_ml", "anomaly_detectors", job_id, "_close"),
params=params,
headers=headers,
body=body,
)
@query_params()
def delete_calendar(self, calendar_id, params=None):
def delete_calendar(self, calendar_id, params=None, headers=None):
"""
:arg calendar_id: The ID of the calendar to delete
@@ -38,11 +39,14 @@ class MlClient(NamespacedClient):
)
return self.transport.perform_request(
"DELETE", _make_path("_ml", "calendars", calendar_id), params=params
"DELETE",
_make_path("_ml", "calendars", calendar_id),
params=params,
headers=headers,
)
@query_params()
def delete_calendar_event(self, calendar_id, event_id, params=None):
def delete_calendar_event(self, calendar_id, event_id, params=None, headers=None):
"""
:arg calendar_id: The ID of the calendar to modify
@@ -56,10 +60,11 @@ class MlClient(NamespacedClient):
"DELETE",
_make_path("_ml", "calendars", calendar_id, "events", event_id),
params=params,
headers=headers,
)
@query_params()
def delete_calendar_job(self, calendar_id, job_id, params=None):
def delete_calendar_job(self, calendar_id, job_id, params=None, headers=None):
"""
:arg calendar_id: The ID of the calendar to modify
@@ -73,10 +78,11 @@ class MlClient(NamespacedClient):
"DELETE",
_make_path("_ml", "calendars", calendar_id, "jobs", job_id),
params=params,
headers=headers,
)
@query_params("force")
def delete_datafeed(self, datafeed_id, params=None):
def delete_datafeed(self, datafeed_id, params=None, headers=None):
"""
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-datafeed.html>`_
@@ -89,20 +95,23 @@ class MlClient(NamespacedClient):
)
return self.transport.perform_request(
"DELETE", _make_path("_ml", "datafeeds", datafeed_id), params=params
"DELETE",
_make_path("_ml", "datafeeds", datafeed_id),
params=params,
headers=headers,
)
@query_params()
def delete_expired_data(self, params=None):
def delete_expired_data(self, params=None, headers=None):
"""
"""
return self.transport.perform_request(
"DELETE", "/_ml/_delete_expired_data", params=params
"DELETE", "/_ml/_delete_expired_data", params=params, headers=headers
)
@query_params()
def delete_filter(self, filter_id, params=None):
def delete_filter(self, filter_id, params=None, headers=None):
"""
:arg filter_id: The ID of the filter to delete
@@ -111,11 +120,14 @@ class MlClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'filter_id'.")
return self.transport.perform_request(
"DELETE", _make_path("_ml", "filters", filter_id), params=params
"DELETE",
_make_path("_ml", "filters", filter_id),
params=params,
headers=headers,
)
@query_params("allow_no_forecasts", "timeout")
def delete_forecast(self, job_id, forecast_id=None, params=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>`_
@@ -134,10 +146,11 @@ class MlClient(NamespacedClient):
"DELETE",
_make_path("_ml", "anomaly_detectors", job_id, "_forecast", forecast_id),
params=params,
headers=headers,
)
@query_params("force", "wait_for_completion")
def delete_job(self, job_id, params=None):
def delete_job(self, job_id, params=None, headers=None):
"""
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-job.html>`_
@@ -150,11 +163,14 @@ class MlClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'job_id'.")
return self.transport.perform_request(
"DELETE", _make_path("_ml", "anomaly_detectors", job_id), params=params
"DELETE",
_make_path("_ml", "anomaly_detectors", job_id),
params=params,
headers=headers,
)
@query_params()
def delete_model_snapshot(self, job_id, snapshot_id, params=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>`_
@@ -171,6 +187,7 @@ class MlClient(NamespacedClient):
"_ml", "anomaly_detectors", job_id, "model_snapshots", snapshot_id
),
params=params,
headers=headers,
)
@query_params(
@@ -189,7 +206,7 @@ class MlClient(NamespacedClient):
"timestamp_field",
"timestamp_format",
)
def find_file_structure(self, body, params=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>`_
@@ -231,11 +248,15 @@ class MlClient(NamespacedClient):
body = _bulk_body(self.transport.serializer, body)
return self.transport.perform_request(
"POST", "/_ml/find_file_structure", params=params, body=body
"POST",
"/_ml/find_file_structure",
params=params,
headers=headers,
body=body,
)
@query_params("advance_time", "calc_interim", "end", "skip_time", "start")
def flush_job(self, job_id, body=None, params=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>`_
@@ -259,11 +280,12 @@ class MlClient(NamespacedClient):
"POST",
_make_path("_ml", "anomaly_detectors", job_id, "_flush"),
params=params,
headers=headers,
body=body,
)
@query_params("duration", "expires_in")
def forecast(self, job_id, params=None):
def forecast(self, job_id, params=None, headers=None):
"""
:arg job_id: The ID of the job to forecast for
@@ -278,6 +300,7 @@ class MlClient(NamespacedClient):
"POST",
_make_path("_ml", "anomaly_detectors", job_id, "_forecast"),
params=params,
headers=headers,
)
@query_params(
@@ -291,7 +314,7 @@ class MlClient(NamespacedClient):
"sort",
"start",
)
def get_buckets(self, job_id, body=None, timestamp=None, params=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>`_
@@ -322,11 +345,12 @@ class MlClient(NamespacedClient):
"_ml", "anomaly_detectors", job_id, "results", "buckets", timestamp
),
params=params,
headers=headers,
body=body,
)
@query_params("end", "from_", "job_id", "size", "start")
def get_calendar_events(self, calendar_id, params=None):
def get_calendar_events(self, calendar_id, params=None, headers=None):
"""
:arg calendar_id: The ID of the calendar containing the events
@@ -347,11 +371,14 @@ class MlClient(NamespacedClient):
)
return self.transport.perform_request(
"GET", _make_path("_ml", "calendars", calendar_id, "events"), params=params
"GET",
_make_path("_ml", "calendars", calendar_id, "events"),
params=params,
headers=headers,
)
@query_params("from_", "size")
def get_calendars(self, body=None, calendar_id=None, params=None):
def get_calendars(self, body=None, calendar_id=None, params=None, headers=None):
"""
:arg body: The from and size parameters optionally sent in the
@@ -365,11 +392,17 @@ class MlClient(NamespacedClient):
params["from"] = params.pop("from_")
return self.transport.perform_request(
"GET", _make_path("_ml", "calendars", calendar_id), params=params, body=body
"GET",
_make_path("_ml", "calendars", calendar_id),
params=params,
headers=headers,
body=body,
)
@query_params("from_", "size")
def get_categories(self, job_id, body=None, category_id=None, params=None):
def get_categories(
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>`_
@@ -393,11 +426,12 @@ class MlClient(NamespacedClient):
"_ml", "anomaly_detectors", job_id, "results", "categories", category_id
),
params=params,
headers=headers,
body=body,
)
@query_params("allow_no_datafeeds")
def get_datafeed_stats(self, datafeed_id=None, params=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>`_
@@ -407,11 +441,14 @@ class MlClient(NamespacedClient):
datafeeds have been specified)
"""
return self.transport.perform_request(
"GET", _make_path("_ml", "datafeeds", datafeed_id, "_stats"), params=params
"GET",
_make_path("_ml", "datafeeds", datafeed_id, "_stats"),
params=params,
headers=headers,
)
@query_params("allow_no_datafeeds")
def get_datafeeds(self, datafeed_id=None, params=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>`_
@@ -421,11 +458,14 @@ class MlClient(NamespacedClient):
datafeeds have been specified)
"""
return self.transport.perform_request(
"GET", _make_path("_ml", "datafeeds", datafeed_id), params=params
"GET",
_make_path("_ml", "datafeeds", datafeed_id),
params=params,
headers=headers,
)
@query_params("from_", "size")
def get_filters(self, filter_id=None, params=None):
def get_filters(self, filter_id=None, params=None, headers=None):
"""
:arg filter_id: The ID of the filter to fetch
@@ -437,7 +477,10 @@ class MlClient(NamespacedClient):
params["from"] = params.pop("from_")
return self.transport.perform_request(
"GET", _make_path("_ml", "filters", filter_id), params=params
"GET",
_make_path("_ml", "filters", filter_id),
params=params,
headers=headers,
)
@query_params(
@@ -450,7 +493,7 @@ class MlClient(NamespacedClient):
"sort",
"start",
)
def get_influencers(self, job_id, body=None, params=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>`_
@@ -478,11 +521,12 @@ class MlClient(NamespacedClient):
"GET",
_make_path("_ml", "anomaly_detectors", job_id, "results", "influencers"),
params=params,
headers=headers,
body=body,
)
@query_params("allow_no_jobs")
def get_job_stats(self, job_id=None, params=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>`_
@@ -495,10 +539,11 @@ class MlClient(NamespacedClient):
"GET",
_make_path("_ml", "anomaly_detectors", job_id, "_stats"),
params=params,
headers=headers,
)
@query_params("allow_no_jobs")
def get_jobs(self, job_id=None, params=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>`_
@@ -508,11 +553,16 @@ class MlClient(NamespacedClient):
specified)
"""
return self.transport.perform_request(
"GET", _make_path("_ml", "anomaly_detectors", job_id), params=params
"GET",
_make_path("_ml", "anomaly_detectors", job_id),
params=params,
headers=headers,
)
@query_params("desc", "end", "from_", "size", "sort", "start")
def get_model_snapshots(self, job_id, body=None, snapshot_id=None, params=None):
def get_model_snapshots(
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>`_
@@ -541,6 +591,7 @@ class MlClient(NamespacedClient):
"_ml", "anomaly_detectors", job_id, "model_snapshots", snapshot_id
),
params=params,
headers=headers,
body=body,
)
@@ -553,7 +604,7 @@ class MlClient(NamespacedClient):
"start",
"top_n",
)
def get_overall_buckets(self, job_id, body=None, params=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>`_
@@ -586,6 +637,7 @@ class MlClient(NamespacedClient):
"_ml", "anomaly_detectors", job_id, "results", "overall_buckets"
),
params=params,
headers=headers,
body=body,
)
@@ -599,7 +651,7 @@ class MlClient(NamespacedClient):
"sort",
"start",
)
def get_records(self, job_id, body=None, params=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>`_
@@ -625,18 +677,21 @@ class MlClient(NamespacedClient):
"GET",
_make_path("_ml", "anomaly_detectors", job_id, "results", "records"),
params=params,
headers=headers,
body=body,
)
@query_params()
def info(self, params=None):
def info(self, params=None, headers=None):
"""
"""
return self.transport.perform_request("GET", "/_ml/info", params=params)
return self.transport.perform_request(
"GET", "/_ml/info", params=params, headers=headers
)
@query_params()
def open_job(self, job_id, params=None):
def open_job(self, job_id, params=None, headers=None):
"""
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-open-job.html>`_
@@ -649,10 +704,11 @@ class MlClient(NamespacedClient):
"POST",
_make_path("_ml", "anomaly_detectors", job_id, "_open"),
params=params,
headers=headers,
)
@query_params()
def post_calendar_events(self, calendar_id, body, params=None):
def post_calendar_events(self, calendar_id, body, params=None, headers=None):
"""
:arg calendar_id: The ID of the calendar to modify
@@ -666,11 +722,12 @@ class MlClient(NamespacedClient):
"POST",
_make_path("_ml", "calendars", calendar_id, "events"),
params=params,
headers=headers,
body=body,
)
@query_params("reset_end", "reset_start")
def post_data(self, job_id, body, params=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>`_
@@ -690,11 +747,12 @@ class MlClient(NamespacedClient):
"POST",
_make_path("_ml", "anomaly_detectors", job_id, "_data"),
params=params,
headers=headers,
body=body,
)
@query_params()
def preview_datafeed(self, datafeed_id, params=None):
def preview_datafeed(self, datafeed_id, params=None, headers=None):
"""
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-preview-datafeed.html>`_
@@ -709,10 +767,11 @@ class MlClient(NamespacedClient):
"GET",
_make_path("_ml", "datafeeds", datafeed_id, "_preview"),
params=params,
headers=headers,
)
@query_params()
def put_calendar(self, calendar_id, body=None, params=None):
def put_calendar(self, calendar_id, body=None, params=None, headers=None):
"""
:arg calendar_id: The ID of the calendar to create
@@ -724,11 +783,15 @@ class MlClient(NamespacedClient):
)
return self.transport.perform_request(
"PUT", _make_path("_ml", "calendars", calendar_id), params=params, body=body
"PUT",
_make_path("_ml", "calendars", calendar_id),
params=params,
headers=headers,
body=body,
)
@query_params()
def put_calendar_job(self, calendar_id, job_id, params=None):
def put_calendar_job(self, calendar_id, job_id, params=None, headers=None):
"""
:arg calendar_id: The ID of the calendar to modify
@@ -742,10 +805,11 @@ class MlClient(NamespacedClient):
"PUT",
_make_path("_ml", "calendars", calendar_id, "jobs", job_id),
params=params,
headers=headers,
)
@query_params()
def put_datafeed(self, datafeed_id, body, params=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>`_
@@ -757,11 +821,15 @@ class MlClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument.")
return self.transport.perform_request(
"PUT", _make_path("_ml", "datafeeds", datafeed_id), params=params, body=body
"PUT",
_make_path("_ml", "datafeeds", datafeed_id),
params=params,
headers=headers,
body=body,
)
@query_params()
def put_filter(self, filter_id, body, params=None):
def put_filter(self, filter_id, body, params=None, headers=None):
"""
:arg filter_id: The ID of the filter to create
@@ -772,11 +840,15 @@ class MlClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument.")
return self.transport.perform_request(
"PUT", _make_path("_ml", "filters", filter_id), params=params, body=body
"PUT",
_make_path("_ml", "filters", filter_id),
params=params,
headers=headers,
body=body,
)
@query_params()
def put_job(self, job_id, body, params=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>`_
@@ -791,11 +863,14 @@ class MlClient(NamespacedClient):
"PUT",
_make_path("_ml", "anomaly_detectors", job_id),
params=params,
headers=headers,
body=body,
)
@query_params("delete_intervening_results")
def revert_model_snapshot(self, job_id, snapshot_id, body=None, params=None):
def revert_model_snapshot(
self, job_id, snapshot_id, body=None, params=None, headers=None
):
"""
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-revert-snapshot.html>`_
@@ -820,11 +895,12 @@ class MlClient(NamespacedClient):
"_revert",
),
params=params,
headers=headers,
body=body,
)
@query_params("enabled", "timeout")
def set_upgrade_mode(self, params=None):
def set_upgrade_mode(self, params=None, headers=None):
"""
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-set-upgrade-mode.html>`_
@@ -834,11 +910,11 @@ class MlClient(NamespacedClient):
Defaults to 30 seconds
"""
return self.transport.perform_request(
"POST", "/_ml/set_upgrade_mode", params=params
"POST", "/_ml/set_upgrade_mode", params=params, headers=headers
)
@query_params("end", "start", "timeout")
def start_datafeed(self, datafeed_id, body=None, params=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>`_
@@ -859,11 +935,12 @@ class MlClient(NamespacedClient):
"POST",
_make_path("_ml", "datafeeds", datafeed_id, "_start"),
params=params,
headers=headers,
body=body,
)
@query_params("allow_no_datafeeds", "force", "timeout")
def stop_datafeed(self, datafeed_id, params=None):
def stop_datafeed(self, datafeed_id, params=None, headers=None):
"""
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-stop-datafeed.html>`_
@@ -881,11 +958,14 @@ class MlClient(NamespacedClient):
)
return self.transport.perform_request(
"POST", _make_path("_ml", "datafeeds", datafeed_id, "_stop"), params=params
"POST",
_make_path("_ml", "datafeeds", datafeed_id, "_stop"),
params=params,
headers=headers,
)
@query_params()
def update_datafeed(self, datafeed_id, body, params=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>`_
@@ -900,11 +980,12 @@ class MlClient(NamespacedClient):
"POST",
_make_path("_ml", "datafeeds", datafeed_id, "_update"),
params=params,
headers=headers,
body=body,
)
@query_params()
def update_filter(self, filter_id, body, params=None):
def update_filter(self, filter_id, body, params=None, headers=None):
"""
:arg filter_id: The ID of the filter to update
@@ -918,11 +999,12 @@ class MlClient(NamespacedClient):
"POST",
_make_path("_ml", "filters", filter_id, "_update"),
params=params,
headers=headers,
body=body,
)
@query_params()
def update_job(self, job_id, body, params=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>`_
@@ -937,11 +1019,14 @@ class MlClient(NamespacedClient):
"POST",
_make_path("_ml", "anomaly_detectors", job_id, "_update"),
params=params,
headers=headers,
body=body,
)
@query_params()
def update_model_snapshot(self, job_id, snapshot_id, body, params=None):
def update_model_snapshot(
self, job_id, snapshot_id, body, params=None, headers=None
):
"""
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-snapshot.html>`_
@@ -964,11 +1049,12 @@ class MlClient(NamespacedClient):
"_update",
),
params=params,
headers=headers,
body=body,
)
@query_params()
def validate(self, body, params=None):
def validate(self, body, params=None, headers=None):
"""
:arg body: The job config
@@ -977,11 +1063,15 @@ class MlClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'body'.")
return self.transport.perform_request(
"POST", "/_ml/anomaly_detectors/_validate", params=params, body=body
"POST",
"/_ml/anomaly_detectors/_validate",
params=params,
headers=headers,
body=body,
)
@query_params()
def validate_detector(self, body, params=None):
def validate_detector(self, body, params=None, headers=None):
"""
:arg body: The detector
@@ -993,11 +1083,12 @@ class MlClient(NamespacedClient):
"POST",
"/_ml/anomaly_detectors/_validate/detector",
params=params,
headers=headers,
body=body,
)
@query_params()
def delete_data_frame_analytics(self, id, params=None):
def delete_data_frame_analytics(self, id, params=None, headers=None):
"""
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/delete-dfanalytics.html>`_
@@ -1007,11 +1098,14 @@ class MlClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'id'.")
return self.transport.perform_request(
"DELETE", _make_path("_ml", "data_frame", "analytics", id), params=params
"DELETE",
_make_path("_ml", "data_frame", "analytics", id),
params=params,
headers=headers,
)
@query_params()
def estimate_memory_usage(self, body, params=None):
def estimate_memory_usage(self, body, params=None, headers=None):
"""
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/estimate-memory-usage-dfanalytics.html>`_
@@ -1024,11 +1118,12 @@ class MlClient(NamespacedClient):
"POST",
"/_ml/data_frame/analytics/_estimate_memory_usage",
params=params,
headers=headers,
body=body,
)
@query_params()
def evaluate_data_frame(self, body, params=None):
def evaluate_data_frame(self, body, params=None, headers=None):
"""
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/evaluate-dfanalytics.html>`_
@@ -1038,11 +1133,15 @@ class MlClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'body'.")
return self.transport.perform_request(
"POST", "/_ml/data_frame/_evaluate", params=params, body=body
"POST",
"/_ml/data_frame/_evaluate",
params=params,
headers=headers,
body=body,
)
@query_params("allow_no_match", "from_", "size")
def get_data_frame_analytics(self, id=None, params=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>`_
@@ -1059,11 +1158,14 @@ class MlClient(NamespacedClient):
params["from"] = params.pop("from_")
return self.transport.perform_request(
"GET", _make_path("_ml", "data_frame", "analytics", id), params=params
"GET",
_make_path("_ml", "data_frame", "analytics", id),
params=params,
headers=headers,
)
@query_params("allow_no_match", "from_", "size")
def get_data_frame_analytics_stats(self, id=None, params=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>`_
@@ -1083,10 +1185,11 @@ class MlClient(NamespacedClient):
"GET",
_make_path("_ml", "data_frame", "analytics", id, "_stats"),
params=params,
headers=headers,
)
@query_params()
def put_data_frame_analytics(self, id, body, params=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>`_
@@ -1101,11 +1204,12 @@ class MlClient(NamespacedClient):
"PUT",
_make_path("_ml", "data_frame", "analytics", id),
params=params,
headers=headers,
body=body,
)
@query_params("timeout")
def start_data_frame_analytics(self, id, body=None, params=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>`_
@@ -1121,11 +1225,12 @@ class MlClient(NamespacedClient):
"POST",
_make_path("_ml", "data_frame", "analytics", id, "_start"),
params=params,
headers=headers,
body=body,
)
@query_params("allow_no_match", "force", "timeout")
def stop_data_frame_analytics(self, id, body=None, params=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>`_
@@ -1146,5 +1251,6 @@ class MlClient(NamespacedClient):
"POST",
_make_path("_ml", "data_frame", "analytics", id, "_stop"),
params=params,
headers=headers,
body=body,
)
+2 -1
View File
@@ -3,7 +3,7 @@ from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH, _bu
class MonitoringClient(NamespacedClient):
@query_params("interval", "system_api_version", "system_id")
def bulk(self, body, doc_type=None, params=None):
def bulk(self, body, doc_type=None, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/es-monitoring.html>`_
@@ -24,5 +24,6 @@ class MonitoringClient(NamespacedClient):
"POST",
_make_path("_monitoring", doc_type, "bulk"),
params=params,
headers=headers,
body=body,
)
+18 -8
View File
@@ -3,7 +3,7 @@ from .utils import NamespacedClient, query_params, _make_path
class NodesClient(NamespacedClient):
@query_params("timeout")
def reload_secure_settings(self, node_id=None, params=None):
def reload_secure_settings(self, node_id=None, params=None, headers=None):
"""
Reloads secure settings.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/secure-settings.html#reloadable-secure-settings>`_
@@ -17,10 +17,11 @@ class NodesClient(NamespacedClient):
"POST",
_make_path("_nodes", node_id, "reload_secure_settings"),
params=params,
headers=headers,
)
@query_params("flat_settings", "timeout")
def info(self, node_id=None, metric=None, params=None):
def info(self, node_id=None, metric=None, params=None, headers=None):
"""
Returns information about nodes in the cluster.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-info.html>`_
@@ -37,7 +38,7 @@ class NodesClient(NamespacedClient):
:arg timeout: Explicit operation timeout
"""
return self.transport.perform_request(
"GET", _make_path("_nodes", node_id, metric), params=params
"GET", _make_path("_nodes", node_id, metric), params=params, headers=headers
)
@query_params(
@@ -50,7 +51,9 @@ class NodesClient(NamespacedClient):
"timeout",
"types",
)
def stats(self, node_id=None, metric=None, index_metric=None, params=None):
def stats(
self, node_id=None, metric=None, index_metric=None, params=None, headers=None
):
"""
Returns statistical information about nodes in the cluster.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-stats.html>`_
@@ -88,12 +91,13 @@ class NodesClient(NamespacedClient):
"GET",
_make_path("_nodes", node_id, "stats", metric, index_metric),
params=params,
headers=headers,
)
@query_params(
"doc_type", "ignore_idle_threads", "interval", "snapshots", "threads", "timeout"
)
def hot_threads(self, node_id=None, params=None):
def hot_threads(self, node_id=None, params=None, headers=None):
"""
Returns information about hot threads on each node in the cluster.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-hot-threads.html>`_
@@ -119,11 +123,14 @@ class NodesClient(NamespacedClient):
params["type"] = params.pop("doc_type")
return self.transport.perform_request(
"GET", _make_path("_nodes", node_id, "hot_threads"), params=params
"GET",
_make_path("_nodes", node_id, "hot_threads"),
params=params,
headers=headers,
)
@query_params("timeout")
def usage(self, node_id=None, metric=None, params=None):
def usage(self, node_id=None, metric=None, params=None, headers=None):
"""
Returns low-level information about REST actions usage on nodes.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-usage.html>`_
@@ -137,5 +144,8 @@ class NodesClient(NamespacedClient):
:arg timeout: Explicit operation timeout
"""
return self.transport.perform_request(
"GET", _make_path("_nodes", node_id, "usage", metric), params=params
"GET",
_make_path("_nodes", node_id, "usage", metric),
params=params,
headers=headers,
)
+4 -2
View File
@@ -3,8 +3,10 @@ from .utils import NamespacedClient, query_params
class RemoteClient(NamespacedClient):
@query_params()
def info(self, params=None):
def info(self, params=None, headers=None):
"""
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-remote-info.html>`_
"""
return self.transport.perform_request("GET", "/_remote/info", params=params)
return self.transport.perform_request(
"GET", "/_remote/info", params=params, headers=headers
)
+26 -15
View File
@@ -3,7 +3,7 @@ from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH
class RollupClient(NamespacedClient):
@query_params()
def delete_job(self, id, params=None):
def delete_job(self, id, params=None, headers=None):
"""
:arg id: The ID of the job to delete
@@ -12,33 +12,33 @@ class RollupClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'id'.")
return self.transport.perform_request(
"DELETE", _make_path("_rollup", "job", id), params=params
"DELETE", _make_path("_rollup", "job", id), params=params, headers=headers
)
@query_params()
def get_jobs(self, id=None, params=None):
def get_jobs(self, id=None, params=None, headers=None):
"""
:arg id: The ID of the job(s) to fetch. Accepts glob patterns,
or left blank for all jobs
"""
return self.transport.perform_request(
"GET", _make_path("_rollup", "job", id), params=params
"GET", _make_path("_rollup", "job", id), params=params, headers=headers
)
@query_params()
def get_rollup_caps(self, id=None, params=None):
def get_rollup_caps(self, id=None, params=None, headers=None):
"""
:arg id: The ID of the index to check rollup capabilities on, or
left blank for all jobs
"""
return self.transport.perform_request(
"GET", _make_path("_rollup", "data", id), params=params
"GET", _make_path("_rollup", "data", id), params=params, headers=headers
)
@query_params()
def get_rollup_index_caps(self, index, params=None):
def get_rollup_index_caps(self, index, params=None, headers=None):
"""
:arg index: The rollup index or index pattern to obtain rollup
@@ -48,11 +48,11 @@ class RollupClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'index'.")
return self.transport.perform_request(
"GET", _make_path(index, "_rollup", "data"), params=params
"GET", _make_path(index, "_rollup", "data"), params=params, headers=headers
)
@query_params()
def put_job(self, id, body, params=None):
def put_job(self, id, body, params=None, headers=None):
"""
:arg id: The ID of the job to create
@@ -63,11 +63,15 @@ class RollupClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument.")
return self.transport.perform_request(
"PUT", _make_path("_rollup", "job", id), params=params, body=body
"PUT",
_make_path("_rollup", "job", id),
params=params,
headers=headers,
body=body,
)
@query_params("rest_total_hits_as_int", "typed_keys")
def rollup_search(self, index, body, doc_type=None, params=None):
def rollup_search(self, index, body, doc_type=None, params=None, headers=None):
"""
:arg index: The indices or index-pattern(s) (containing rollup
@@ -87,11 +91,12 @@ class RollupClient(NamespacedClient):
"GET",
_make_path(index, doc_type, "_rollup_search"),
params=params,
headers=headers,
body=body,
)
@query_params()
def start_job(self, id, params=None):
def start_job(self, id, params=None, headers=None):
"""
:arg id: The ID of the job to start
@@ -100,11 +105,14 @@ class RollupClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'id'.")
return self.transport.perform_request(
"POST", _make_path("_rollup", "job", id, "_start"), params=params
"POST",
_make_path("_rollup", "job", id, "_start"),
params=params,
headers=headers,
)
@query_params("timeout", "wait_for_completion")
def stop_job(self, id, params=None):
def stop_job(self, id, params=None, headers=None):
"""
:arg id: The ID of the job to stop
@@ -118,5 +126,8 @@ class RollupClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'id'.")
return self.transport.perform_request(
"POST", _make_path("_rollup", "job", id, "_stop"), params=params
"POST",
_make_path("_rollup", "job", id, "_stop"),
params=params,
headers=headers,
)
+88 -46
View File
@@ -3,17 +3,17 @@ from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH
class SecurityClient(NamespacedClient):
@query_params()
def authenticate(self, params=None):
def authenticate(self, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-authenticate.html>`_
"""
return self.transport.perform_request(
"GET", "/_security/_authenticate", params=params
"GET", "/_security/_authenticate", params=params, headers=headers
)
@query_params("refresh")
def change_password(self, body, username=None, params=None):
def change_password(self, body, username=None, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-change-password.html>`_
@@ -32,11 +32,12 @@ class SecurityClient(NamespacedClient):
"PUT",
_make_path("_security", "user", username, "_password"),
params=params,
headers=headers,
body=body,
)
@query_params("usernames")
def clear_cached_realms(self, realms, params=None):
def clear_cached_realms(self, realms, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-cache.html>`_
@@ -51,10 +52,11 @@ class SecurityClient(NamespacedClient):
"POST",
_make_path("_security", "realm", realms, "_clear_cache"),
params=params,
headers=headers,
)
@query_params()
def clear_cached_roles(self, name, params=None):
def clear_cached_roles(self, name, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-role-cache.html>`_
@@ -64,11 +66,14 @@ class SecurityClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'name'.")
return self.transport.perform_request(
"POST", _make_path("_security", "role", name, "_clear_cache"), params=params
"POST",
_make_path("_security", "role", name, "_clear_cache"),
params=params,
headers=headers,
)
@query_params("refresh")
def create_api_key(self, body, params=None):
def create_api_key(self, body, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-api-key.html>`_
@@ -82,11 +87,11 @@ class SecurityClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'body'.")
return self.transport.perform_request(
"PUT", "/_security/api_key", params=params, body=body
"PUT", "/_security/api_key", params=params, headers=headers, body=body
)
@query_params("refresh")
def delete_privileges(self, application, name, params=None):
def delete_privileges(self, application, name, params=None, headers=None):
"""
`<TODO>`_
@@ -105,10 +110,11 @@ class SecurityClient(NamespacedClient):
"DELETE",
_make_path("_security", "privilege", application, name),
params=params,
headers=headers,
)
@query_params("refresh")
def delete_role(self, name, params=None):
def delete_role(self, name, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-role.html>`_
@@ -122,11 +128,14 @@ class SecurityClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'name'.")
return self.transport.perform_request(
"DELETE", _make_path("_security", "role", name), params=params
"DELETE",
_make_path("_security", "role", name),
params=params,
headers=headers,
)
@query_params("refresh")
def delete_role_mapping(self, name, params=None):
def delete_role_mapping(self, name, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-role-mapping.html>`_
@@ -140,11 +149,14 @@ class SecurityClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'name'.")
return self.transport.perform_request(
"DELETE", _make_path("_security", "role_mapping", name), params=params
"DELETE",
_make_path("_security", "role_mapping", name),
params=params,
headers=headers,
)
@query_params("refresh")
def delete_user(self, username, params=None):
def delete_user(self, username, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-user.html>`_
@@ -158,11 +170,14 @@ class SecurityClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'username'.")
return self.transport.perform_request(
"DELETE", _make_path("_security", "user", username), params=params
"DELETE",
_make_path("_security", "user", username),
params=params,
headers=headers,
)
@query_params("refresh")
def disable_user(self, username, params=None):
def disable_user(self, username, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-disable-user.html>`_
@@ -176,11 +191,14 @@ class SecurityClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'username'.")
return self.transport.perform_request(
"PUT", _make_path("_security", "user", username, "_disable"), params=params
"PUT",
_make_path("_security", "user", username, "_disable"),
params=params,
headers=headers,
)
@query_params("refresh")
def enable_user(self, username, params=None):
def enable_user(self, username, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-enable-user.html>`_
@@ -194,11 +212,14 @@ class SecurityClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'username'.")
return self.transport.perform_request(
"PUT", _make_path("_security", "user", username, "_enable"), params=params
"PUT",
_make_path("_security", "user", username, "_enable"),
params=params,
headers=headers,
)
@query_params("id", "name", "owner", "realm_name", "username")
def get_api_key(self, params=None):
def get_api_key(self, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-api-key.html>`_
@@ -212,11 +233,11 @@ class SecurityClient(NamespacedClient):
be retrieved
"""
return self.transport.perform_request(
"GET", "/_security/api_key", params=params
"GET", "/_security/api_key", params=params, headers=headers
)
@query_params()
def get_privileges(self, application=None, name=None, params=None):
def get_privileges(self, application=None, name=None, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-privileges.html>`_
@@ -227,32 +248,36 @@ class SecurityClient(NamespacedClient):
"GET",
_make_path("_security", "privilege", application, name),
params=params,
headers=headers,
)
@query_params()
def get_role(self, name=None, params=None):
def get_role(self, name=None, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-role.html>`_
:arg name: Role name
"""
return self.transport.perform_request(
"GET", _make_path("_security", "role", name), params=params
"GET", _make_path("_security", "role", name), params=params, headers=headers
)
@query_params()
def get_role_mapping(self, name=None, params=None):
def get_role_mapping(self, name=None, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-role-mapping.html>`_
:arg name: Role-Mapping name
"""
return self.transport.perform_request(
"GET", _make_path("_security", "role_mapping", name), params=params
"GET",
_make_path("_security", "role_mapping", name),
params=params,
headers=headers,
)
@query_params()
def get_token(self, body, params=None):
def get_token(self, body, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-token.html>`_
@@ -262,32 +287,35 @@ class SecurityClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'body'.")
return self.transport.perform_request(
"POST", "/_security/oauth2/token", params=params, body=body
"POST", "/_security/oauth2/token", params=params, headers=headers, body=body
)
@query_params()
def get_user(self, username=None, params=None):
def get_user(self, username=None, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-user.html>`_
:arg username: A comma-separated list of usernames
"""
return self.transport.perform_request(
"GET", _make_path("_security", "user", username), params=params
"GET",
_make_path("_security", "user", username),
params=params,
headers=headers,
)
@query_params()
def get_user_privileges(self, params=None):
def get_user_privileges(self, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-privileges.html>`_
"""
return self.transport.perform_request(
"GET", "/_security/user/_privileges", params=params
"GET", "/_security/user/_privileges", params=params, headers=headers
)
@query_params()
def has_privileges(self, body, user=None, params=None):
def has_privileges(self, body, user=None, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-has-privileges.html>`_
@@ -301,11 +329,12 @@ class SecurityClient(NamespacedClient):
"GET",
_make_path("_security", "user", user, "_has_privileges"),
params=params,
headers=headers,
body=body,
)
@query_params()
def invalidate_api_key(self, body, params=None):
def invalidate_api_key(self, body, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-invalidate-api-key.html>`_
@@ -315,11 +344,11 @@ class SecurityClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'body'.")
return self.transport.perform_request(
"DELETE", "/_security/api_key", params=params, body=body
"DELETE", "/_security/api_key", params=params, headers=headers, body=body
)
@query_params()
def invalidate_token(self, body, params=None):
def invalidate_token(self, body, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-invalidate-token.html>`_
@@ -329,11 +358,15 @@ class SecurityClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'body'.")
return self.transport.perform_request(
"DELETE", "/_security/oauth2/token", params=params, body=body
"DELETE",
"/_security/oauth2/token",
params=params,
headers=headers,
body=body,
)
@query_params("refresh")
def put_privileges(self, body, params=None):
def put_privileges(self, body, params=None, headers=None):
"""
`<TODO>`_
@@ -347,11 +380,11 @@ class SecurityClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'body'.")
return self.transport.perform_request(
"PUT", "/_security/privilege/", params=params, body=body
"PUT", "/_security/privilege/", params=params, headers=headers, body=body
)
@query_params("refresh")
def put_role(self, name, body, params=None):
def put_role(self, name, body, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-role.html>`_
@@ -367,11 +400,15 @@ class SecurityClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument.")
return self.transport.perform_request(
"PUT", _make_path("_security", "role", name), params=params, body=body
"PUT",
_make_path("_security", "role", name),
params=params,
headers=headers,
body=body,
)
@query_params("refresh")
def put_role_mapping(self, name, body, params=None):
def put_role_mapping(self, name, body, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-role-mapping.html>`_
@@ -390,11 +427,12 @@ class SecurityClient(NamespacedClient):
"PUT",
_make_path("_security", "role_mapping", name),
params=params,
headers=headers,
body=body,
)
@query_params("refresh")
def put_user(self, username, body, params=None):
def put_user(self, username, body, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-user.html>`_
@@ -410,15 +448,19 @@ class SecurityClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument.")
return self.transport.perform_request(
"PUT", _make_path("_security", "user", username), params=params, body=body
"PUT",
_make_path("_security", "user", username),
params=params,
headers=headers,
body=body,
)
@query_params()
def get_builtin_privileges(self, params=None):
def get_builtin_privileges(self, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-builtin-privileges.html>`_
"""
return self.transport.perform_request(
"GET", "/_security/privilege/_builtin", params=params
"GET", "/_security/privilege/_builtin", params=params, headers=headers
)
+39 -18
View File
@@ -3,7 +3,7 @@ from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH
class SlmClient(NamespacedClient):
@query_params()
def delete_lifecycle(self, policy_id, params=None):
def delete_lifecycle(self, policy_id, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-delete.html>`_
@@ -14,11 +14,14 @@ class SlmClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'policy_id'.")
return self.transport.perform_request(
"DELETE", _make_path("_slm", "policy", policy_id), params=params
"DELETE",
_make_path("_slm", "policy", policy_id),
params=params,
headers=headers,
)
@query_params()
def execute_lifecycle(self, policy_id, params=None):
def execute_lifecycle(self, policy_id, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-execute.html>`_
@@ -29,21 +32,24 @@ class SlmClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'policy_id'.")
return self.transport.perform_request(
"PUT", _make_path("_slm", "policy", policy_id, "_execute"), params=params
"PUT",
_make_path("_slm", "policy", policy_id, "_execute"),
params=params,
headers=headers,
)
@query_params()
def execute_retention(self, params=None):
def execute_retention(self, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-execute-retention.html>`_
"""
return self.transport.perform_request(
"POST", "/_slm/_execute_retention", params=params
"POST", "/_slm/_execute_retention", params=params, headers=headers
)
@query_params()
def get_lifecycle(self, policy_id=None, params=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>`_
@@ -51,19 +57,24 @@ class SlmClient(NamespacedClient):
policies to retrieve
"""
return self.transport.perform_request(
"GET", _make_path("_slm", "policy", policy_id), params=params
"GET",
_make_path("_slm", "policy", policy_id),
params=params,
headers=headers,
)
@query_params()
def get_stats(self, params=None):
def get_stats(self, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/slm-get-stats.html>`_
"""
return self.transport.perform_request("GET", "/_slm/stats", params=params)
return self.transport.perform_request(
"GET", "/_slm/stats", params=params, headers=headers
)
@query_params()
def put_lifecycle(self, policy_id, body=None, params=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>`_
@@ -74,29 +85,39 @@ class SlmClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'policy_id'.")
return self.transport.perform_request(
"PUT", _make_path("_slm", "policy", policy_id), params=params, body=body
"PUT",
_make_path("_slm", "policy", policy_id),
params=params,
headers=headers,
body=body,
)
@query_params()
def get_status(self, params=None):
def get_status(self, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-get-status.html>`_
"""
return self.transport.perform_request("GET", "/_slm/status", params=params)
return self.transport.perform_request(
"GET", "/_slm/status", params=params, headers=headers
)
@query_params()
def start(self, params=None):
def start(self, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-start.html>`_
"""
return self.transport.perform_request("POST", "/_slm/start", params=params)
return self.transport.perform_request(
"POST", "/_slm/start", params=params, headers=headers
)
@query_params()
def stop(self, params=None):
def stop(self, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-stop.html>`_
"""
return self.transport.perform_request("POST", "/_slm/stop", params=params)
return self.transport.perform_request(
"POST", "/_slm/stop", params=params, headers=headers
)
+39 -17
View File
@@ -3,7 +3,7 @@ from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH
class SnapshotClient(NamespacedClient):
@query_params("master_timeout", "wait_for_completion")
def create(self, repository, snapshot, body=None, params=None):
def create(self, repository, snapshot, body=None, params=None, headers=None):
"""
Creates a snapshot in a repository.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html>`_
@@ -24,11 +24,12 @@ class SnapshotClient(NamespacedClient):
"PUT",
_make_path("_snapshot", repository, snapshot),
params=params,
headers=headers,
body=body,
)
@query_params("master_timeout")
def delete(self, repository, snapshot, params=None):
def delete(self, repository, snapshot, params=None, headers=None):
"""
Deletes a snapshot.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html>`_
@@ -43,11 +44,14 @@ class SnapshotClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument.")
return self.transport.perform_request(
"DELETE", _make_path("_snapshot", repository, snapshot), params=params
"DELETE",
_make_path("_snapshot", repository, snapshot),
params=params,
headers=headers,
)
@query_params("ignore_unavailable", "master_timeout", "verbose")
def get(self, repository, snapshot, params=None):
def get(self, repository, snapshot, params=None, headers=None):
"""
Returns information about a snapshot.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html>`_
@@ -67,11 +71,14 @@ class SnapshotClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument.")
return self.transport.perform_request(
"GET", _make_path("_snapshot", repository, snapshot), params=params
"GET",
_make_path("_snapshot", repository, snapshot),
params=params,
headers=headers,
)
@query_params("master_timeout", "timeout")
def delete_repository(self, repository, params=None):
def delete_repository(self, repository, params=None, headers=None):
"""
Deletes a repository.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html>`_
@@ -85,11 +92,14 @@ class SnapshotClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'repository'.")
return self.transport.perform_request(
"DELETE", _make_path("_snapshot", repository), params=params
"DELETE",
_make_path("_snapshot", repository),
params=params,
headers=headers,
)
@query_params("local", "master_timeout")
def get_repository(self, repository=None, params=None):
def get_repository(self, repository=None, params=None, headers=None):
"""
Returns information about a repository.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html>`_
@@ -101,11 +111,11 @@ class SnapshotClient(NamespacedClient):
to master node
"""
return self.transport.perform_request(
"GET", _make_path("_snapshot", repository), params=params
"GET", _make_path("_snapshot", repository), params=params, headers=headers
)
@query_params("master_timeout", "timeout", "verify")
def create_repository(self, repository, body, params=None):
def create_repository(self, repository, body, params=None, headers=None):
"""
Creates a repository.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html>`_
@@ -122,11 +132,15 @@ class SnapshotClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument.")
return self.transport.perform_request(
"PUT", _make_path("_snapshot", repository), params=params, body=body
"PUT",
_make_path("_snapshot", repository),
params=params,
headers=headers,
body=body,
)
@query_params("master_timeout", "wait_for_completion")
def restore(self, repository, snapshot, body=None, params=None):
def restore(self, repository, snapshot, body=None, params=None, headers=None):
"""
Restores a snapshot.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html>`_
@@ -147,11 +161,12 @@ class SnapshotClient(NamespacedClient):
"POST",
_make_path("_snapshot", repository, snapshot, "_restore"),
params=params,
headers=headers,
body=body,
)
@query_params("ignore_unavailable", "master_timeout")
def status(self, repository=None, snapshot=None, params=None):
def status(self, repository=None, snapshot=None, params=None, headers=None):
"""
Returns information about the status of a snapshot.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html>`_
@@ -168,10 +183,11 @@ class SnapshotClient(NamespacedClient):
"GET",
_make_path("_snapshot", repository, snapshot, "_status"),
params=params,
headers=headers,
)
@query_params("master_timeout", "timeout")
def verify_repository(self, repository, params=None):
def verify_repository(self, repository, params=None, headers=None):
"""
Verifies a repository.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html>`_
@@ -185,11 +201,14 @@ class SnapshotClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'repository'.")
return self.transport.perform_request(
"POST", _make_path("_snapshot", repository, "_verify"), params=params
"POST",
_make_path("_snapshot", repository, "_verify"),
params=params,
headers=headers,
)
@query_params("master_timeout", "timeout")
def cleanup_repository(self, repository, params=None):
def cleanup_repository(self, repository, params=None, headers=None):
"""
Removes stale data from repository.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html>`_
@@ -203,5 +222,8 @@ class SnapshotClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'repository'.")
return self.transport.perform_request(
"POST", _make_path("_snapshot", repository, "_cleanup"), params=params
"POST",
_make_path("_snapshot", repository, "_cleanup"),
params=params,
headers=headers,
)
+8 -6
View File
@@ -3,7 +3,7 @@ from .utils import NamespacedClient, query_params, SKIP_IN_PATH
class SqlClient(NamespacedClient):
@query_params()
def clear_cursor(self, body, params=None):
def clear_cursor(self, body, params=None, headers=None):
"""
`<Clear SQL cursor>`_
@@ -14,11 +14,11 @@ class SqlClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'body'.")
return self.transport.perform_request(
"POST", "/_sql/close", params=params, body=body
"POST", "/_sql/close", params=params, headers=headers, body=body
)
@query_params("format")
def query(self, body, params=None):
def query(self, body, params=None, headers=None):
"""
`<Execute SQL>`_
@@ -30,10 +30,12 @@ class SqlClient(NamespacedClient):
if body in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'body'.")
return self.transport.perform_request("POST", "/_sql", params=params, body=body)
return self.transport.perform_request(
"POST", "/_sql", params=params, headers=headers, body=body
)
@query_params()
def translate(self, body, params=None):
def translate(self, body, params=None, headers=None):
"""
`<Translate SQL into Elasticsearch queries>`_
@@ -43,5 +45,5 @@ class SqlClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'body'.")
return self.transport.perform_request(
"POST", "/_sql/translate", params=params, body=body
"POST", "/_sql/translate", params=params, headers=headers, body=body
)
+2 -2
View File
@@ -3,11 +3,11 @@ from .utils import NamespacedClient, query_params
class SslClient(NamespacedClient):
@query_params()
def certificates(self, params=None):
def certificates(self, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-ssl.html>`_
"""
return self.transport.perform_request(
"GET", "/_ssl/certificates", params=params
"GET", "/_ssl/certificates", params=params, headers=headers
)
+11 -6
View File
@@ -11,7 +11,7 @@ class TasksClient(NamespacedClient):
"timeout",
"wait_for_completion",
)
def list(self, params=None):
def list(self, params=None, headers=None):
"""
Returns a list of tasks.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html>`_
@@ -30,10 +30,12 @@ class TasksClient(NamespacedClient):
:arg wait_for_completion: Wait for the matching tasks to
complete (default: false)
"""
return self.transport.perform_request("GET", "/_tasks", params=params)
return self.transport.perform_request(
"GET", "/_tasks", params=params, headers=headers
)
@query_params("actions", "nodes", "parent_task_id")
def cancel(self, task_id=None, params=None):
def cancel(self, task_id=None, params=None, headers=None):
"""
Cancels a task, if it can be cancelled through an API.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html>`_
@@ -49,11 +51,14 @@ class TasksClient(NamespacedClient):
(node_id:task_number). Set to -1 to cancel all.
"""
return self.transport.perform_request(
"POST", _make_path("_tasks", task_id, "_cancel"), params=params
"POST",
_make_path("_tasks", task_id, "_cancel"),
params=params,
headers=headers,
)
@query_params("timeout", "wait_for_completion")
def get(self, task_id, params=None):
def get(self, task_id, params=None, headers=None):
"""
Returns information about a task.
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html>`_
@@ -68,5 +73,5 @@ class TasksClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'task_id'.")
return self.transport.perform_request(
"GET", _make_path("_tasks", task_id), params=params
"GET", _make_path("_tasks", task_id), params=params, headers=headers
)
+35 -15
View File
@@ -3,7 +3,7 @@ from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH
class TransformClient(NamespacedClient):
@query_params("force")
def delete_transform(self, transform_id, params=None):
def delete_transform(self, transform_id, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-transform.html>`_
@@ -18,11 +18,14 @@ class TransformClient(NamespacedClient):
)
return self.transport.perform_request(
"DELETE", _make_path("_transform", transform_id), params=params
"DELETE",
_make_path("_transform", transform_id),
params=params,
headers=headers,
)
@query_params("allow_no_match", "from_", "size")
def get_transform(self, transform_id=None, params=None):
def get_transform(self, transform_id=None, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/get-transform.html>`_
@@ -41,11 +44,14 @@ class TransformClient(NamespacedClient):
params["from"] = params.pop("from_")
return self.transport.perform_request(
"GET", _make_path("_transform", transform_id), params=params
"GET",
_make_path("_transform", transform_id),
params=params,
headers=headers,
)
@query_params("allow_no_match", "from_", "size")
def get_transform_stats(self, transform_id, params=None):
def get_transform_stats(self, transform_id, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/get-transform-stats.html>`_
@@ -68,11 +74,14 @@ class TransformClient(NamespacedClient):
)
return self.transport.perform_request(
"GET", _make_path("_transform", transform_id, "_stats"), params=params
"GET",
_make_path("_transform", transform_id, "_stats"),
params=params,
headers=headers,
)
@query_params()
def preview_transform(self, body, params=None):
def preview_transform(self, body, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/preview-transform.html>`_
@@ -82,11 +91,11 @@ class TransformClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'body'.")
return self.transport.perform_request(
"POST", "/_transform/_preview", params=params, body=body
"POST", "/_transform/_preview", params=params, headers=headers, body=body
)
@query_params("defer_validation")
def put_transform(self, transform_id, body, params=None):
def put_transform(self, transform_id, body, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/put-transform.html>`_
@@ -100,11 +109,15 @@ class TransformClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument.")
return self.transport.perform_request(
"PUT", _make_path("_transform", transform_id), params=params, body=body
"PUT",
_make_path("_transform", transform_id),
params=params,
headers=headers,
body=body,
)
@query_params("timeout")
def start_transform(self, transform_id, params=None):
def start_transform(self, transform_id, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/start-transform.html>`_
@@ -118,11 +131,14 @@ class TransformClient(NamespacedClient):
)
return self.transport.perform_request(
"POST", _make_path("_transform", transform_id, "_start"), params=params
"POST",
_make_path("_transform", transform_id, "_start"),
params=params,
headers=headers,
)
@query_params("allow_no_match", "timeout", "wait_for_completion")
def stop_transform(self, transform_id, params=None):
def stop_transform(self, transform_id, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/stop-transform.html>`_
@@ -141,11 +157,14 @@ class TransformClient(NamespacedClient):
)
return self.transport.perform_request(
"POST", _make_path("_transform", transform_id, "_stop"), params=params
"POST",
_make_path("_transform", transform_id, "_stop"),
params=params,
headers=headers,
)
@query_params("defer_validation")
def update_transform(self, transform_id, body, params=None):
def update_transform(self, transform_id, body, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/update-transform.html>`_
@@ -162,5 +181,6 @@ class TransformClient(NamespacedClient):
"POST",
_make_path("_transform", transform_id, "_update"),
params=params,
headers=headers,
body=body,
)
+10 -2
View File
@@ -69,19 +69,27 @@ def query_params(*es_query_params):
@wraps(func)
def _wrapped(*args, **kwargs):
params = {}
headers = {}
if "params" in kwargs:
params = kwargs.pop("params").copy()
if "headers" in kwargs:
headers = {
k.lower(): v for k, v in (kwargs.pop("headers") or {}).items()
}
if "opaque_id" in kwargs:
headers["x-opaque-id"] = kwargs.pop("opaque_id")
for p in es_query_params + GLOBAL_PARAMS:
if p in kwargs:
v = kwargs.pop(p)
if v is not None:
params[p] = _escape(v)
# don't treat ignore and request_timeout as other params to avoid escaping
# don't treat ignore, request_timeout, and opaque_id as other params to avoid escaping
for p in ("ignore", "request_timeout"):
if p in kwargs:
params[p] = kwargs.pop(p)
return func(*args, params=params, **kwargs)
return func(*args, params=params, headers=headers, **kwargs)
return _wrapped
+37 -17
View File
@@ -3,7 +3,7 @@ from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH
class WatcherClient(NamespacedClient):
@query_params()
def ack_watch(self, watch_id, action_id=None, params=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>`_
@@ -18,10 +18,11 @@ class WatcherClient(NamespacedClient):
"PUT",
_make_path("_watcher", "watch", watch_id, "_ack", action_id),
params=params,
headers=headers,
)
@query_params()
def activate_watch(self, watch_id, params=None):
def activate_watch(self, watch_id, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-activate-watch.html>`_
@@ -31,11 +32,14 @@ class WatcherClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'watch_id'.")
return self.transport.perform_request(
"PUT", _make_path("_watcher", "watch", watch_id, "_activate"), params=params
"PUT",
_make_path("_watcher", "watch", watch_id, "_activate"),
params=params,
headers=headers,
)
@query_params()
def deactivate_watch(self, watch_id, params=None):
def deactivate_watch(self, watch_id, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-deactivate-watch.html>`_
@@ -48,10 +52,11 @@ class WatcherClient(NamespacedClient):
"PUT",
_make_path("_watcher", "watch", watch_id, "_deactivate"),
params=params,
headers=headers,
)
@query_params()
def delete_watch(self, id, params=None):
def delete_watch(self, id, params=None, headers=None):
"""
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-delete-watch.html>`_
@@ -61,11 +66,14 @@ class WatcherClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'id'.")
return self.transport.perform_request(
"DELETE", _make_path("_watcher", "watch", id), params=params
"DELETE",
_make_path("_watcher", "watch", id),
params=params,
headers=headers,
)
@query_params("debug")
def execute_watch(self, body=None, id=None, params=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>`_
@@ -78,11 +86,12 @@ class WatcherClient(NamespacedClient):
"PUT",
_make_path("_watcher", "watch", id, "_execute"),
params=params,
headers=headers,
body=body,
)
@query_params()
def get_watch(self, id, params=None):
def get_watch(self, id, params=None, headers=None):
"""
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-get-watch.html>`_
@@ -92,11 +101,11 @@ class WatcherClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'id'.")
return self.transport.perform_request(
"GET", _make_path("_watcher", "watch", id), params=params
"GET", _make_path("_watcher", "watch", id), params=params, headers=headers
)
@query_params("active", "if_primary_term", "if_seq_no", "version")
def put_watch(self, id, body=None, params=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>`_
@@ -113,19 +122,25 @@ class WatcherClient(NamespacedClient):
raise ValueError("Empty value passed for a required argument 'id'.")
return self.transport.perform_request(
"PUT", _make_path("_watcher", "watch", id), params=params, body=body
"PUT",
_make_path("_watcher", "watch", id),
params=params,
headers=headers,
body=body,
)
@query_params()
def start(self, params=None):
def start(self, params=None, headers=None):
"""
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-start.html>`_
"""
return self.transport.perform_request("POST", "/_watcher/_start", params=params)
return self.transport.perform_request(
"POST", "/_watcher/_start", params=params, headers=headers
)
@query_params("emit_stacktraces")
def stats(self, metric=None, params=None):
def stats(self, metric=None, params=None, headers=None):
"""
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-stats.html>`_
@@ -139,13 +154,18 @@ class WatcherClient(NamespacedClient):
current_watches, pending_watches
"""
return self.transport.perform_request(
"GET", _make_path("_watcher", "stats", metric), params=params
"GET",
_make_path("_watcher", "stats", metric),
params=params,
headers=headers,
)
@query_params()
def stop(self, params=None):
def stop(self, params=None, headers=None):
"""
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-stop.html>`_
"""
return self.transport.perform_request("POST", "/_watcher/_stop", params=params)
return self.transport.perform_request(
"POST", "/_watcher/_stop", params=params, headers=headers
)
+8 -4
View File
@@ -7,20 +7,24 @@ class XPackClient(NamespacedClient):
# AUTO-GENERATED-API-DEFINITIONS #
@query_params("categories")
def info(self, params=None):
def info(self, params=None, headers=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/info-api.html>`_
:arg categories: Comma-separated list of info categories. Can be
any of: build, license, features
"""
return self.transport.perform_request("GET", "/_xpack", params=params)
return self.transport.perform_request(
"GET", "/_xpack", params=params, headers=headers
)
@query_params("master_timeout")
def usage(self, params=None):
def usage(self, params=None, headers=None):
"""
`<Retrieve information about xpack features usage>`_
:arg master_timeout: Specify timeout for watch write operation
"""
return self.transport.perform_request("GET", "/_xpack/usage", params=params)
return self.transport.perform_request(
"GET", "/_xpack/usage", params=params, headers=headers
)
+5
View File
@@ -37,6 +37,8 @@ class Connection(object):
:arg timeout: default timeout in seconds (float, default: 10)
:arg http_compress: Use gzip compression
:arg cloud_id: The Cloud ID from ElasticCloud. Convenient way to connect to cloud instances.
:arg opaque_id: Send this value in the 'X-Opaque-Id' HTTP header
For tracing all requests made by this transport.
"""
def __init__(
@@ -50,6 +52,7 @@ class Connection(object):
http_compress=None,
cloud_id=None,
api_key=None,
opaque_id=None,
**kwargs
):
@@ -78,6 +81,8 @@ class Connection(object):
headers = headers or {}
for key in headers:
self.headers[key.lower()] = headers[key]
if opaque_id:
self.headers["x-opaque-id"] = opaque_id
self.headers.setdefault("content-type", "application/json")
self.headers.setdefault("user-agent", self._get_default_user_agent())
@@ -38,6 +38,8 @@ class RequestsHttpConnection(Connection):
:arg cloud_id: The Cloud ID from ElasticCloud. Convenient way to connect to cloud instances.
Other host connection params will be ignored.
:arg api_key: optional API Key authentication as either base64 encoded string or a tuple.
:arg opaque_id: Send this value in the 'X-Opaque-Id' HTTP header
For tracing all requests made by this transport.
"""
def __init__(
@@ -55,6 +57,7 @@ class RequestsHttpConnection(Connection):
http_compress=None,
cloud_id=None,
api_key=None,
opaque_id=None,
**kwargs
):
if not REQUESTS_AVAILABLE:
@@ -75,6 +78,7 @@ class RequestsHttpConnection(Connection):
http_compress=http_compress,
cloud_id=cloud_id,
api_key=api_key,
opaque_id=opaque_id,
**kwargs
)
+4
View File
@@ -75,6 +75,8 @@ class Urllib3HttpConnection(Connection):
:arg cloud_id: The Cloud ID from ElasticCloud. Convenient way to connect to cloud instances.
Other host connection params will be ignored.
:arg api_key: optional API Key authentication as either base64 encoded string or a tuple.
:arg opaque_id: Send this value in the 'X-Opaque-Id' HTTP header
For tracing all requests made by this transport.
"""
def __init__(
@@ -97,6 +99,7 @@ class Urllib3HttpConnection(Connection):
http_compress=None,
cloud_id=None,
api_key=None,
opaque_id=None,
**kwargs
):
# Initialize headers before calling super().__init__().
@@ -110,6 +113,7 @@ class Urllib3HttpConnection(Connection):
http_compress=http_compress,
cloud_id=cloud_id,
api_key=api_key,
opaque_id=opaque_id,
**kwargs
)
if http_auth is not None:
+1
View File
@@ -342,6 +342,7 @@ class Transport(object):
ignore = params.pop("ignore", ())
if isinstance(ignore, int):
ignore = (ignore,)
for attempt in range(self.max_retries + 1):
connection = self.get_connection()
+5 -3
View File
@@ -11,12 +11,12 @@ class DummyTransport(object):
self.call_count = 0
self.calls = defaultdict(list)
def perform_request(self, method, url, params=None, body=None):
def perform_request(self, method, url, params=None, headers=None, body=None):
resp = 200, {}
if self.responses:
resp = self.responses[self.call_count]
self.call_count += 1
self.calls[(method, url)].append((params, body))
self.calls[(method, url)].append((params, headers, body))
return resp
@@ -46,4 +46,6 @@ class TestElasticsearchTestCase(ElasticsearchTestCase):
self.client.transport.perform_request("GET", "/")
self.client.transport.perform_request("DELETE", "/42", params={}, body="body")
self.assert_call_count_equals(2)
self.assertEquals([({}, "body")], self.assert_url_called("DELETE", "/42", 1))
self.assertEquals(
[({}, None, "body")], self.assert_url_called("DELETE", "/42", 1)
)
+16 -3
View File
@@ -52,7 +52,7 @@ class TestClient(ElasticsearchTestCase):
def test_request_timeout_is_passed_through_unescaped(self):
self.client.ping(request_timeout=0.1)
calls = self.assert_url_called("HEAD", "/")
self.assertEquals([({"request_timeout": 0.1}, None)], calls)
self.assertEquals([({"request_timeout": 0.1}, {}, None)], calls)
def test_params_is_copied_when(self):
rt = object()
@@ -61,14 +61,27 @@ class TestClient(ElasticsearchTestCase):
self.client.ping(params=params)
calls = self.assert_url_called("HEAD", "/", 2)
self.assertEquals(
[({"request_timeout": rt}, None), ({"request_timeout": rt}, None)], calls
[({"request_timeout": rt}, {}, None), ({"request_timeout": rt}, {}, None)],
calls,
)
self.assertFalse(calls[0][0] is calls[1][0])
def test_headers_is_copied_when(self):
hv = "value"
headers = dict(Authentication=hv)
self.client.ping(headers=headers)
self.client.ping(headers=headers)
calls = self.assert_url_called("HEAD", "/", 2)
self.assertEquals(
[({}, {"authentication": hv}, None), ({}, {"authentication": hv}, None)],
calls,
)
self.assertFalse(calls[0][0] is calls[1][0])
def test_from_in_search(self):
self.client.search(index="i", from_=10)
calls = self.assert_url_called("GET", "/i/_search")
self.assertEquals([({"from": "10"}, None)], calls)
self.assertEquals([({"from": "10"}, {}, None)], calls)
def test_repr_contains_hosts(self):
self.assertEquals("<Elasticsearch([{}])>", repr(self.client))
+37 -1
View File
@@ -1,12 +1,48 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from elasticsearch.client.utils import _make_path, _escape
from elasticsearch.client.utils import _make_path, _escape, query_params
from elasticsearch.compat import PY2
from ..test_cases import TestCase, SkipTest
class TestQueryParams(TestCase):
def setUp(self):
self.calls = []
@query_params("simple_param")
def func_to_wrap(self, *args, **kwargs):
self.calls.append((args, kwargs))
def test_handles_params(self):
self.func_to_wrap(params={"simple_param_2": "2"}, simple_param="3")
self.assertEqual(
self.calls,
[
(
(),
{
"params": {"simple_param": b"3", "simple_param_2": "2"},
"headers": {},
},
)
],
)
def test_handles_headers(self):
self.func_to_wrap(headers={"X-Opaque-Id": "app-1"})
self.assertEqual(
self.calls, [((), {"params": {}, "headers": {"x-opaque-id": "app-1"}})]
)
def test_handles_opaque_id(self):
self.func_to_wrap(opaque_id="request-id")
self.assertEqual(
self.calls, [((), {"params": {}, "headers": {"x-opaque-id": "request-id"}})]
)
class TestMakePath(TestCase):
def test_handles_unicode(self):
id = "中文"
+8
View File
@@ -55,6 +55,10 @@ class TestUrllib3Connection(TestCase):
self.assertIsInstance(con.pool.conn_kw["ssl_context"], ssl.SSLContext)
self.assertTrue(con.use_ssl)
def test_opaque_id(self):
con = Urllib3HttpConnection(opaque_id="app-1")
self.assertEqual(con.headers["x-opaque-id"], "app-1")
def test_http_cloud_id(self):
con = Urllib3HttpConnection(
cloud_id="foobar:ZXhhbXBsZS5jbG91ZC5jb20kMGZkNTBmNjIzMjBlZDY1MzlmNmNiNDhlMWI2OCRhYzUzOTVhODgz\nNDU2NmM5ZjE1Y2Q4ZTQ5MGE=\n"
@@ -317,6 +321,10 @@ class TestRequestsConnection(TestCase):
con = RequestsHttpConnection(timeout=42)
self.assertEquals(42, con.timeout)
def test_opaque_id(self):
con = RequestsHttpConnection(opaque_id="app-1")
self.assertEqual(con.headers["x-opaque-id"], "app-1")
def test_http_cloud_id(self):
con = RequestsHttpConnection(
cloud_id="foobar:ZXhhbXBsZS5jbG91ZC5jb20kMGZkNTBmNjIzMjBlZDY1MzlmNmNiNDhlMWI2OCRhYzUzOTVhODgz\nNDU2NmM5ZjE1Y2Q4ZTQ5MGE=\n"
@@ -164,13 +164,12 @@ class YamlTestCase(ElasticsearchTestCase):
def run_do(self, action):
""" Perform an api call with given parameters. """
api = self.client
if "headers" in action:
api = self._get_client(headers=action.pop("headers"))
headers = action.pop("headers", None)
catch = action.pop("catch", None)
self.assertEquals(1, len(action))
method, args = list(action.items())[0]
args["headers"] = headers
# locate api endpoint
for m in method.split("."):
+20
View File
@@ -111,6 +111,26 @@ class TestTransport(TestCase):
t.get_connection().calls[0][1],
)
def test_opaque_id(self):
t = Transport([{}], opaque_id="app-1", connection_class=DummyConnection)
t.perform_request("GET", "/")
self.assertEquals(1, len(t.get_connection().calls))
self.assertEquals(("GET", "/", None, None), t.get_connection().calls[0][0])
self.assertEquals(
{"timeout": None, "ignore": (), "headers": None},
t.get_connection().calls[0][1],
)
# Now try with an 'x-opaque-id' set on perform_request().
t.perform_request("GET", "/", headers={"x-opaque-id": "request-1"})
self.assertEquals(2, len(t.get_connection().calls))
self.assertEquals(("GET", "/", None, None), t.get_connection().calls[1][0])
self.assertEquals(
{"timeout": None, "ignore": (), "headers": {"x-opaque-id": "request-1"}},
t.get_connection().calls[1][1],
)
def test_request_with_custom_user_agent_header(self):
t = Transport([{}], connection_class=DummyConnection)
+1 -1
View File
@@ -24,6 +24,6 @@
body = _bulk_body(self.transport.serializer, body)
{% endif %}
{% block request %}
return self.transport.perform_request("{{ api.method }}", {% include "url" %}, params=params{% if api.body %}, body=body{% endif %})
return self.transport.perform_request("{{ api.method }}", {% include "url" %}, params=params, headers=headers{% if api.body %}, body=body{% endif %})
{% endblock %}
+2 -1
View File
@@ -10,4 +10,5 @@
{% if not info.required %}{{ p }}=None, {% endif %}
{% endfor %}
params=None
params=None,
headers=None
@@ -7,6 +7,6 @@
elif scroll_id:
params["scroll_id"] = scroll_id
return self.transport.perform_request("{{ api.method }}", "/_search/scroll", params=params, body=body)
return self.transport.perform_request("{{ api.method }}", "/_search/scroll", params=params, headers=headers, body=body)
{% endblock %}
+1 -1
View File
@@ -4,6 +4,6 @@
doc_type = "_doc"
return self.transport.perform_request("POST" if id in SKIP_IN_PATH else "PUT", {% include "url" %}, params=params, body=body)
return self.transport.perform_request("POST" if id in SKIP_IN_PATH else "PUT", {% include "url" %}, params=params, headers=headers, body=body)
{% endblock %}
+1 -1
View File
@@ -7,6 +7,6 @@
elif scroll_id:
params["scroll_id"] = scroll_id
return self.transport.perform_request("{{ api.method }}", "/_search/scroll", params=params, body=body)
return self.transport.perform_request("{{ api.method }}", "/_search/scroll", params=params, headers=headers, body=body)
{% endblock %}
+1 -1
View File
@@ -1,5 +1,5 @@
{% extends "base" %}
{% block request %}
return self.transport.perform_request("{{ api.method }}", "/_cluster/stats" if node_id in SKIP_IN_PATH else _make_path("_cluster", "stats", "nodes", node_id), params=params)
return self.transport.perform_request("{{ api.method }}", "/_cluster/stats" if node_id in SKIP_IN_PATH else _make_path("_cluster", "stats", "nodes", node_id), params=params, headers=headers)
{% endblock%}