[7.x] Update API generator for async
This commit is contained in:
committed by
Seth Michael Larson
parent
8ffae94912
commit
bed5ffc740
@@ -18,3 +18,4 @@ black; python_version>="3.6"
|
|||||||
# Requirements for testing [async] extra
|
# Requirements for testing [async] extra
|
||||||
aiohttp; python_version>="3.6"
|
aiohttp; python_version>="3.6"
|
||||||
pytest-asyncio; python_version>="3.6"
|
pytest-asyncio; python_version>="3.6"
|
||||||
|
unasync; python_version>="3.6"
|
||||||
|
|||||||
@@ -73,7 +73,8 @@ try:
|
|||||||
|
|
||||||
from ._async.http_aiohttp import AIOHttpConnection
|
from ._async.http_aiohttp import AIOHttpConnection
|
||||||
from ._async.transport import AsyncTransport
|
from ._async.transport import AsyncTransport
|
||||||
|
from ._async.client import AsyncElasticsearch
|
||||||
|
|
||||||
__all__ += ["AIOHttpConnection", "AsyncTransport"]
|
__all__ += ["AIOHttpConnection", "AsyncTransport", "AsyncElasticsearch"]
|
||||||
except (ImportError, SyntaxError):
|
except (ImportError, SyntaxError):
|
||||||
pass
|
pass
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,191 @@
|
|||||||
|
# Licensed to Elasticsearch B.V under one or more agreements.
|
||||||
|
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||||
|
# See the LICENSE file in the project root for more information
|
||||||
|
|
||||||
|
from .utils import NamespacedClient, SKIP_IN_PATH, query_params, _make_path
|
||||||
|
|
||||||
|
|
||||||
|
class AsyncSearchClient(NamespacedClient):
|
||||||
|
@query_params()
|
||||||
|
def delete(self, id, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Deletes an async search by ID. If the search is still running, the search
|
||||||
|
request will be cancelled. Otherwise, the saved search results are deleted.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/async-search.html>`_
|
||||||
|
|
||||||
|
:arg id: The async search ID
|
||||||
|
"""
|
||||||
|
if id in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'id'.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"DELETE", _make_path("_async_search", id), params=params, headers=headers
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("keep_alive", "typed_keys", "wait_for_completion_timeout")
|
||||||
|
def get(self, id, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Retrieves the results of a previously submitted async search request given its
|
||||||
|
ID.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/async-search.html>`_
|
||||||
|
|
||||||
|
:arg id: The async search ID
|
||||||
|
:arg keep_alive: Specify the time interval in which the results
|
||||||
|
(partial or final) for this search will be available
|
||||||
|
:arg typed_keys: Specify whether aggregation and suggester names
|
||||||
|
should be prefixed by their respective types in the response
|
||||||
|
:arg wait_for_completion_timeout: Specify the time that the
|
||||||
|
request should block waiting for the final response
|
||||||
|
"""
|
||||||
|
if id in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'id'.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET", _make_path("_async_search", id), params=params, headers=headers
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params(
|
||||||
|
"_source",
|
||||||
|
"_source_excludes",
|
||||||
|
"_source_includes",
|
||||||
|
"allow_no_indices",
|
||||||
|
"allow_partial_search_results",
|
||||||
|
"analyze_wildcard",
|
||||||
|
"analyzer",
|
||||||
|
"batched_reduce_size",
|
||||||
|
"default_operator",
|
||||||
|
"df",
|
||||||
|
"docvalue_fields",
|
||||||
|
"expand_wildcards",
|
||||||
|
"explain",
|
||||||
|
"from_",
|
||||||
|
"ignore_throttled",
|
||||||
|
"ignore_unavailable",
|
||||||
|
"keep_alive",
|
||||||
|
"keep_on_completion",
|
||||||
|
"lenient",
|
||||||
|
"max_concurrent_shard_requests",
|
||||||
|
"preference",
|
||||||
|
"q",
|
||||||
|
"request_cache",
|
||||||
|
"routing",
|
||||||
|
"search_type",
|
||||||
|
"seq_no_primary_term",
|
||||||
|
"size",
|
||||||
|
"sort",
|
||||||
|
"stats",
|
||||||
|
"stored_fields",
|
||||||
|
"suggest_field",
|
||||||
|
"suggest_mode",
|
||||||
|
"suggest_size",
|
||||||
|
"suggest_text",
|
||||||
|
"terminate_after",
|
||||||
|
"timeout",
|
||||||
|
"track_scores",
|
||||||
|
"track_total_hits",
|
||||||
|
"typed_keys",
|
||||||
|
"version",
|
||||||
|
"wait_for_completion_timeout",
|
||||||
|
)
|
||||||
|
def submit(self, body=None, index=None, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Executes a search request asynchronously.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/async-search.html>`_
|
||||||
|
|
||||||
|
:arg body: The search definition using the Query DSL
|
||||||
|
:arg index: A comma-separated list of index names to search; use
|
||||||
|
`_all` or empty string to perform the operation on all indices
|
||||||
|
:arg _source: True or false to return the _source field or not,
|
||||||
|
or a list of fields to return
|
||||||
|
:arg _source_excludes: A list of fields to exclude from the
|
||||||
|
returned _source field
|
||||||
|
:arg _source_includes: A list of fields to extract and return
|
||||||
|
from the _source field
|
||||||
|
:arg allow_no_indices: Whether to ignore if a wildcard indices
|
||||||
|
expression resolves into no concrete indices. (This includes `_all`
|
||||||
|
string or when no indices have been specified)
|
||||||
|
:arg allow_partial_search_results: Indicate if an error should
|
||||||
|
be returned if there is a partial search failure or timeout Default:
|
||||||
|
True
|
||||||
|
:arg analyze_wildcard: Specify whether wildcard and prefix
|
||||||
|
queries should be analyzed (default: false)
|
||||||
|
:arg analyzer: The analyzer to use for the query string
|
||||||
|
:arg batched_reduce_size: The number of shard results that
|
||||||
|
should be reduced at once on the coordinating node. This value should be
|
||||||
|
used as the granularity at which progress results will be made
|
||||||
|
available. Default: 5
|
||||||
|
:arg default_operator: The default operator for query string
|
||||||
|
query (AND or OR) Valid choices: AND, OR Default: OR
|
||||||
|
:arg df: The field to use as default where no field prefix is
|
||||||
|
given in the query string
|
||||||
|
:arg docvalue_fields: A comma-separated list of fields to return
|
||||||
|
as the docvalue representation of a field for each hit
|
||||||
|
:arg expand_wildcards: Whether to expand wildcard expression to
|
||||||
|
concrete indices that are open, closed or both. Valid choices: open,
|
||||||
|
closed, hidden, none, all Default: open
|
||||||
|
:arg explain: Specify whether to return detailed information
|
||||||
|
about score computation as part of a hit
|
||||||
|
:arg from\\_: Starting offset (default: 0)
|
||||||
|
:arg ignore_throttled: Whether specified concrete, expanded or
|
||||||
|
aliased indices should be ignored when throttled
|
||||||
|
:arg ignore_unavailable: Whether specified concrete indices
|
||||||
|
should be ignored when unavailable (missing or closed)
|
||||||
|
:arg keep_alive: Update the time interval in which the results
|
||||||
|
(partial or final) for this search will be available Default: 5d
|
||||||
|
:arg keep_on_completion: Control whether the response should be
|
||||||
|
stored in the cluster if it completed within the provided
|
||||||
|
[wait_for_completion] time (default: false)
|
||||||
|
:arg lenient: Specify whether format-based query failures (such
|
||||||
|
as providing text to a numeric field) should be ignored
|
||||||
|
:arg max_concurrent_shard_requests: The number of concurrent
|
||||||
|
shard requests per node this search executes concurrently. This value
|
||||||
|
should be used to limit the impact of the search on the cluster in order
|
||||||
|
to limit the number of concurrent shard requests Default: 5
|
||||||
|
:arg preference: Specify the node or shard the operation should
|
||||||
|
be performed on (default: random)
|
||||||
|
:arg q: Query in the Lucene query string syntax
|
||||||
|
:arg request_cache: Specify if request cache should be used for
|
||||||
|
this request or not, defaults to true
|
||||||
|
:arg routing: A comma-separated list of specific routing values
|
||||||
|
:arg search_type: Search operation type Valid choices:
|
||||||
|
query_then_fetch, dfs_query_then_fetch
|
||||||
|
:arg seq_no_primary_term: Specify whether to return sequence
|
||||||
|
number and primary term of the last modification of each hit
|
||||||
|
:arg size: Number of hits to return (default: 10)
|
||||||
|
:arg sort: A comma-separated list of <field>:<direction> pairs
|
||||||
|
:arg stats: Specific 'tag' of the request for logging and
|
||||||
|
statistical purposes
|
||||||
|
:arg stored_fields: A comma-separated list of stored fields to
|
||||||
|
return as part of a hit
|
||||||
|
:arg suggest_field: Specify which field to use for suggestions
|
||||||
|
:arg suggest_mode: Specify suggest mode Valid choices: missing,
|
||||||
|
popular, always Default: missing
|
||||||
|
:arg suggest_size: How many suggestions to return in response
|
||||||
|
:arg suggest_text: The source text for which the suggestions
|
||||||
|
should be returned
|
||||||
|
:arg terminate_after: The maximum number of documents to collect
|
||||||
|
for each shard, upon reaching which the query execution will terminate
|
||||||
|
early.
|
||||||
|
:arg timeout: Explicit operation timeout
|
||||||
|
:arg track_scores: Whether to calculate and return scores even
|
||||||
|
if they are not used for sorting
|
||||||
|
:arg track_total_hits: Indicate if the number of documents that
|
||||||
|
match the query should be tracked
|
||||||
|
:arg typed_keys: Specify whether aggregation and suggester names
|
||||||
|
should be prefixed by their respective types in the response
|
||||||
|
:arg version: Specify whether to return document version as part
|
||||||
|
of a hit
|
||||||
|
:arg wait_for_completion_timeout: Specify the time that the
|
||||||
|
request should block waiting for the final response Default: 1s
|
||||||
|
"""
|
||||||
|
# from is a reserved word so it cannot be used, use from_ instead
|
||||||
|
if "from_" in params:
|
||||||
|
params["from"] = params.pop("from_")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"POST",
|
||||||
|
_make_path(index, "_async_search"),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
body=body,
|
||||||
|
)
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
# Licensed to Elasticsearch B.V under one or more agreements.
|
||||||
|
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||||
|
# See the LICENSE file in the project root for more information
|
||||||
|
|
||||||
|
from .utils import NamespacedClient, query_params, SKIP_IN_PATH, _make_path
|
||||||
|
|
||||||
|
|
||||||
|
class AutoscalingClient(NamespacedClient):
|
||||||
|
@query_params()
|
||||||
|
def get_autoscaling_decision(self, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Gets the current autoscaling decision based on the configured autoscaling
|
||||||
|
policy, indicating whether or not autoscaling is needed.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/autoscaling-get-autoscaling-decision.html>`_
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET", "/_autoscaling/decision", params=params, headers=headers
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def delete_autoscaling_policy(self, name, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Deletes an autoscaling policy.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/autoscaling-delete-autoscaling-policy.html>`_
|
||||||
|
|
||||||
|
:arg name: the name of the autoscaling policy
|
||||||
|
"""
|
||||||
|
if name in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'name'.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"DELETE",
|
||||||
|
_make_path("_autoscaling", "policy", name),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def put_autoscaling_policy(self, name, body, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Creates a new autoscaling policy.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/autoscaling-put-autoscaling-policy.html>`_
|
||||||
|
|
||||||
|
:arg name: the name of the autoscaling policy
|
||||||
|
:arg body: the specification of the autoscaling policy
|
||||||
|
"""
|
||||||
|
for param in (name, body):
|
||||||
|
if param in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"PUT",
|
||||||
|
_make_path("_autoscaling", "policy", name),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
body=body,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def get_autoscaling_policy(self, name, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Retrieves an autoscaling policy.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/autoscaling-get-autoscaling-policy.html>`_
|
||||||
|
|
||||||
|
:arg name: the name of the autoscaling policy
|
||||||
|
"""
|
||||||
|
if name in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'name'.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET",
|
||||||
|
_make_path("_autoscaling", "policy", name),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
@@ -0,0 +1,713 @@
|
|||||||
|
# Licensed to Elasticsearch B.V under one or more agreements.
|
||||||
|
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||||
|
# See the LICENSE file in the project root for more information
|
||||||
|
|
||||||
|
from .utils import NamespacedClient, query_params, _make_path
|
||||||
|
|
||||||
|
|
||||||
|
class CatClient(NamespacedClient):
|
||||||
|
@query_params("expand_wildcards", "format", "h", "help", "local", "s", "v")
|
||||||
|
def aliases(self, name=None, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Shows information about currently configured aliases to indices including
|
||||||
|
filter and routing infos.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-alias.html>`_
|
||||||
|
|
||||||
|
:arg name: A comma-separated list of alias names to return
|
||||||
|
:arg expand_wildcards: Whether to expand wildcard expression to
|
||||||
|
concrete indices that are open, closed or both. Valid choices: open,
|
||||||
|
closed, hidden, none, all Default: all
|
||||||
|
:arg format: a short version of the Accept header, e.g. json,
|
||||||
|
yaml
|
||||||
|
:arg h: Comma-separated list of column names to display
|
||||||
|
:arg help: Return help information
|
||||||
|
:arg local: Return local information, do not retrieve the state
|
||||||
|
from master node (default: false)
|
||||||
|
:arg s: Comma-separated list of column names or column aliases
|
||||||
|
to sort by
|
||||||
|
:arg v: Verbose mode. Display column headers
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"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, headers=None):
|
||||||
|
"""
|
||||||
|
Provides a snapshot of how many shards are allocated to each data node and how
|
||||||
|
much disk space they are using.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-allocation.html>`_
|
||||||
|
|
||||||
|
:arg node_id: A comma-separated list of node IDs or names to
|
||||||
|
limit the returned information
|
||||||
|
:arg bytes: The unit in which to display byte values Valid
|
||||||
|
choices: b, k, kb, m, mb, g, gb, t, tb, p, pb
|
||||||
|
:arg format: a short version of the Accept header, e.g. json,
|
||||||
|
yaml
|
||||||
|
:arg h: Comma-separated list of column names to display
|
||||||
|
:arg help: Return help information
|
||||||
|
:arg local: Return local information, do not retrieve the state
|
||||||
|
from master node (default: false)
|
||||||
|
:arg master_timeout: Explicit operation timeout for connection
|
||||||
|
to master node
|
||||||
|
:arg s: Comma-separated list of column names or column aliases
|
||||||
|
to sort by
|
||||||
|
:arg v: Verbose mode. Display column headers
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"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, headers=None):
|
||||||
|
"""
|
||||||
|
Provides quick access to the document count of the entire cluster, or
|
||||||
|
individual indices.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-count.html>`_
|
||||||
|
|
||||||
|
:arg index: A comma-separated list of index names to limit the
|
||||||
|
returned information
|
||||||
|
:arg format: a short version of the Accept header, e.g. json,
|
||||||
|
yaml
|
||||||
|
:arg h: Comma-separated list of column names to display
|
||||||
|
:arg help: Return help information
|
||||||
|
:arg s: Comma-separated list of column names or column aliases
|
||||||
|
to sort by
|
||||||
|
:arg v: Verbose mode. Display column headers
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET", _make_path("_cat", "count", index), params=params, headers=headers
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("format", "h", "help", "s", "time", "ts", "v")
|
||||||
|
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>`_
|
||||||
|
|
||||||
|
:arg format: a short version of the Accept header, e.g. json,
|
||||||
|
yaml
|
||||||
|
:arg h: Comma-separated list of column names to display
|
||||||
|
:arg help: Return help information
|
||||||
|
:arg s: Comma-separated list of column names or column aliases
|
||||||
|
to sort by
|
||||||
|
:arg time: The unit in which to display time values Valid
|
||||||
|
choices: d, h, m, s, ms, micros, nanos
|
||||||
|
: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, headers=headers
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("help", "s")
|
||||||
|
def help(self, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Returns help for the Cat APIs.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/cat.html>`_
|
||||||
|
|
||||||
|
:arg help: Return help information
|
||||||
|
:arg s: Comma-separated list of column names or column aliases
|
||||||
|
to sort by
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET", "/_cat", params=params, headers=headers
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params(
|
||||||
|
"bytes",
|
||||||
|
"expand_wildcards",
|
||||||
|
"format",
|
||||||
|
"h",
|
||||||
|
"health",
|
||||||
|
"help",
|
||||||
|
"include_unloaded_segments",
|
||||||
|
"local",
|
||||||
|
"master_timeout",
|
||||||
|
"pri",
|
||||||
|
"s",
|
||||||
|
"time",
|
||||||
|
"v",
|
||||||
|
)
|
||||||
|
def indices(self, index=None, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Returns information about indices: number of primaries and replicas, document
|
||||||
|
counts, disk size, ...
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-indices.html>`_
|
||||||
|
|
||||||
|
:arg index: A comma-separated list of index names to limit the
|
||||||
|
returned information
|
||||||
|
:arg bytes: The unit in which to display byte values Valid
|
||||||
|
choices: b, k, kb, m, mb, g, gb, t, tb, p, pb
|
||||||
|
:arg expand_wildcards: Whether to expand wildcard expression to
|
||||||
|
concrete indices that are open, closed or both. Valid choices: open,
|
||||||
|
closed, hidden, none, all Default: all
|
||||||
|
:arg format: a short version of the Accept header, e.g. json,
|
||||||
|
yaml
|
||||||
|
:arg h: Comma-separated list of column names to display
|
||||||
|
:arg health: A health status ("green", "yellow", or "red" to
|
||||||
|
filter only indices matching the specified health status Valid choices:
|
||||||
|
green, yellow, red
|
||||||
|
:arg help: Return help information
|
||||||
|
:arg include_unloaded_segments: If set to true segment stats
|
||||||
|
will include stats for segments that are not currently loaded into
|
||||||
|
memory
|
||||||
|
:arg local: Return local information, do not retrieve the state
|
||||||
|
from master node (default: false)
|
||||||
|
:arg master_timeout: Explicit operation timeout for connection
|
||||||
|
to master node
|
||||||
|
:arg pri: Set to true to return stats only for primary shards
|
||||||
|
:arg s: Comma-separated list of column names or column aliases
|
||||||
|
to sort by
|
||||||
|
:arg time: The unit in which to display time values Valid
|
||||||
|
choices: d, h, m, s, ms, micros, nanos
|
||||||
|
:arg v: Verbose mode. Display column headers
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"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, headers=None):
|
||||||
|
"""
|
||||||
|
Returns information about the master node.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-master.html>`_
|
||||||
|
|
||||||
|
:arg format: a short version of the Accept header, e.g. json,
|
||||||
|
yaml
|
||||||
|
:arg h: Comma-separated list of column names to display
|
||||||
|
:arg help: Return help information
|
||||||
|
:arg local: Return local information, do not retrieve the state
|
||||||
|
from master node (default: false)
|
||||||
|
:arg master_timeout: Explicit operation timeout for connection
|
||||||
|
to master node
|
||||||
|
:arg s: Comma-separated list of column names or column aliases
|
||||||
|
to sort by
|
||||||
|
:arg v: Verbose mode. Display column headers
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET", "/_cat/master", params=params, headers=headers
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params(
|
||||||
|
"bytes", "format", "full_id", "h", "help", "master_timeout", "s", "time", "v"
|
||||||
|
)
|
||||||
|
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>`_
|
||||||
|
|
||||||
|
:arg bytes: The unit in which to display byte values Valid
|
||||||
|
choices: b, k, kb, m, mb, g, gb, t, tb, p, pb
|
||||||
|
:arg format: a short version of the Accept header, e.g. json,
|
||||||
|
yaml
|
||||||
|
:arg full_id: Return the full node ID instead of the shortened
|
||||||
|
version (default: false)
|
||||||
|
:arg h: Comma-separated list of column names to display
|
||||||
|
:arg help: Return help information
|
||||||
|
:arg master_timeout: Explicit operation timeout for connection
|
||||||
|
to master node
|
||||||
|
:arg s: Comma-separated list of column names or column aliases
|
||||||
|
to sort by
|
||||||
|
:arg time: The unit in which to display time values Valid
|
||||||
|
choices: d, h, m, s, ms, micros, nanos
|
||||||
|
:arg v: Verbose mode. Display column headers
|
||||||
|
"""
|
||||||
|
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, headers=None):
|
||||||
|
"""
|
||||||
|
Returns information about index shard recoveries, both on-going completed.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-recovery.html>`_
|
||||||
|
|
||||||
|
:arg index: Comma-separated list or wildcard expression of index
|
||||||
|
names to limit the returned information
|
||||||
|
:arg active_only: If `true`, the response only includes ongoing
|
||||||
|
shard recoveries
|
||||||
|
:arg bytes: The unit in which to display byte values Valid
|
||||||
|
choices: b, k, kb, m, mb, g, gb, t, tb, p, pb
|
||||||
|
:arg detailed: If `true`, the response includes detailed
|
||||||
|
information about shard recoveries
|
||||||
|
:arg format: a short version of the Accept header, e.g. json,
|
||||||
|
yaml
|
||||||
|
:arg h: Comma-separated list of column names to display
|
||||||
|
:arg help: Return help information
|
||||||
|
:arg s: Comma-separated list of column names or column aliases
|
||||||
|
to sort by
|
||||||
|
:arg time: The unit in which to display time values Valid
|
||||||
|
choices: d, h, m, s, ms, micros, nanos
|
||||||
|
:arg v: Verbose mode. Display column headers
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"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, headers=None):
|
||||||
|
"""
|
||||||
|
Provides a detailed view of shard allocation on nodes.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-shards.html>`_
|
||||||
|
|
||||||
|
:arg index: A comma-separated list of index names to limit the
|
||||||
|
returned information
|
||||||
|
:arg bytes: The unit in which to display byte values Valid
|
||||||
|
choices: b, k, kb, m, mb, g, gb, t, tb, p, pb
|
||||||
|
:arg format: a short version of the Accept header, e.g. json,
|
||||||
|
yaml
|
||||||
|
:arg h: Comma-separated list of column names to display
|
||||||
|
:arg help: Return help information
|
||||||
|
:arg local: Return local information, do not retrieve the state
|
||||||
|
from master node (default: false)
|
||||||
|
:arg master_timeout: Explicit operation timeout for connection
|
||||||
|
to master node
|
||||||
|
:arg s: Comma-separated list of column names or column aliases
|
||||||
|
to sort by
|
||||||
|
:arg time: The unit in which to display time values Valid
|
||||||
|
choices: d, h, m, s, ms, micros, nanos
|
||||||
|
:arg v: Verbose mode. Display column headers
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"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, 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>`_
|
||||||
|
|
||||||
|
:arg index: A comma-separated list of index names to limit the
|
||||||
|
returned information
|
||||||
|
:arg bytes: The unit in which to display byte values Valid
|
||||||
|
choices: b, k, kb, m, mb, g, gb, t, tb, p, pb
|
||||||
|
:arg format: a short version of the Accept header, e.g. json,
|
||||||
|
yaml
|
||||||
|
:arg h: Comma-separated list of column names to display
|
||||||
|
:arg help: Return help information
|
||||||
|
:arg s: Comma-separated list of column names or column aliases
|
||||||
|
to sort by
|
||||||
|
:arg v: Verbose mode. Display column headers
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"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, headers=None):
|
||||||
|
"""
|
||||||
|
Returns a concise representation of the cluster pending tasks.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-pending-tasks.html>`_
|
||||||
|
|
||||||
|
:arg format: a short version of the Accept header, e.g. json,
|
||||||
|
yaml
|
||||||
|
:arg h: Comma-separated list of column names to display
|
||||||
|
:arg help: Return help information
|
||||||
|
:arg local: Return local information, do not retrieve the state
|
||||||
|
from master node (default: false)
|
||||||
|
:arg master_timeout: Explicit operation timeout for connection
|
||||||
|
to master node
|
||||||
|
:arg s: Comma-separated list of column names or column aliases
|
||||||
|
to sort by
|
||||||
|
:arg time: The unit in which to display time values Valid
|
||||||
|
choices: d, h, m, s, ms, micros, nanos
|
||||||
|
:arg v: Verbose mode. Display column headers
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET", "/_cat/pending_tasks", params=params, headers=headers
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("format", "h", "help", "local", "master_timeout", "s", "time", "v")
|
||||||
|
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.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-thread-pool.html>`_
|
||||||
|
|
||||||
|
:arg thread_pool_patterns: A comma-separated list of regular-
|
||||||
|
expressions to filter the thread pools in the output
|
||||||
|
:arg format: a short version of the Accept header, e.g. json,
|
||||||
|
yaml
|
||||||
|
:arg h: Comma-separated list of column names to display
|
||||||
|
:arg help: Return help information
|
||||||
|
:arg local: Return local information, do not retrieve the state
|
||||||
|
from master node (default: false)
|
||||||
|
:arg master_timeout: Explicit operation timeout for connection
|
||||||
|
to master node
|
||||||
|
:arg s: Comma-separated list of column names or column aliases
|
||||||
|
to sort by
|
||||||
|
:arg time: The unit in which to display time values Valid
|
||||||
|
choices: d, h, m, s, ms, micros, nanos
|
||||||
|
:arg v: Verbose mode. Display column headers
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"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, headers=None):
|
||||||
|
"""
|
||||||
|
Shows how much heap memory is currently being used by fielddata on every data
|
||||||
|
node in the cluster.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-fielddata.html>`_
|
||||||
|
|
||||||
|
:arg fields: A comma-separated list of fields to return in the
|
||||||
|
output
|
||||||
|
:arg bytes: The unit in which to display byte values Valid
|
||||||
|
choices: b, k, kb, m, mb, g, gb, t, tb, p, pb
|
||||||
|
:arg format: a short version of the Accept header, e.g. json,
|
||||||
|
yaml
|
||||||
|
:arg h: Comma-separated list of column names to display
|
||||||
|
:arg help: Return help information
|
||||||
|
:arg s: Comma-separated list of column names or column aliases
|
||||||
|
to sort by
|
||||||
|
:arg v: Verbose mode. Display column headers
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"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, headers=None):
|
||||||
|
"""
|
||||||
|
Returns information about installed plugins across nodes node.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-plugins.html>`_
|
||||||
|
|
||||||
|
:arg format: a short version of the Accept header, e.g. json,
|
||||||
|
yaml
|
||||||
|
:arg h: Comma-separated list of column names to display
|
||||||
|
:arg help: Return help information
|
||||||
|
:arg local: Return local information, do not retrieve the state
|
||||||
|
from master node (default: false)
|
||||||
|
:arg master_timeout: Explicit operation timeout for connection
|
||||||
|
to master node
|
||||||
|
:arg s: Comma-separated list of column names or column aliases
|
||||||
|
to sort by
|
||||||
|
:arg v: Verbose mode. Display column headers
|
||||||
|
"""
|
||||||
|
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, headers=None):
|
||||||
|
"""
|
||||||
|
Returns information about custom node attributes.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-nodeattrs.html>`_
|
||||||
|
|
||||||
|
:arg format: a short version of the Accept header, e.g. json,
|
||||||
|
yaml
|
||||||
|
:arg h: Comma-separated list of column names to display
|
||||||
|
:arg help: Return help information
|
||||||
|
:arg local: Return local information, do not retrieve the state
|
||||||
|
from master node (default: false)
|
||||||
|
:arg master_timeout: Explicit operation timeout for connection
|
||||||
|
to master node
|
||||||
|
:arg s: Comma-separated list of column names or column aliases
|
||||||
|
to sort by
|
||||||
|
:arg v: Verbose mode. Display column headers
|
||||||
|
"""
|
||||||
|
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, headers=None):
|
||||||
|
"""
|
||||||
|
Returns information about snapshot repositories registered in the cluster.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-repositories.html>`_
|
||||||
|
|
||||||
|
:arg format: a short version of the Accept header, e.g. json,
|
||||||
|
yaml
|
||||||
|
:arg h: Comma-separated list of column names to display
|
||||||
|
:arg help: Return help information
|
||||||
|
:arg local: Return local information, do not retrieve the state
|
||||||
|
from master node
|
||||||
|
:arg master_timeout: Explicit operation timeout for connection
|
||||||
|
to master node
|
||||||
|
:arg s: Comma-separated list of column names or column aliases
|
||||||
|
to sort by
|
||||||
|
:arg v: Verbose mode. Display column headers
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"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, headers=None):
|
||||||
|
"""
|
||||||
|
Returns all snapshots in a specific repository.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-snapshots.html>`_
|
||||||
|
|
||||||
|
:arg repository: Name of repository from which to fetch the
|
||||||
|
snapshot information
|
||||||
|
:arg format: a short version of the Accept header, e.g. json,
|
||||||
|
yaml
|
||||||
|
:arg h: Comma-separated list of column names to display
|
||||||
|
:arg help: Return help information
|
||||||
|
:arg ignore_unavailable: Set to true to ignore unavailable
|
||||||
|
snapshots
|
||||||
|
:arg master_timeout: Explicit operation timeout for connection
|
||||||
|
to master node
|
||||||
|
:arg s: Comma-separated list of column names or column aliases
|
||||||
|
to sort by
|
||||||
|
:arg time: The unit in which to display time values Valid
|
||||||
|
choices: d, h, m, s, ms, micros, nanos
|
||||||
|
:arg v: Verbose mode. Display column headers
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET",
|
||||||
|
_make_path("_cat", "snapshots", repository),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params(
|
||||||
|
"actions",
|
||||||
|
"detailed",
|
||||||
|
"format",
|
||||||
|
"h",
|
||||||
|
"help",
|
||||||
|
"node_id",
|
||||||
|
"parent_task",
|
||||||
|
"s",
|
||||||
|
"time",
|
||||||
|
"v",
|
||||||
|
)
|
||||||
|
def tasks(self, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Returns information about the tasks currently executing on one or more nodes in
|
||||||
|
the cluster.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html>`_
|
||||||
|
|
||||||
|
:arg actions: A comma-separated list of actions that should be
|
||||||
|
returned. Leave empty to return all.
|
||||||
|
:arg detailed: Return detailed task information (default: false)
|
||||||
|
:arg format: a short version of the Accept header, e.g. json,
|
||||||
|
yaml
|
||||||
|
:arg h: Comma-separated list of column names to display
|
||||||
|
:arg help: Return help information
|
||||||
|
:arg node_id: A comma-separated list of node IDs or names to
|
||||||
|
limit the returned information; use `_local` to return information from
|
||||||
|
the node you're connecting to, leave empty to get information from all
|
||||||
|
nodes
|
||||||
|
:arg parent_task: Return tasks with specified parent task id.
|
||||||
|
Set to -1 to return all.
|
||||||
|
:arg s: Comma-separated list of column names or column aliases
|
||||||
|
to sort by
|
||||||
|
:arg time: The unit in which to display time values Valid
|
||||||
|
choices: d, h, m, s, ms, micros, nanos
|
||||||
|
:arg v: Verbose mode. Display column headers
|
||||||
|
"""
|
||||||
|
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, headers=None):
|
||||||
|
"""
|
||||||
|
Returns information about existing templates.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-templates.html>`_
|
||||||
|
|
||||||
|
:arg name: A pattern that returned template names must match
|
||||||
|
:arg format: a short version of the Accept header, e.g. json,
|
||||||
|
yaml
|
||||||
|
:arg h: Comma-separated list of column names to display
|
||||||
|
:arg help: Return help information
|
||||||
|
:arg local: Return local information, do not retrieve the state
|
||||||
|
from master node (default: false)
|
||||||
|
:arg master_timeout: Explicit operation timeout for connection
|
||||||
|
to master node
|
||||||
|
:arg s: Comma-separated list of column names or column aliases
|
||||||
|
to sort by
|
||||||
|
:arg v: Verbose mode. Display column headers
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET", _make_path("_cat", "templates", name), params=params, headers=headers
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("allow_no_match", "bytes", "format", "h", "help", "s", "time", "v")
|
||||||
|
def ml_data_frame_analytics(self, id=None, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Gets configuration and usage information about data frame analytics jobs.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-dfanalytics.html>`_
|
||||||
|
|
||||||
|
:arg id: The ID of the data frame analytics to fetch
|
||||||
|
:arg allow_no_match: Whether to ignore if a wildcard expression
|
||||||
|
matches no configs. (This includes `_all` string or when no configs have
|
||||||
|
been specified)
|
||||||
|
:arg bytes: The unit in which to display byte values Valid
|
||||||
|
choices: b, k, kb, m, mb, g, gb, t, tb, p, pb
|
||||||
|
:arg format: a short version of the Accept header, e.g. json,
|
||||||
|
yaml
|
||||||
|
:arg h: Comma-separated list of column names to display
|
||||||
|
:arg help: Return help information
|
||||||
|
:arg s: Comma-separated list of column names or column aliases
|
||||||
|
to sort by
|
||||||
|
:arg time: The unit in which to display time values Valid
|
||||||
|
choices: d, h, m, s, ms, micros, nanos
|
||||||
|
:arg v: Verbose mode. Display column headers
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET",
|
||||||
|
_make_path("_cat", "ml", "data_frame", "analytics", id),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("allow_no_datafeeds", "format", "h", "help", "s", "time", "v")
|
||||||
|
def ml_datafeeds(self, datafeed_id=None, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Gets configuration and usage information about datafeeds.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-datafeeds.html>`_
|
||||||
|
|
||||||
|
:arg datafeed_id: The ID of the datafeeds stats to fetch
|
||||||
|
:arg allow_no_datafeeds: Whether to ignore if a wildcard
|
||||||
|
expression matches no datafeeds. (This includes `_all` string or when no
|
||||||
|
datafeeds have been specified)
|
||||||
|
:arg format: a short version of the Accept header, e.g. json,
|
||||||
|
yaml
|
||||||
|
:arg h: Comma-separated list of column names to display
|
||||||
|
:arg help: Return help information
|
||||||
|
:arg s: Comma-separated list of column names or column aliases
|
||||||
|
to sort by
|
||||||
|
:arg time: The unit in which to display time values Valid
|
||||||
|
choices: d, h, m, s, ms, micros, nanos
|
||||||
|
:arg v: Verbose mode. Display column headers
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET",
|
||||||
|
_make_path("_cat", "ml", "datafeeds", datafeed_id),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("allow_no_jobs", "bytes", "format", "h", "help", "s", "time", "v")
|
||||||
|
def ml_jobs(self, job_id=None, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Gets configuration and usage information about anomaly detection jobs.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-anomaly-detectors.html>`_
|
||||||
|
|
||||||
|
:arg job_id: The ID of the jobs stats to fetch
|
||||||
|
:arg allow_no_jobs: Whether to ignore if a wildcard expression
|
||||||
|
matches no jobs. (This includes `_all` string or when no jobs have been
|
||||||
|
specified)
|
||||||
|
:arg bytes: The unit in which to display byte values Valid
|
||||||
|
choices: b, k, kb, m, mb, g, gb, t, tb, p, pb
|
||||||
|
:arg format: a short version of the Accept header, e.g. json,
|
||||||
|
yaml
|
||||||
|
:arg h: Comma-separated list of column names to display
|
||||||
|
:arg help: Return help information
|
||||||
|
:arg s: Comma-separated list of column names or column aliases
|
||||||
|
to sort by
|
||||||
|
:arg time: The unit in which to display time values Valid
|
||||||
|
choices: d, h, m, s, ms, micros, nanos
|
||||||
|
:arg v: Verbose mode. Display column headers
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET",
|
||||||
|
_make_path("_cat", "ml", "anomaly_detectors", job_id),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params(
|
||||||
|
"allow_no_match",
|
||||||
|
"bytes",
|
||||||
|
"format",
|
||||||
|
"from_",
|
||||||
|
"h",
|
||||||
|
"help",
|
||||||
|
"s",
|
||||||
|
"size",
|
||||||
|
"time",
|
||||||
|
"v",
|
||||||
|
)
|
||||||
|
def ml_trained_models(self, model_id=None, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Gets configuration and usage information about inference trained models.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-trained-model.html>`_
|
||||||
|
|
||||||
|
:arg model_id: The ID of the trained models stats to fetch
|
||||||
|
:arg allow_no_match: Whether to ignore if a wildcard expression
|
||||||
|
matches no trained models. (This includes `_all` string or when no
|
||||||
|
trained models have been specified) Default: True
|
||||||
|
:arg bytes: The unit in which to display byte values Valid
|
||||||
|
choices: b, k, kb, m, mb, g, gb, t, tb, p, pb
|
||||||
|
:arg format: a short version of the Accept header, e.g. json,
|
||||||
|
yaml
|
||||||
|
:arg from\\_: skips a number of trained models
|
||||||
|
:arg h: Comma-separated list of column names to display
|
||||||
|
:arg help: Return help information
|
||||||
|
:arg s: Comma-separated list of column names or column aliases
|
||||||
|
to sort by
|
||||||
|
:arg size: specifies a max number of trained models to get
|
||||||
|
Default: 100
|
||||||
|
:arg time: The unit in which to display time values Valid
|
||||||
|
choices: d, h, m, s, ms, micros, nanos
|
||||||
|
:arg v: Verbose mode. Display column headers
|
||||||
|
"""
|
||||||
|
# from is a reserved word so it cannot be used, use from_ instead
|
||||||
|
if "from_" in params:
|
||||||
|
params["from"] = params.pop("from_")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET",
|
||||||
|
_make_path("_cat", "ml", "trained_models", model_id),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params(
|
||||||
|
"allow_no_match", "format", "from_", "h", "help", "s", "size", "time", "v"
|
||||||
|
)
|
||||||
|
def transforms(self, transform_id=None, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Gets configuration and usage information about transforms.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-transforms.html>`_
|
||||||
|
|
||||||
|
:arg transform_id: The id of the transform for which to get
|
||||||
|
stats. '_all' or '*' implies all transforms
|
||||||
|
:arg allow_no_match: Whether to ignore if a wildcard expression
|
||||||
|
matches no transforms. (This includes `_all` string or when no
|
||||||
|
transforms have been specified)
|
||||||
|
:arg format: a short version of the Accept header, e.g. json,
|
||||||
|
yaml
|
||||||
|
:arg from\\_: skips a number of transform configs, defaults to 0
|
||||||
|
:arg h: Comma-separated list of column names to display
|
||||||
|
:arg help: Return help information
|
||||||
|
:arg s: Comma-separated list of column names or column aliases
|
||||||
|
to sort by
|
||||||
|
:arg size: specifies a max number of transforms to get, defaults
|
||||||
|
to 100
|
||||||
|
:arg time: The unit in which to display time values Valid
|
||||||
|
choices: d, h, m, s, ms, micros, nanos
|
||||||
|
:arg v: Verbose mode. Display column headers
|
||||||
|
"""
|
||||||
|
# from is a reserved word so it cannot be used, use from_ instead
|
||||||
|
if "from_" in params:
|
||||||
|
params["from"] = params.pop("from_")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET",
|
||||||
|
_make_path("_cat", "transforms", transform_id),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
@@ -0,0 +1,259 @@
|
|||||||
|
# Licensed to Elasticsearch B.V under one or more agreements.
|
||||||
|
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||||
|
# See the LICENSE file in the project root for more information
|
||||||
|
|
||||||
|
from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH
|
||||||
|
|
||||||
|
|
||||||
|
class CcrClient(NamespacedClient):
|
||||||
|
@query_params()
|
||||||
|
def delete_auto_follow_pattern(self, name, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Deletes auto-follow patterns.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/ccr-delete-auto-follow-pattern.html>`_
|
||||||
|
|
||||||
|
:arg name: The name of the auto follow pattern.
|
||||||
|
"""
|
||||||
|
if name in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'name'.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"DELETE",
|
||||||
|
_make_path("_ccr", "auto_follow", name),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("wait_for_active_shards")
|
||||||
|
def follow(self, index, body, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Creates a new follower index configured to follow the referenced leader index.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/ccr-put-follow.html>`_
|
||||||
|
|
||||||
|
:arg index: The name of the follower index
|
||||||
|
:arg body: The name of the leader index and other optional ccr
|
||||||
|
related parameters
|
||||||
|
:arg wait_for_active_shards: Sets the number of shard copies
|
||||||
|
that must be active before returning. Defaults to 0. Set to `all` for
|
||||||
|
all shard copies, otherwise set to any non-negative value less than or
|
||||||
|
equal to the total number of copies for the shard (number of replicas +
|
||||||
|
1) Default: 0
|
||||||
|
"""
|
||||||
|
for param in (index, body):
|
||||||
|
if param in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"PUT",
|
||||||
|
_make_path(index, "_ccr", "follow"),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
body=body,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def follow_info(self, index, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Retrieves information about all follower indices, including parameters and
|
||||||
|
status for each follower index
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/ccr-get-follow-info.html>`_
|
||||||
|
|
||||||
|
:arg index: A comma-separated list of index patterns; use `_all`
|
||||||
|
to perform the operation on all indices
|
||||||
|
"""
|
||||||
|
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, "_ccr", "info"), params=params, headers=headers
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def follow_stats(self, index, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Retrieves follower stats. return shard-level stats about the following tasks
|
||||||
|
associated with each shard for the specified indices.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/ccr-get-follow-stats.html>`_
|
||||||
|
|
||||||
|
:arg index: A comma-separated list of index patterns; use `_all`
|
||||||
|
to perform the operation on all indices
|
||||||
|
"""
|
||||||
|
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, "_ccr", "stats"), params=params, headers=headers
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def forget_follower(self, index, body, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Removes the follower retention leases from the leader.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/ccr-post-forget-follower.html>`_
|
||||||
|
|
||||||
|
:arg index: the name of the leader index for which specified
|
||||||
|
follower retention leases should be removed
|
||||||
|
:arg body: the name and UUID of the follower index, the name of
|
||||||
|
the cluster containing the follower index, and the alias from the
|
||||||
|
perspective of that cluster for the remote cluster containing the leader
|
||||||
|
index
|
||||||
|
"""
|
||||||
|
for param in (index, body):
|
||||||
|
if param in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"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, headers=None):
|
||||||
|
"""
|
||||||
|
Gets configured auto-follow patterns. Returns the specified auto-follow pattern
|
||||||
|
collection.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/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,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def pause_follow(self, index, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Pauses a follower index. The follower index will not fetch any additional
|
||||||
|
operations from the leader index.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/ccr-post-pause-follow.html>`_
|
||||||
|
|
||||||
|
:arg index: The name of the follower index that should pause
|
||||||
|
following its leader index.
|
||||||
|
"""
|
||||||
|
if index in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'index'.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"POST",
|
||||||
|
_make_path(index, "_ccr", "pause_follow"),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def put_auto_follow_pattern(self, name, body, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Creates a new named collection of auto-follow patterns against a specified
|
||||||
|
remote cluster. Newly created indices on the remote cluster matching any of the
|
||||||
|
specified patterns will be automatically configured as follower indices.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/ccr-put-auto-follow-pattern.html>`_
|
||||||
|
|
||||||
|
:arg name: The name of the auto follow pattern.
|
||||||
|
:arg body: The specification of the auto follow pattern
|
||||||
|
"""
|
||||||
|
for param in (name, body):
|
||||||
|
if param in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"PUT",
|
||||||
|
_make_path("_ccr", "auto_follow", name),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
body=body,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def resume_follow(self, index, body=None, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Resumes a follower index that has been paused
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/ccr-post-resume-follow.html>`_
|
||||||
|
|
||||||
|
:arg index: The name of the follow index to resume following.
|
||||||
|
:arg body: The name of the leader index and other optional ccr
|
||||||
|
related parameters
|
||||||
|
"""
|
||||||
|
if index in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'index'.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"POST",
|
||||||
|
_make_path(index, "_ccr", "resume_follow"),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
body=body,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def stats(self, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Gets all stats related to cross-cluster replication.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/ccr-get-stats.html>`_
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET", "/_ccr/stats", params=params, headers=headers
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def unfollow(self, index, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Stops the following task associated with a follower index and removes index
|
||||||
|
metadata and settings associated with cross-cluster replication.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/ccr-post-unfollow.html>`_
|
||||||
|
|
||||||
|
:arg index: The name of the follower index that should be turned
|
||||||
|
into a regular index.
|
||||||
|
"""
|
||||||
|
if index in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'index'.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"POST",
|
||||||
|
_make_path(index, "_ccr", "unfollow"),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def pause_auto_follow_pattern(self, name, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Pauses an auto-follow pattern
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/ccr-pause-auto-follow-pattern.html>`_
|
||||||
|
|
||||||
|
:arg name: The name of the auto follow pattern that should pause
|
||||||
|
discovering new indices to follow.
|
||||||
|
"""
|
||||||
|
if name in SKIP_IN_PATH:
|
||||||
|
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,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def resume_auto_follow_pattern(self, name, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Resumes an auto-follow pattern that has been paused
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/ccr-resume-auto-follow-pattern.html>`_
|
||||||
|
|
||||||
|
:arg name: The name of the auto follow pattern to resume
|
||||||
|
discovering new indices to follow.
|
||||||
|
"""
|
||||||
|
if name in SKIP_IN_PATH:
|
||||||
|
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,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
@@ -0,0 +1,361 @@
|
|||||||
|
# Licensed to Elasticsearch B.V under one or more agreements.
|
||||||
|
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||||
|
# See the LICENSE file in the project root for more information
|
||||||
|
|
||||||
|
from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH
|
||||||
|
|
||||||
|
|
||||||
|
class ClusterClient(NamespacedClient):
|
||||||
|
@query_params(
|
||||||
|
"expand_wildcards",
|
||||||
|
"level",
|
||||||
|
"local",
|
||||||
|
"master_timeout",
|
||||||
|
"timeout",
|
||||||
|
"wait_for_active_shards",
|
||||||
|
"wait_for_events",
|
||||||
|
"wait_for_no_initializing_shards",
|
||||||
|
"wait_for_no_relocating_shards",
|
||||||
|
"wait_for_nodes",
|
||||||
|
"wait_for_status",
|
||||||
|
)
|
||||||
|
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>`_
|
||||||
|
|
||||||
|
:arg index: Limit the information returned to a specific index
|
||||||
|
:arg expand_wildcards: Whether to expand wildcard expression to
|
||||||
|
concrete indices that are open, closed or both. Valid choices: open,
|
||||||
|
closed, hidden, none, all Default: all
|
||||||
|
:arg level: Specify the level of detail for returned information
|
||||||
|
Valid choices: cluster, indices, shards Default: cluster
|
||||||
|
:arg local: Return local information, do not retrieve the state
|
||||||
|
from master node (default: false)
|
||||||
|
:arg master_timeout: Explicit operation timeout for connection
|
||||||
|
to master node
|
||||||
|
:arg timeout: Explicit operation timeout
|
||||||
|
:arg wait_for_active_shards: Wait until the specified number of
|
||||||
|
shards is active
|
||||||
|
:arg wait_for_events: Wait until all currently queued events
|
||||||
|
with the given priority are processed Valid choices: immediate, urgent,
|
||||||
|
high, normal, low, languid
|
||||||
|
:arg wait_for_no_initializing_shards: Whether to wait until
|
||||||
|
there are no initializing shards in the cluster
|
||||||
|
:arg wait_for_no_relocating_shards: Whether to wait until there
|
||||||
|
are no relocating shards in the cluster
|
||||||
|
:arg wait_for_nodes: Wait until the specified number of nodes is
|
||||||
|
available
|
||||||
|
:arg wait_for_status: Wait until cluster is in a specific state
|
||||||
|
Valid choices: green, yellow, red
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET",
|
||||||
|
_make_path("_cluster", "health", index),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("local", "master_timeout")
|
||||||
|
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.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-pending.html>`_
|
||||||
|
|
||||||
|
:arg local: Return local information, do not retrieve the state
|
||||||
|
from master node (default: false)
|
||||||
|
:arg master_timeout: Specify timeout for connection to master
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET", "/_cluster/pending_tasks", params=params, headers=headers
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params(
|
||||||
|
"allow_no_indices",
|
||||||
|
"expand_wildcards",
|
||||||
|
"flat_settings",
|
||||||
|
"ignore_unavailable",
|
||||||
|
"local",
|
||||||
|
"master_timeout",
|
||||||
|
"wait_for_metadata_version",
|
||||||
|
"wait_for_timeout",
|
||||||
|
)
|
||||||
|
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>`_
|
||||||
|
|
||||||
|
:arg metric: Limit the information returned to the specified
|
||||||
|
metrics Valid choices: _all, blocks, metadata, nodes, routing_table,
|
||||||
|
routing_nodes, master_node, version
|
||||||
|
:arg index: A comma-separated list of index names; use `_all` or
|
||||||
|
empty string to perform the operation on all indices
|
||||||
|
:arg allow_no_indices: Whether to ignore if a wildcard indices
|
||||||
|
expression resolves into no concrete indices. (This includes `_all`
|
||||||
|
string or when no indices have been specified)
|
||||||
|
:arg expand_wildcards: Whether to expand wildcard expression to
|
||||||
|
concrete indices that are open, closed or both. Valid choices: open,
|
||||||
|
closed, hidden, none, all Default: open
|
||||||
|
:arg flat_settings: Return settings in flat format (default:
|
||||||
|
false)
|
||||||
|
:arg ignore_unavailable: Whether specified concrete indices
|
||||||
|
should be ignored when unavailable (missing or closed)
|
||||||
|
:arg local: Return local information, do not retrieve the state
|
||||||
|
from master node (default: false)
|
||||||
|
:arg master_timeout: Specify timeout for connection to master
|
||||||
|
:arg wait_for_metadata_version: Wait for the metadata version to
|
||||||
|
be equal or greater than the specified metadata version
|
||||||
|
:arg wait_for_timeout: The maximum time to wait for
|
||||||
|
wait_for_metadata_version before timing out
|
||||||
|
"""
|
||||||
|
if index and metric in SKIP_IN_PATH:
|
||||||
|
metric = "_all"
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET",
|
||||||
|
_make_path("_cluster", "state", metric, index),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("flat_settings", "timeout")
|
||||||
|
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>`_
|
||||||
|
|
||||||
|
:arg node_id: A comma-separated list of node IDs or names to
|
||||||
|
limit the returned information; use `_local` to return information from
|
||||||
|
the node you're connecting to, leave empty to get information from all
|
||||||
|
nodes
|
||||||
|
:arg flat_settings: Return settings in flat format (default:
|
||||||
|
false)
|
||||||
|
:arg timeout: Explicit operation timeout
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET",
|
||||||
|
"/_cluster/stats"
|
||||||
|
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, 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>`_
|
||||||
|
|
||||||
|
:arg body: The definition of `commands` to perform (`move`,
|
||||||
|
`cancel`, `allocate`)
|
||||||
|
:arg dry_run: Simulate the operation only and return the
|
||||||
|
resulting state
|
||||||
|
:arg explain: Return an explanation of why the commands can or
|
||||||
|
cannot be executed
|
||||||
|
:arg master_timeout: Explicit operation timeout for connection
|
||||||
|
to master node
|
||||||
|
:arg metric: Limit the information returned to the specified
|
||||||
|
metrics. Defaults to all but metadata Valid choices: _all, blocks,
|
||||||
|
metadata, nodes, routing_table, master_node, version
|
||||||
|
:arg retry_failed: Retries allocation of shards that are blocked
|
||||||
|
due to too many subsequent allocation failures
|
||||||
|
:arg timeout: Explicit operation timeout
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"POST", "/_cluster/reroute", params=params, headers=headers, body=body
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("flat_settings", "include_defaults", "master_timeout", "timeout")
|
||||||
|
def get_settings(self, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Returns cluster settings.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-update-settings.html>`_
|
||||||
|
|
||||||
|
:arg flat_settings: Return settings in flat format (default:
|
||||||
|
false)
|
||||||
|
:arg include_defaults: Whether to return all default clusters
|
||||||
|
setting.
|
||||||
|
:arg master_timeout: Explicit operation timeout for connection
|
||||||
|
to master node
|
||||||
|
:arg timeout: Explicit operation timeout
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET", "/_cluster/settings", params=params, headers=headers
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("flat_settings", "master_timeout", "timeout")
|
||||||
|
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>`_
|
||||||
|
|
||||||
|
:arg body: The settings to be updated. Can be either `transient`
|
||||||
|
or `persistent` (survives cluster restart).
|
||||||
|
:arg flat_settings: Return settings in flat format (default:
|
||||||
|
false)
|
||||||
|
:arg master_timeout: Explicit operation timeout for connection
|
||||||
|
to master node
|
||||||
|
:arg timeout: Explicit operation timeout
|
||||||
|
"""
|
||||||
|
if body in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'body'.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"PUT", "/_cluster/settings", params=params, headers=headers, body=body
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
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, headers=headers
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("include_disk_info", "include_yes_decisions")
|
||||||
|
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>`_
|
||||||
|
|
||||||
|
:arg body: The index, shard, and primary flag to explain. Empty
|
||||||
|
means 'explain the first unassigned shard'
|
||||||
|
:arg include_disk_info: Return information about disk usage and
|
||||||
|
shard sizes (default: false)
|
||||||
|
:arg include_yes_decisions: Return 'YES' decisions in
|
||||||
|
explanation (default: false)
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"POST",
|
||||||
|
"/_cluster/allocation/explain",
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
body=body,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("master_timeout", "timeout")
|
||||||
|
def delete_component_template(self, name, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Deletes a component template
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-component-templates.html>`_
|
||||||
|
|
||||||
|
:arg name: The name of the template
|
||||||
|
:arg master_timeout: Specify timeout for connection to master
|
||||||
|
:arg timeout: Explicit operation timeout
|
||||||
|
"""
|
||||||
|
if name in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'name'.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"DELETE",
|
||||||
|
_make_path("_component_template", name),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("local", "master_timeout")
|
||||||
|
def get_component_template(self, name=None, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Returns one or more component templates
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-component-templates.html>`_
|
||||||
|
|
||||||
|
:arg name: The comma separated names of the component templates
|
||||||
|
:arg local: Return local information, do not retrieve the state
|
||||||
|
from master node (default: false)
|
||||||
|
:arg master_timeout: Explicit operation timeout for connection
|
||||||
|
to master node
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET",
|
||||||
|
_make_path("_component_template", name),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("create", "master_timeout", "timeout")
|
||||||
|
def put_component_template(self, name, body, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Creates or updates a component template
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-component-templates.html>`_
|
||||||
|
|
||||||
|
:arg name: The name of the template
|
||||||
|
:arg body: The template definition
|
||||||
|
:arg create: Whether the index template should only be added if
|
||||||
|
new or can also replace an existing one
|
||||||
|
:arg master_timeout: Specify timeout for connection to master
|
||||||
|
:arg timeout: Explicit operation timeout
|
||||||
|
"""
|
||||||
|
for param in (name, body):
|
||||||
|
if param in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"PUT",
|
||||||
|
_make_path("_component_template", name),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
body=body,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("local", "master_timeout")
|
||||||
|
def exists_component_template(self, name, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Returns information about whether a particular component template exist
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-component-templates.html>`_
|
||||||
|
|
||||||
|
:arg name: The name of the template
|
||||||
|
:arg local: Return local information, do not retrieve the state
|
||||||
|
from master node (default: false)
|
||||||
|
:arg master_timeout: Explicit operation timeout for connection
|
||||||
|
to master node
|
||||||
|
"""
|
||||||
|
if name in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'name'.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"HEAD",
|
||||||
|
_make_path("_component_template", name),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("wait_for_removal")
|
||||||
|
def delete_voting_config_exclusions(self, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Clears cluster voting config exclusions.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/voting-config-exclusions.html>`_
|
||||||
|
|
||||||
|
:arg wait_for_removal: Specifies whether to wait for all
|
||||||
|
excluded nodes to be removed from the cluster before clearing the voting
|
||||||
|
configuration exclusions list. Default: True
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"DELETE",
|
||||||
|
"/_cluster/voting_config_exclusions",
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("node_ids", "node_names", "timeout")
|
||||||
|
def post_voting_config_exclusions(self, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Updates the cluster voting config exclusions by node ids or node names.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/voting-config-exclusions.html>`_
|
||||||
|
|
||||||
|
:arg node_ids: A comma-separated list of the persistent ids of
|
||||||
|
the nodes to exclude from the voting configuration. If specified, you
|
||||||
|
may not also specify ?node_names.
|
||||||
|
:arg node_names: A comma-separated list of the names of the
|
||||||
|
nodes to exclude from the voting configuration. If specified, you may
|
||||||
|
not also specify ?node_ids.
|
||||||
|
:arg timeout: Explicit operation timeout Default: 30s
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"POST", "/_cluster/voting_config_exclusions", params=params, headers=headers
|
||||||
|
)
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
# Licensed to Elasticsearch B.V under one or more agreements.
|
||||||
|
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||||
|
# See the LICENSE file in the project root for more information
|
||||||
|
|
||||||
|
from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH
|
||||||
|
|
||||||
|
|
||||||
|
class EnrichClient(NamespacedClient):
|
||||||
|
@query_params()
|
||||||
|
def delete_policy(self, name, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Deletes an existing enrich policy and its enrich index.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-enrich-policy-api.html>`_
|
||||||
|
|
||||||
|
:arg name: The name of the enrich policy
|
||||||
|
"""
|
||||||
|
if name in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'name'.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"DELETE",
|
||||||
|
_make_path("_enrich", "policy", name),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("wait_for_completion")
|
||||||
|
def execute_policy(self, name, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Creates the enrich index for an existing enrich policy.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/execute-enrich-policy-api.html>`_
|
||||||
|
|
||||||
|
:arg name: The name of the enrich policy
|
||||||
|
:arg wait_for_completion: Should the request should block until
|
||||||
|
the execution is complete. Default: True
|
||||||
|
"""
|
||||||
|
if name in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'name'.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"PUT",
|
||||||
|
_make_path("_enrich", "policy", name, "_execute"),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def get_policy(self, name=None, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Gets information about an enrich policy.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/get-enrich-policy-api.html>`_
|
||||||
|
|
||||||
|
:arg name: A comma-separated list of enrich policy names
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET", _make_path("_enrich", "policy", name), params=params, headers=headers
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def put_policy(self, name, body, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Creates a new enrich policy.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/put-enrich-policy-api.html>`_
|
||||||
|
|
||||||
|
:arg name: The name of the enrich policy
|
||||||
|
:arg body: The enrich policy to register
|
||||||
|
"""
|
||||||
|
for param in (name, body):
|
||||||
|
if param in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"PUT",
|
||||||
|
_make_path("_enrich", "policy", name),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
body=body,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def stats(self, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Gets enrich coordinator statistics and information about enrich policies that
|
||||||
|
are currently executing.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/enrich-stats-api.html>`_
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET", "/_enrich/_stats", params=params, headers=headers
|
||||||
|
)
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Licensed to Elasticsearch B.V under one or more agreements.
|
||||||
|
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||||
|
# See the LICENSE file in the project root for more information
|
||||||
|
|
||||||
|
from .utils import NamespacedClient, SKIP_IN_PATH, query_params, _make_path
|
||||||
|
|
||||||
|
|
||||||
|
class EqlClient(NamespacedClient):
|
||||||
|
@query_params()
|
||||||
|
def search(self, index, body, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Returns results matching a query expressed in Event Query Language (EQL)
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/eql-search-api.html>`_
|
||||||
|
|
||||||
|
:arg index: The name of the index to scope the operation
|
||||||
|
:arg body: Eql request body. Use the `query` to limit the query
|
||||||
|
scope.
|
||||||
|
"""
|
||||||
|
for param in (index, body):
|
||||||
|
if param in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"POST",
|
||||||
|
_make_path(index, "_eql", "search"),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
body=body,
|
||||||
|
)
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
# Licensed to Elasticsearch B.V under one or more agreements.
|
||||||
|
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||||
|
# See the LICENSE file in the project root for more information
|
||||||
|
|
||||||
|
from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH
|
||||||
|
|
||||||
|
|
||||||
|
class GraphClient(NamespacedClient):
|
||||||
|
@query_params("routing", "timeout")
|
||||||
|
def explore(self, index, body=None, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Explore extracted and summarized information about the documents and terms in
|
||||||
|
an index.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/graph-explore-api.html>`_
|
||||||
|
|
||||||
|
:arg index: A comma-separated list of index names to search; use
|
||||||
|
`_all` or empty string to perform the operation on all indices
|
||||||
|
:arg body: Graph Query DSL
|
||||||
|
:arg routing: Specific routing value
|
||||||
|
:arg timeout: Explicit operation timeout
|
||||||
|
"""
|
||||||
|
if index in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'index'.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"POST",
|
||||||
|
_make_path(index, "_graph", "explore"),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
body=body,
|
||||||
|
)
|
||||||
@@ -0,0 +1,162 @@
|
|||||||
|
# Licensed to Elasticsearch B.V under one or more agreements.
|
||||||
|
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||||
|
# See the LICENSE file in the project root for more information
|
||||||
|
|
||||||
|
from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH
|
||||||
|
|
||||||
|
|
||||||
|
class IlmClient(NamespacedClient):
|
||||||
|
@query_params()
|
||||||
|
def delete_lifecycle(self, policy, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Deletes the specified lifecycle policy definition. A currently used policy
|
||||||
|
cannot be deleted.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/ilm-delete-lifecycle.html>`_
|
||||||
|
|
||||||
|
:arg policy: The name of the index lifecycle policy
|
||||||
|
"""
|
||||||
|
if policy in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'policy'.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"DELETE",
|
||||||
|
_make_path("_ilm", "policy", policy),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("only_errors", "only_managed")
|
||||||
|
def explain_lifecycle(self, index, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Retrieves information about the index's current lifecycle state, such as the
|
||||||
|
currently executing phase, action, and step.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/ilm-explain-lifecycle.html>`_
|
||||||
|
|
||||||
|
:arg index: The name of the index to explain
|
||||||
|
:arg only_errors: filters the indices included in the response
|
||||||
|
to ones in an ILM error state, implies only_managed
|
||||||
|
:arg only_managed: filters the indices included in the response
|
||||||
|
to ones managed by ILM
|
||||||
|
"""
|
||||||
|
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, "_ilm", "explain"), params=params, headers=headers
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def get_lifecycle(self, policy=None, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Returns the specified policy definition. Includes the policy version and last
|
||||||
|
modified date.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/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, headers=headers
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def get_status(self, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Retrieves the current index lifecycle management (ILM) status.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/ilm-get-status.html>`_
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET", "/_ilm/status", params=params, headers=headers
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def move_to_step(self, index, body=None, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Manually moves an index into the specified step and executes that step.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/ilm-move-to-step.html>`_
|
||||||
|
|
||||||
|
:arg index: The name of the index whose lifecycle step is to
|
||||||
|
change
|
||||||
|
:arg body: The new lifecycle step to move to
|
||||||
|
"""
|
||||||
|
if index in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'index'.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"POST",
|
||||||
|
_make_path("_ilm", "move", index),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
body=body,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def put_lifecycle(self, policy, body=None, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Creates a lifecycle policy
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/ilm-put-lifecycle.html>`_
|
||||||
|
|
||||||
|
:arg policy: The name of the index lifecycle policy
|
||||||
|
:arg body: The lifecycle policy definition to register
|
||||||
|
"""
|
||||||
|
if policy in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'policy'.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"PUT",
|
||||||
|
_make_path("_ilm", "policy", policy),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
body=body,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def remove_policy(self, index, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Removes the assigned lifecycle policy and stops managing the specified index
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/ilm-remove-policy.html>`_
|
||||||
|
|
||||||
|
:arg index: The name of the index to remove policy on
|
||||||
|
"""
|
||||||
|
if index in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'index'.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"POST", _make_path(index, "_ilm", "remove"), params=params, headers=headers
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def retry(self, index, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Retries executing the policy for an index that is in the ERROR step.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/ilm-retry-policy.html>`_
|
||||||
|
|
||||||
|
:arg index: The name of the indices (comma-separated) whose
|
||||||
|
failed lifecycle step is to be retry
|
||||||
|
"""
|
||||||
|
if index in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'index'.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"POST", _make_path(index, "_ilm", "retry"), params=params, headers=headers
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def start(self, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Start the index lifecycle management (ILM) plugin.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/ilm-start.html>`_
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"POST", "/_ilm/start", params=params, headers=headers
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def stop(self, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Halts all lifecycle management operations and stops the index lifecycle
|
||||||
|
management (ILM) plugin
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/ilm-stop.html>`_
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"POST", "/_ilm/stop", params=params, headers=headers
|
||||||
|
)
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,99 @@
|
|||||||
|
# Licensed to Elasticsearch B.V under one or more agreements.
|
||||||
|
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||||
|
# See the LICENSE file in the project root for more information
|
||||||
|
|
||||||
|
from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH
|
||||||
|
|
||||||
|
|
||||||
|
class IngestClient(NamespacedClient):
|
||||||
|
@query_params("master_timeout")
|
||||||
|
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>`_
|
||||||
|
|
||||||
|
:arg id: Comma separated list of pipeline ids. Wildcards
|
||||||
|
supported
|
||||||
|
:arg master_timeout: Explicit operation timeout for connection
|
||||||
|
to master node
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET", _make_path("_ingest", "pipeline", id), params=params, headers=headers
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("master_timeout", "timeout")
|
||||||
|
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>`_
|
||||||
|
|
||||||
|
:arg id: Pipeline ID
|
||||||
|
:arg body: The ingest definition
|
||||||
|
:arg master_timeout: Explicit operation timeout for connection
|
||||||
|
to master node
|
||||||
|
:arg timeout: Explicit operation timeout
|
||||||
|
"""
|
||||||
|
for param in (id, body):
|
||||||
|
if param in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"PUT",
|
||||||
|
_make_path("_ingest", "pipeline", id),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
body=body,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("master_timeout", "timeout")
|
||||||
|
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>`_
|
||||||
|
|
||||||
|
:arg id: Pipeline ID
|
||||||
|
:arg master_timeout: Explicit operation timeout for connection
|
||||||
|
to master node
|
||||||
|
:arg timeout: Explicit operation timeout
|
||||||
|
"""
|
||||||
|
if id in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'id'.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"DELETE",
|
||||||
|
_make_path("_ingest", "pipeline", id),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("verbose")
|
||||||
|
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>`_
|
||||||
|
|
||||||
|
:arg body: The simulate definition
|
||||||
|
:arg id: Pipeline ID
|
||||||
|
:arg verbose: Verbose mode. Display data output for each
|
||||||
|
processor in executed pipeline
|
||||||
|
"""
|
||||||
|
if body in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'body'.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"POST",
|
||||||
|
_make_path("_ingest", "pipeline", id, "_simulate"),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
body=body,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
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, headers=headers
|
||||||
|
)
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
# Licensed to Elasticsearch B.V under one or more agreements.
|
||||||
|
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||||
|
# See the LICENSE file in the project root for more information
|
||||||
|
|
||||||
|
from .utils import NamespacedClient, query_params
|
||||||
|
|
||||||
|
|
||||||
|
class LicenseClient(NamespacedClient):
|
||||||
|
@query_params()
|
||||||
|
def delete(self, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Deletes licensing information for the cluster
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-license.html>`_
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"DELETE", "/_license", params=params, headers=headers
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("accept_enterprise", "local")
|
||||||
|
def get(self, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Retrieves licensing information for the cluster
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/get-license.html>`_
|
||||||
|
|
||||||
|
:arg accept_enterprise: Supported for backwards compatibility
|
||||||
|
with 7.x. If this param is used it must be set to true
|
||||||
|
:arg local: Return local information, do not retrieve the state
|
||||||
|
from master node (default: false)
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET", "/_license", params=params, headers=headers
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def get_basic_status(self, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Retrieves information about the status of the basic license.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/get-basic-status.html>`_
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET", "/_license/basic_status", params=params, headers=headers
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def get_trial_status(self, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Retrieves information about the status of the trial license.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/get-trial-status.html>`_
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET", "/_license/trial_status", params=params, headers=headers
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("acknowledge")
|
||||||
|
def post(self, body=None, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Updates the license for the cluster.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/update-license.html>`_
|
||||||
|
|
||||||
|
:arg body: licenses to be installed
|
||||||
|
:arg acknowledge: whether the user has acknowledged acknowledge
|
||||||
|
messages (default: false)
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"PUT", "/_license", params=params, headers=headers, body=body
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("acknowledge")
|
||||||
|
def post_start_basic(self, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Starts an indefinite basic license.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/start-basic.html>`_
|
||||||
|
|
||||||
|
:arg acknowledge: whether the user has acknowledged acknowledge
|
||||||
|
messages (default: false)
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"POST", "/_license/start_basic", params=params, headers=headers
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("acknowledge", "doc_type")
|
||||||
|
def post_start_trial(self, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
starts a limited time trial license.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/start-trial.html>`_
|
||||||
|
|
||||||
|
:arg acknowledge: whether the user has acknowledged acknowledge
|
||||||
|
messages (default: false)
|
||||||
|
:arg doc_type: The type of trial license to generate (default:
|
||||||
|
"trial")
|
||||||
|
"""
|
||||||
|
# type is a reserved word so it cannot be used, use doc_type instead
|
||||||
|
if "doc_type" in params:
|
||||||
|
params["type"] = params.pop("doc_type")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"POST", "/_license/start_trial", params=params, headers=headers
|
||||||
|
)
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
# Licensed to Elasticsearch B.V under one or more agreements.
|
||||||
|
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||||
|
# See the LICENSE file in the project root for more information
|
||||||
|
|
||||||
|
from .utils import NamespacedClient, query_params, _make_path
|
||||||
|
|
||||||
|
|
||||||
|
class MigrationClient(NamespacedClient):
|
||||||
|
@query_params()
|
||||||
|
def deprecations(self, index=None, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Retrieves information about different cluster, node, and index level settings
|
||||||
|
that use deprecated features that will be removed or changed in the next major
|
||||||
|
version.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/migration-api-deprecation.html>`_
|
||||||
|
|
||||||
|
:arg index: Index pattern
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET",
|
||||||
|
_make_path(index, "_migration", "deprecations"),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,34 @@
|
|||||||
|
# Licensed to Elasticsearch B.V under one or more agreements.
|
||||||
|
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||||
|
# See the LICENSE file in the project root for more information
|
||||||
|
|
||||||
|
from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH, _bulk_body
|
||||||
|
|
||||||
|
|
||||||
|
class MonitoringClient(NamespacedClient):
|
||||||
|
@query_params("interval", "system_api_version", "system_id")
|
||||||
|
def bulk(self, body, doc_type=None, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Used by the monitoring features to send monitoring data.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/monitor-elasticsearch-cluster.html>`_
|
||||||
|
|
||||||
|
:arg body: The operation definition and data (action-data
|
||||||
|
pairs), separated by newlines
|
||||||
|
:arg doc_type: Default document type for items which don't
|
||||||
|
provide one
|
||||||
|
:arg interval: Collection interval (e.g., '10s' or '10000ms') of
|
||||||
|
the payload
|
||||||
|
:arg system_api_version: API Version of the monitored system
|
||||||
|
:arg system_id: Identifier of the monitored system
|
||||||
|
"""
|
||||||
|
if body in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'body'.")
|
||||||
|
|
||||||
|
body = _bulk_body(self.transport.serializer, body)
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"POST",
|
||||||
|
_make_path("_monitoring", doc_type, "bulk"),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
body=body,
|
||||||
|
)
|
||||||
@@ -0,0 +1,160 @@
|
|||||||
|
# Licensed to Elasticsearch B.V under one or more agreements.
|
||||||
|
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||||
|
# See the LICENSE file in the project root for more information
|
||||||
|
|
||||||
|
from .utils import NamespacedClient, query_params, _make_path
|
||||||
|
|
||||||
|
|
||||||
|
class NodesClient(NamespacedClient):
|
||||||
|
@query_params("timeout")
|
||||||
|
def reload_secure_settings(
|
||||||
|
self, body=None, 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>`_
|
||||||
|
|
||||||
|
:arg body: An object containing the password for the
|
||||||
|
elasticsearch keystore
|
||||||
|
:arg node_id: A comma-separated list of node IDs to span the
|
||||||
|
reload/reinit call. Should stay empty because reloading usually involves
|
||||||
|
all cluster nodes.
|
||||||
|
:arg timeout: Explicit operation timeout
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"POST",
|
||||||
|
_make_path("_nodes", node_id, "reload_secure_settings"),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
body=body,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("flat_settings", "timeout")
|
||||||
|
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>`_
|
||||||
|
|
||||||
|
:arg node_id: A comma-separated list of node IDs or names to
|
||||||
|
limit the returned information; use `_local` to return information from
|
||||||
|
the node you're connecting to, leave empty to get information from all
|
||||||
|
nodes
|
||||||
|
:arg metric: A comma-separated list of metrics you wish
|
||||||
|
returned. Leave empty to return all. Valid choices: settings, os,
|
||||||
|
process, jvm, thread_pool, transport, http, plugins, ingest
|
||||||
|
:arg flat_settings: Return settings in flat format (default:
|
||||||
|
false)
|
||||||
|
:arg timeout: Explicit operation timeout
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET", _make_path("_nodes", node_id, 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, 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>`_
|
||||||
|
|
||||||
|
:arg node_id: A comma-separated list of node IDs or names to
|
||||||
|
limit the returned information; use `_local` to return information from
|
||||||
|
the node you're connecting to, leave empty to get information from all
|
||||||
|
nodes
|
||||||
|
:arg doc_type: The type to sample (default: cpu) Valid choices:
|
||||||
|
cpu, wait, block
|
||||||
|
:arg ignore_idle_threads: Don't show threads that are in known-
|
||||||
|
idle places, such as waiting on a socket select or pulling from an empty
|
||||||
|
task queue (default: true)
|
||||||
|
:arg interval: The interval for the second sampling of threads
|
||||||
|
:arg snapshots: Number of samples of thread stacktrace (default:
|
||||||
|
10)
|
||||||
|
:arg threads: Specify the number of threads to provide
|
||||||
|
information for (default: 3)
|
||||||
|
:arg timeout: Explicit operation timeout
|
||||||
|
"""
|
||||||
|
# type is a reserved word so it cannot be used, use doc_type instead
|
||||||
|
if "doc_type" in params:
|
||||||
|
params["type"] = params.pop("doc_type")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"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, 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>`_
|
||||||
|
|
||||||
|
:arg node_id: A comma-separated list of node IDs or names to
|
||||||
|
limit the returned information; use `_local` to return information from
|
||||||
|
the node you're connecting to, leave empty to get information from all
|
||||||
|
nodes
|
||||||
|
:arg metric: Limit the information returned to the specified
|
||||||
|
metrics Valid choices: _all, rest_actions
|
||||||
|
:arg timeout: Explicit operation timeout
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET",
|
||||||
|
_make_path("_nodes", node_id, "usage", metric),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params(
|
||||||
|
"completion_fields",
|
||||||
|
"fielddata_fields",
|
||||||
|
"fields",
|
||||||
|
"groups",
|
||||||
|
"include_segment_file_sizes",
|
||||||
|
"level",
|
||||||
|
"timeout",
|
||||||
|
"types",
|
||||||
|
)
|
||||||
|
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>`_
|
||||||
|
|
||||||
|
:arg node_id: A comma-separated list of node IDs or names to
|
||||||
|
limit the returned information; use `_local` to return information from
|
||||||
|
the node you're connecting to, leave empty to get information from all
|
||||||
|
nodes
|
||||||
|
:arg metric: Limit the information returned to the specified
|
||||||
|
metrics Valid choices: _all, breaker, fs, http, indices, jvm, os,
|
||||||
|
process, thread_pool, transport, discovery
|
||||||
|
:arg index_metric: Limit the information returned for `indices`
|
||||||
|
metric to the specific index metrics. Isn't used if `indices` (or `all`)
|
||||||
|
metric isn't specified. Valid choices: _all, completion, docs,
|
||||||
|
fielddata, query_cache, flush, get, indexing, merge, request_cache,
|
||||||
|
refresh, search, segments, store, warmer, suggest, bulk
|
||||||
|
:arg completion_fields: A comma-separated list of fields for
|
||||||
|
`fielddata` and `suggest` index metric (supports wildcards)
|
||||||
|
:arg fielddata_fields: A comma-separated list of fields for
|
||||||
|
`fielddata` index metric (supports wildcards)
|
||||||
|
:arg fields: A comma-separated list of fields for `fielddata`
|
||||||
|
and `completion` index metric (supports wildcards)
|
||||||
|
:arg groups: A comma-separated list of search groups for
|
||||||
|
`search` index metric
|
||||||
|
:arg include_segment_file_sizes: Whether to report the
|
||||||
|
aggregated disk usage of each one of the Lucene index files (only
|
||||||
|
applies if segment stats are requested)
|
||||||
|
:arg level: Return indices stats aggregated at index, node or
|
||||||
|
shard level Valid choices: indices, node, shards Default: node
|
||||||
|
:arg timeout: Explicit operation timeout
|
||||||
|
:arg types: A comma-separated list of document types for the
|
||||||
|
`indexing` index metric
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET",
|
||||||
|
_make_path("_nodes", node_id, "stats", metric, index_metric),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
# Licensed to Elasticsearch B.V under one or more agreements.
|
||||||
|
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||||
|
# See the LICENSE file in the project root for more information
|
||||||
|
|
||||||
|
from .utils import NamespacedClient, query_params
|
||||||
|
|
||||||
|
|
||||||
|
class RemoteClient(NamespacedClient):
|
||||||
|
@query_params()
|
||||||
|
def info(self, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
`<http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-remote-info.html>`_
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET", "/_remote/info", params=params, headers=headers
|
||||||
|
)
|
||||||
@@ -0,0 +1,155 @@
|
|||||||
|
# Licensed to Elasticsearch B.V under one or more agreements.
|
||||||
|
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||||
|
# See the LICENSE file in the project root for more information
|
||||||
|
|
||||||
|
from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH
|
||||||
|
|
||||||
|
|
||||||
|
class RollupClient(NamespacedClient):
|
||||||
|
@query_params()
|
||||||
|
def delete_job(self, id, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Deletes an existing rollup job.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-delete-job.html>`_
|
||||||
|
|
||||||
|
:arg id: The ID of the job to delete
|
||||||
|
"""
|
||||||
|
if id in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'id'.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"DELETE", _make_path("_rollup", "job", id), params=params, headers=headers
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def get_jobs(self, id=None, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Retrieves the configuration, stats, and status of rollup jobs.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-get-job.html>`_
|
||||||
|
|
||||||
|
: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, headers=headers
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def get_rollup_caps(self, id=None, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Returns the capabilities of any rollup jobs that have been configured for a
|
||||||
|
specific index or index pattern.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-get-rollup-caps.html>`_
|
||||||
|
|
||||||
|
: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, headers=headers
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def get_rollup_index_caps(self, index, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Returns the rollup capabilities of all jobs inside of a rollup index (e.g. the
|
||||||
|
index where rollup data is stored).
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-get-rollup-index-caps.html>`_
|
||||||
|
|
||||||
|
:arg index: The rollup index or index pattern to obtain rollup
|
||||||
|
capabilities from.
|
||||||
|
"""
|
||||||
|
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, "_rollup", "data"), params=params, headers=headers
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def put_job(self, id, body, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Creates a rollup job.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-put-job.html>`_
|
||||||
|
|
||||||
|
:arg id: The ID of the job to create
|
||||||
|
:arg body: The job configuration
|
||||||
|
"""
|
||||||
|
for param in (id, body):
|
||||||
|
if param in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"PUT",
|
||||||
|
_make_path("_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, headers=None):
|
||||||
|
"""
|
||||||
|
Enables searching rolled-up data using the standard query DSL.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-search.html>`_
|
||||||
|
|
||||||
|
:arg index: The indices or index-pattern(s) (containing rollup
|
||||||
|
or regular data) that should be searched
|
||||||
|
:arg body: The search request body
|
||||||
|
:arg doc_type: The doc type inside the index
|
||||||
|
:arg rest_total_hits_as_int: Indicates whether hits.total should
|
||||||
|
be rendered as an integer or an object in the rest search response
|
||||||
|
:arg typed_keys: Specify whether aggregation and suggester names
|
||||||
|
should be prefixed by their respective types in the response
|
||||||
|
"""
|
||||||
|
for param in (index, body):
|
||||||
|
if param in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"POST",
|
||||||
|
_make_path(index, doc_type, "_rollup_search"),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
body=body,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def start_job(self, id, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Starts an existing, stopped rollup job.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-start-job.html>`_
|
||||||
|
|
||||||
|
:arg id: The ID of the job to start
|
||||||
|
"""
|
||||||
|
if id in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'id'.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"POST",
|
||||||
|
_make_path("_rollup", "job", id, "_start"),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("timeout", "wait_for_completion")
|
||||||
|
def stop_job(self, id, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Stops an existing, started rollup job.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-stop-job.html>`_
|
||||||
|
|
||||||
|
:arg id: The ID of the job to stop
|
||||||
|
:arg timeout: Block for (at maximum) the specified duration
|
||||||
|
while waiting for the job to stop. Defaults to 30s.
|
||||||
|
:arg wait_for_completion: True if the API should block until the
|
||||||
|
job has fully stopped, false if should be executed async. Defaults to
|
||||||
|
false.
|
||||||
|
"""
|
||||||
|
if id in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'id'.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"POST",
|
||||||
|
_make_path("_rollup", "job", id, "_stop"),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
# Licensed to Elasticsearch B.V under one or more agreements.
|
||||||
|
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||||
|
# See the LICENSE file in the project root for more information
|
||||||
|
|
||||||
|
from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH
|
||||||
|
|
||||||
|
|
||||||
|
class SearchableSnapshotsClient(NamespacedClient):
|
||||||
|
@query_params("allow_no_indices", "expand_wildcards", "ignore_unavailable")
|
||||||
|
def clear_cache(self, index=None, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Clear the cache of searchable snapshots.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/searchable-snapshots-api-clear-cache.html>`_
|
||||||
|
|
||||||
|
:arg index: A comma-separated list of index name to limit the
|
||||||
|
operation
|
||||||
|
:arg allow_no_indices: Whether to ignore if a wildcard indices
|
||||||
|
expression resolves into no concrete indices. (This includes `_all`
|
||||||
|
string or when no indices have been specified)
|
||||||
|
:arg expand_wildcards: Whether to expand wildcard expression to
|
||||||
|
concrete indices that are open, closed or both. Valid choices: open,
|
||||||
|
closed, none, all Default: open
|
||||||
|
:arg ignore_unavailable: Whether specified concrete indices
|
||||||
|
should be ignored when unavailable (missing or closed)
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"POST",
|
||||||
|
_make_path(index, "_searchable_snapshots", "cache", "clear"),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("master_timeout", "wait_for_completion")
|
||||||
|
def mount(self, repository, snapshot, body, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Mount a snapshot as a searchable index.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/searchable-snapshots-api-mount-snapshot.html>`_
|
||||||
|
|
||||||
|
:arg repository: The name of the repository containing the
|
||||||
|
snapshot of the index to mount
|
||||||
|
:arg snapshot: The name of the snapshot of the index to mount
|
||||||
|
:arg body: The restore configuration for mounting the snapshot
|
||||||
|
as searchable
|
||||||
|
:arg master_timeout: Explicit operation timeout for connection
|
||||||
|
to master node
|
||||||
|
:arg wait_for_completion: Should this request wait until the
|
||||||
|
operation has completed before returning
|
||||||
|
"""
|
||||||
|
for param in (repository, snapshot, body):
|
||||||
|
if param in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"POST",
|
||||||
|
_make_path("_snapshot", repository, snapshot, "_mount"),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
body=body,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def repository_stats(self, repository, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Retrieve usage statistics about a snapshot repository.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/searchable-snapshots-repository-stats.html>`_
|
||||||
|
|
||||||
|
:arg repository: The repository for which to get the stats for
|
||||||
|
"""
|
||||||
|
if repository in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'repository'.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET",
|
||||||
|
_make_path("_snapshot", repository, "_stats"),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def stats(self, index=None, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Retrieve various statistics about searchable snapshots.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/searchable-snapshots-api-stats.html>`_
|
||||||
|
|
||||||
|
:arg index: A comma-separated list of index names
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET",
|
||||||
|
_make_path(index, "_searchable_snapshots", "stats"),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
@@ -0,0 +1,497 @@
|
|||||||
|
# Licensed to Elasticsearch B.V under one or more agreements.
|
||||||
|
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||||
|
# See the LICENSE file in the project root for more information
|
||||||
|
|
||||||
|
from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH
|
||||||
|
|
||||||
|
|
||||||
|
class SecurityClient(NamespacedClient):
|
||||||
|
@query_params()
|
||||||
|
def authenticate(self, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Enables authentication as a user and retrieve information about the
|
||||||
|
authenticated user.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/security-api-authenticate.html>`_
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET", "/_security/_authenticate", params=params, headers=headers
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("refresh")
|
||||||
|
def change_password(self, body, username=None, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Changes the passwords of users in the native realm and built-in users.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/security-api-change-password.html>`_
|
||||||
|
|
||||||
|
:arg body: the new password for the user
|
||||||
|
:arg username: The username of the user to change the password
|
||||||
|
for
|
||||||
|
:arg refresh: If `true` (the default) then refresh the affected
|
||||||
|
shards to make this operation visible to search, if `wait_for` then wait
|
||||||
|
for a refresh to make this operation visible to search, if `false` then
|
||||||
|
do nothing with refreshes. Valid choices: true, false, wait_for
|
||||||
|
"""
|
||||||
|
if body in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'body'.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"PUT",
|
||||||
|
_make_path("_security", "user", username, "_password"),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
body=body,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("usernames")
|
||||||
|
def clear_cached_realms(self, realms, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Evicts users from the user cache. Can completely clear the cache or evict
|
||||||
|
specific users.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/security-api-clear-cache.html>`_
|
||||||
|
|
||||||
|
:arg realms: Comma-separated list of realms to clear
|
||||||
|
:arg usernames: Comma-separated list of usernames to clear from
|
||||||
|
the cache
|
||||||
|
"""
|
||||||
|
if realms in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'realms'.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"POST",
|
||||||
|
_make_path("_security", "realm", realms, "_clear_cache"),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def clear_cached_roles(self, name, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Evicts roles from the native role cache.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/security-api-clear-role-cache.html>`_
|
||||||
|
|
||||||
|
:arg name: Role name
|
||||||
|
"""
|
||||||
|
if name in SKIP_IN_PATH:
|
||||||
|
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,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("refresh")
|
||||||
|
def create_api_key(self, body, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Creates an API key for access without requiring basic authentication.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/security-api-create-api-key.html>`_
|
||||||
|
|
||||||
|
:arg body: The api key request to create an API key
|
||||||
|
:arg refresh: If `true` (the default) then refresh the affected
|
||||||
|
shards to make this operation visible to search, if `wait_for` then wait
|
||||||
|
for a refresh to make this operation visible to search, if `false` then
|
||||||
|
do nothing with refreshes. Valid choices: true, false, wait_for
|
||||||
|
"""
|
||||||
|
if body in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'body'.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"PUT", "/_security/api_key", params=params, headers=headers, body=body
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("refresh")
|
||||||
|
def delete_privileges(self, application, name, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Removes application privileges.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/security-api-delete-privilege.html>`_
|
||||||
|
|
||||||
|
:arg application: Application name
|
||||||
|
:arg name: Privilege name
|
||||||
|
:arg refresh: If `true` (the default) then refresh the affected
|
||||||
|
shards to make this operation visible to search, if `wait_for` then wait
|
||||||
|
for a refresh to make this operation visible to search, if `false` then
|
||||||
|
do nothing with refreshes. Valid choices: true, false, wait_for
|
||||||
|
"""
|
||||||
|
for param in (application, name):
|
||||||
|
if param in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"DELETE",
|
||||||
|
_make_path("_security", "privilege", application, name),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("refresh")
|
||||||
|
def delete_role(self, name, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Removes roles in the native realm.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/security-api-delete-role.html>`_
|
||||||
|
|
||||||
|
:arg name: Role name
|
||||||
|
:arg refresh: If `true` (the default) then refresh the affected
|
||||||
|
shards to make this operation visible to search, if `wait_for` then wait
|
||||||
|
for a refresh to make this operation visible to search, if `false` then
|
||||||
|
do nothing with refreshes. Valid choices: true, false, wait_for
|
||||||
|
"""
|
||||||
|
if name in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'name'.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"DELETE",
|
||||||
|
_make_path("_security", "role", name),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("refresh")
|
||||||
|
def delete_role_mapping(self, name, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Removes role mappings.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/security-api-delete-role-mapping.html>`_
|
||||||
|
|
||||||
|
:arg name: Role-mapping name
|
||||||
|
:arg refresh: If `true` (the default) then refresh the affected
|
||||||
|
shards to make this operation visible to search, if `wait_for` then wait
|
||||||
|
for a refresh to make this operation visible to search, if `false` then
|
||||||
|
do nothing with refreshes. Valid choices: true, false, wait_for
|
||||||
|
"""
|
||||||
|
if name in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'name'.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"DELETE",
|
||||||
|
_make_path("_security", "role_mapping", name),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("refresh")
|
||||||
|
def delete_user(self, username, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Deletes users from the native realm.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/security-api-delete-user.html>`_
|
||||||
|
|
||||||
|
:arg username: username
|
||||||
|
:arg refresh: If `true` (the default) then refresh the affected
|
||||||
|
shards to make this operation visible to search, if `wait_for` then wait
|
||||||
|
for a refresh to make this operation visible to search, if `false` then
|
||||||
|
do nothing with refreshes. Valid choices: true, false, wait_for
|
||||||
|
"""
|
||||||
|
if username in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'username'.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"DELETE",
|
||||||
|
_make_path("_security", "user", username),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("refresh")
|
||||||
|
def disable_user(self, username, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Disables users in the native realm.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/security-api-disable-user.html>`_
|
||||||
|
|
||||||
|
:arg username: The username of the user to disable
|
||||||
|
:arg refresh: If `true` (the default) then refresh the affected
|
||||||
|
shards to make this operation visible to search, if `wait_for` then wait
|
||||||
|
for a refresh to make this operation visible to search, if `false` then
|
||||||
|
do nothing with refreshes. Valid choices: true, false, wait_for
|
||||||
|
"""
|
||||||
|
if username in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'username'.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"PUT",
|
||||||
|
_make_path("_security", "user", username, "_disable"),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("refresh")
|
||||||
|
def enable_user(self, username, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Enables users in the native realm.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/security-api-enable-user.html>`_
|
||||||
|
|
||||||
|
:arg username: The username of the user to enable
|
||||||
|
:arg refresh: If `true` (the default) then refresh the affected
|
||||||
|
shards to make this operation visible to search, if `wait_for` then wait
|
||||||
|
for a refresh to make this operation visible to search, if `false` then
|
||||||
|
do nothing with refreshes. Valid choices: true, false, wait_for
|
||||||
|
"""
|
||||||
|
if username in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'username'.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"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, headers=None):
|
||||||
|
"""
|
||||||
|
Retrieves information for one or more API keys.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/security-api-get-api-key.html>`_
|
||||||
|
|
||||||
|
:arg id: API key id of the API key to be retrieved
|
||||||
|
:arg name: API key name of the API key to be retrieved
|
||||||
|
:arg owner: flag to query API keys owned by the currently
|
||||||
|
authenticated user
|
||||||
|
:arg realm_name: realm name of the user who created this API key
|
||||||
|
to be retrieved
|
||||||
|
:arg username: user name of the user who created this API key to
|
||||||
|
be retrieved
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET", "/_security/api_key", params=params, headers=headers
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def get_privileges(self, application=None, name=None, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Retrieves application privileges.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/security-api-get-privileges.html>`_
|
||||||
|
|
||||||
|
:arg application: Application name
|
||||||
|
:arg name: Privilege name
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET",
|
||||||
|
_make_path("_security", "privilege", application, name),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def get_role(self, name=None, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Retrieves roles in the native realm.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/security-api-get-role.html>`_
|
||||||
|
|
||||||
|
:arg name: Role name
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET", _make_path("_security", "role", name), params=params, headers=headers
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def get_role_mapping(self, name=None, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Retrieves role mappings.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/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,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def get_token(self, body, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Creates a bearer token for access without requiring basic authentication.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/security-api-get-token.html>`_
|
||||||
|
|
||||||
|
:arg body: The token request to get
|
||||||
|
"""
|
||||||
|
if body in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'body'.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"POST", "/_security/oauth2/token", params=params, headers=headers, body=body
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def get_user(self, username=None, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Retrieves information about users in the native realm and built-in users.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/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,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def get_user_privileges(self, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Retrieves application privileges.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/security-api-get-privileges.html>`_
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET", "/_security/user/_privileges", params=params, headers=headers
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def has_privileges(self, body, user=None, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Determines whether the specified user has a specified list of privileges.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/security-api-has-privileges.html>`_
|
||||||
|
|
||||||
|
:arg body: The privileges to test
|
||||||
|
:arg user: Username
|
||||||
|
"""
|
||||||
|
if body in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'body'.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"POST",
|
||||||
|
_make_path("_security", "user", user, "_has_privileges"),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
body=body,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def invalidate_api_key(self, body, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Invalidates one or more API keys.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/security-api-invalidate-api-key.html>`_
|
||||||
|
|
||||||
|
:arg body: The api key request to invalidate API key(s)
|
||||||
|
"""
|
||||||
|
if body in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'body'.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"DELETE", "/_security/api_key", params=params, headers=headers, body=body
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def invalidate_token(self, body, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Invalidates one or more access tokens or refresh tokens.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/security-api-invalidate-token.html>`_
|
||||||
|
|
||||||
|
:arg body: The token to invalidate
|
||||||
|
"""
|
||||||
|
if body in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'body'.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"DELETE",
|
||||||
|
"/_security/oauth2/token",
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
body=body,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("refresh")
|
||||||
|
def put_privileges(self, body, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Adds or updates application privileges.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/security-api-put-privileges.html>`_
|
||||||
|
|
||||||
|
:arg body: The privilege(s) to add
|
||||||
|
:arg refresh: If `true` (the default) then refresh the affected
|
||||||
|
shards to make this operation visible to search, if `wait_for` then wait
|
||||||
|
for a refresh to make this operation visible to search, if `false` then
|
||||||
|
do nothing with refreshes. Valid choices: true, false, wait_for
|
||||||
|
"""
|
||||||
|
if body in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'body'.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"PUT", "/_security/privilege/", params=params, headers=headers, body=body
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("refresh")
|
||||||
|
def put_role(self, name, body, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Adds and updates roles in the native realm.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/security-api-put-role.html>`_
|
||||||
|
|
||||||
|
:arg name: Role name
|
||||||
|
:arg body: The role to add
|
||||||
|
:arg refresh: If `true` (the default) then refresh the affected
|
||||||
|
shards to make this operation visible to search, if `wait_for` then wait
|
||||||
|
for a refresh to make this operation visible to search, if `false` then
|
||||||
|
do nothing with refreshes. Valid choices: true, false, wait_for
|
||||||
|
"""
|
||||||
|
for param in (name, body):
|
||||||
|
if param in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"PUT",
|
||||||
|
_make_path("_security", "role", name),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
body=body,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("refresh")
|
||||||
|
def put_role_mapping(self, name, body, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Creates and updates role mappings.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/security-api-put-role-mapping.html>`_
|
||||||
|
|
||||||
|
:arg name: Role-mapping name
|
||||||
|
:arg body: The role mapping to add
|
||||||
|
:arg refresh: If `true` (the default) then refresh the affected
|
||||||
|
shards to make this operation visible to search, if `wait_for` then wait
|
||||||
|
for a refresh to make this operation visible to search, if `false` then
|
||||||
|
do nothing with refreshes. Valid choices: true, false, wait_for
|
||||||
|
"""
|
||||||
|
for param in (name, body):
|
||||||
|
if param in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"PUT",
|
||||||
|
_make_path("_security", "role_mapping", name),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
body=body,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("refresh")
|
||||||
|
def put_user(self, username, body, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Adds and updates users in the native realm. These users are commonly referred
|
||||||
|
to as native users.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/security-api-put-user.html>`_
|
||||||
|
|
||||||
|
:arg username: The username of the User
|
||||||
|
:arg body: The user to add
|
||||||
|
:arg refresh: If `true` (the default) then refresh the affected
|
||||||
|
shards to make this operation visible to search, if `wait_for` then wait
|
||||||
|
for a refresh to make this operation visible to search, if `false` then
|
||||||
|
do nothing with refreshes. Valid choices: true, false, wait_for
|
||||||
|
"""
|
||||||
|
for param in (username, body):
|
||||||
|
if param in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"PUT",
|
||||||
|
_make_path("_security", "user", username),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
body=body,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def get_builtin_privileges(self, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Retrieves the list of cluster privileges and index privileges that are
|
||||||
|
available in this version of Elasticsearch.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/security-api-get-builtin-privileges.html>`_
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET", "/_security/privilege/_builtin", params=params, headers=headers
|
||||||
|
)
|
||||||
@@ -0,0 +1,135 @@
|
|||||||
|
# Licensed to Elasticsearch B.V under one or more agreements.
|
||||||
|
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||||
|
# See the LICENSE file in the project root for more information
|
||||||
|
|
||||||
|
from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH
|
||||||
|
|
||||||
|
|
||||||
|
class SlmClient(NamespacedClient):
|
||||||
|
@query_params()
|
||||||
|
def delete_lifecycle(self, policy_id, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Deletes an existing snapshot lifecycle policy.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/slm-api-delete-policy.html>`_
|
||||||
|
|
||||||
|
:arg policy_id: The id of the snapshot lifecycle policy to
|
||||||
|
remove
|
||||||
|
"""
|
||||||
|
if policy_id in SKIP_IN_PATH:
|
||||||
|
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,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def execute_lifecycle(self, policy_id, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Immediately creates a snapshot according to the lifecycle policy, without
|
||||||
|
waiting for the scheduled time.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/slm-api-execute-lifecycle.html>`_
|
||||||
|
|
||||||
|
:arg policy_id: The id of the snapshot lifecycle policy to be
|
||||||
|
executed
|
||||||
|
"""
|
||||||
|
if policy_id in SKIP_IN_PATH:
|
||||||
|
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,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def execute_retention(self, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Deletes any snapshots that are expired according to the policy's retention
|
||||||
|
rules.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/slm-api-execute-retention.html>`_
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"POST", "/_slm/_execute_retention", params=params, headers=headers
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def get_lifecycle(self, policy_id=None, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Retrieves one or more snapshot lifecycle policy definitions and information
|
||||||
|
about the latest snapshot attempts.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/slm-api-get-policy.html>`_
|
||||||
|
|
||||||
|
:arg policy_id: Comma-separated list of snapshot lifecycle
|
||||||
|
policies to retrieve
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET",
|
||||||
|
_make_path("_slm", "policy", policy_id),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def get_stats(self, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Returns global and policy-level statistics about actions taken by snapshot
|
||||||
|
lifecycle management.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/slm-api-get-stats.html>`_
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET", "/_slm/stats", params=params, headers=headers
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def put_lifecycle(self, policy_id, body=None, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Creates or updates a snapshot lifecycle policy.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/slm-api-put-policy.html>`_
|
||||||
|
|
||||||
|
:arg policy_id: The id of the snapshot lifecycle policy
|
||||||
|
:arg body: The snapshot lifecycle policy definition to register
|
||||||
|
"""
|
||||||
|
if policy_id in SKIP_IN_PATH:
|
||||||
|
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,
|
||||||
|
headers=headers,
|
||||||
|
body=body,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def get_status(self, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Retrieves the status of snapshot lifecycle management (SLM).
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/slm-api-get-status.html>`_
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET", "/_slm/status", params=params, headers=headers
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def start(self, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Turns on snapshot lifecycle management (SLM).
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/slm-api-start.html>`_
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"POST", "/_slm/start", params=params, headers=headers
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def stop(self, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Turns off snapshot lifecycle management (SLM).
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/slm-api-stop.html>`_
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"POST", "/_slm/stop", params=params, headers=headers
|
||||||
|
)
|
||||||
@@ -0,0 +1,233 @@
|
|||||||
|
# Licensed to Elasticsearch B.V under one or more agreements.
|
||||||
|
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||||
|
# See the LICENSE file in the project root for more information
|
||||||
|
|
||||||
|
from .utils import NamespacedClient, 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, headers=None):
|
||||||
|
"""
|
||||||
|
Creates a snapshot in a repository.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html>`_
|
||||||
|
|
||||||
|
:arg repository: A repository name
|
||||||
|
:arg snapshot: A snapshot name
|
||||||
|
:arg body: The snapshot definition
|
||||||
|
:arg master_timeout: Explicit operation timeout for connection
|
||||||
|
to master node
|
||||||
|
:arg wait_for_completion: Should this request wait until the
|
||||||
|
operation has completed before returning
|
||||||
|
"""
|
||||||
|
for param in (repository, snapshot):
|
||||||
|
if param in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"PUT",
|
||||||
|
_make_path("_snapshot", repository, snapshot),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
body=body,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("master_timeout")
|
||||||
|
def delete(self, repository, snapshot, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Deletes a snapshot.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html>`_
|
||||||
|
|
||||||
|
:arg repository: A repository name
|
||||||
|
:arg snapshot: A snapshot name
|
||||||
|
:arg master_timeout: Explicit operation timeout for connection
|
||||||
|
to master node
|
||||||
|
"""
|
||||||
|
for param in (repository, snapshot):
|
||||||
|
if param in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"DELETE",
|
||||||
|
_make_path("_snapshot", repository, snapshot),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("ignore_unavailable", "master_timeout", "verbose")
|
||||||
|
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>`_
|
||||||
|
|
||||||
|
:arg repository: A repository name
|
||||||
|
:arg snapshot: A comma-separated list of snapshot names
|
||||||
|
:arg ignore_unavailable: Whether to ignore unavailable
|
||||||
|
snapshots, defaults to false which means a SnapshotMissingException is
|
||||||
|
thrown
|
||||||
|
:arg master_timeout: Explicit operation timeout for connection
|
||||||
|
to master node
|
||||||
|
:arg verbose: Whether to show verbose snapshot info or only show
|
||||||
|
the basic info found in the repository index blob
|
||||||
|
"""
|
||||||
|
for param in (repository, snapshot):
|
||||||
|
if param in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET",
|
||||||
|
_make_path("_snapshot", repository, snapshot),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("master_timeout", "timeout")
|
||||||
|
def delete_repository(self, repository, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Deletes a repository.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html>`_
|
||||||
|
|
||||||
|
:arg repository: A comma-separated list of repository names
|
||||||
|
:arg master_timeout: Explicit operation timeout for connection
|
||||||
|
to master node
|
||||||
|
:arg timeout: Explicit operation timeout
|
||||||
|
"""
|
||||||
|
if repository in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'repository'.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"DELETE",
|
||||||
|
_make_path("_snapshot", repository),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("local", "master_timeout")
|
||||||
|
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>`_
|
||||||
|
|
||||||
|
:arg repository: A comma-separated list of repository names
|
||||||
|
:arg local: Return local information, do not retrieve the state
|
||||||
|
from master node (default: false)
|
||||||
|
:arg master_timeout: Explicit operation timeout for connection
|
||||||
|
to master node
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET", _make_path("_snapshot", repository), params=params, headers=headers
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("master_timeout", "timeout", "verify")
|
||||||
|
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>`_
|
||||||
|
|
||||||
|
:arg repository: A repository name
|
||||||
|
:arg body: The repository definition
|
||||||
|
:arg master_timeout: Explicit operation timeout for connection
|
||||||
|
to master node
|
||||||
|
:arg timeout: Explicit operation timeout
|
||||||
|
:arg verify: Whether to verify the repository after creation
|
||||||
|
"""
|
||||||
|
for param in (repository, body):
|
||||||
|
if param in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"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, headers=None):
|
||||||
|
"""
|
||||||
|
Restores a snapshot.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html>`_
|
||||||
|
|
||||||
|
:arg repository: A repository name
|
||||||
|
:arg snapshot: A snapshot name
|
||||||
|
:arg body: Details of what to restore
|
||||||
|
:arg master_timeout: Explicit operation timeout for connection
|
||||||
|
to master node
|
||||||
|
:arg wait_for_completion: Should this request wait until the
|
||||||
|
operation has completed before returning
|
||||||
|
"""
|
||||||
|
for param in (repository, snapshot):
|
||||||
|
if param in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"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, headers=None):
|
||||||
|
"""
|
||||||
|
Returns information about the status of a snapshot.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html>`_
|
||||||
|
|
||||||
|
:arg repository: A repository name
|
||||||
|
:arg snapshot: A comma-separated list of snapshot names
|
||||||
|
:arg ignore_unavailable: Whether to ignore unavailable
|
||||||
|
snapshots, defaults to false which means a SnapshotMissingException is
|
||||||
|
thrown
|
||||||
|
:arg master_timeout: Explicit operation timeout for connection
|
||||||
|
to master node
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET",
|
||||||
|
_make_path("_snapshot", repository, snapshot, "_status"),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("master_timeout", "timeout")
|
||||||
|
def verify_repository(self, repository, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Verifies a repository.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html>`_
|
||||||
|
|
||||||
|
:arg repository: A repository name
|
||||||
|
:arg master_timeout: Explicit operation timeout for connection
|
||||||
|
to master node
|
||||||
|
:arg timeout: Explicit operation timeout
|
||||||
|
"""
|
||||||
|
if repository in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'repository'.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"POST",
|
||||||
|
_make_path("_snapshot", repository, "_verify"),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("master_timeout", "timeout")
|
||||||
|
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>`_
|
||||||
|
|
||||||
|
:arg repository: A repository name
|
||||||
|
:arg master_timeout: Explicit operation timeout for connection
|
||||||
|
to master node
|
||||||
|
:arg timeout: Explicit operation timeout
|
||||||
|
"""
|
||||||
|
if repository in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'repository'.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"POST",
|
||||||
|
_make_path("_snapshot", repository, "_cleanup"),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
# Licensed to Elasticsearch B.V under one or more agreements.
|
||||||
|
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||||
|
# See the LICENSE file in the project root for more information
|
||||||
|
|
||||||
|
from .utils import NamespacedClient, query_params, SKIP_IN_PATH
|
||||||
|
|
||||||
|
|
||||||
|
class SqlClient(NamespacedClient):
|
||||||
|
@query_params()
|
||||||
|
def clear_cursor(self, body, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Clears the SQL cursor
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/sql-pagination.html>`_
|
||||||
|
|
||||||
|
:arg body: Specify the cursor value in the `cursor` element to
|
||||||
|
clean the cursor.
|
||||||
|
"""
|
||||||
|
if body in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'body'.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"POST", "/_sql/close", params=params, headers=headers, body=body
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("format")
|
||||||
|
def query(self, body, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Executes a SQL request
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/sql-rest-overview.html>`_
|
||||||
|
|
||||||
|
:arg body: Use the `query` element to start a query. Use the
|
||||||
|
`cursor` element to continue a query.
|
||||||
|
:arg format: a short version of the Accept header, e.g. json,
|
||||||
|
yaml
|
||||||
|
"""
|
||||||
|
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, headers=headers, body=body
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def translate(self, body, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Translates SQL into Elasticsearch queries
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/sql-translate.html>`_
|
||||||
|
|
||||||
|
:arg body: Specify the query in the `query` element.
|
||||||
|
"""
|
||||||
|
if body in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'body'.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"POST", "/_sql/translate", params=params, headers=headers, body=body
|
||||||
|
)
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Licensed to Elasticsearch B.V under one or more agreements.
|
||||||
|
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||||
|
# See the LICENSE file in the project root for more information
|
||||||
|
|
||||||
|
from .utils import NamespacedClient, query_params
|
||||||
|
|
||||||
|
|
||||||
|
class SslClient(NamespacedClient):
|
||||||
|
@query_params()
|
||||||
|
def certificates(self, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Retrieves information about the X.509 certificates used to encrypt
|
||||||
|
communications in the cluster.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/security-api-ssl.html>`_
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET", "/_ssl/certificates", params=params, headers=headers
|
||||||
|
)
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
# Licensed to Elasticsearch B.V under one or more agreements.
|
||||||
|
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||||
|
# See the LICENSE file in the project root for more information
|
||||||
|
|
||||||
|
from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH
|
||||||
|
|
||||||
|
|
||||||
|
class TasksClient(NamespacedClient):
|
||||||
|
@query_params(
|
||||||
|
"actions",
|
||||||
|
"detailed",
|
||||||
|
"group_by",
|
||||||
|
"nodes",
|
||||||
|
"parent_task_id",
|
||||||
|
"timeout",
|
||||||
|
"wait_for_completion",
|
||||||
|
)
|
||||||
|
def list(self, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Returns a list of tasks.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html>`_
|
||||||
|
|
||||||
|
:arg actions: A comma-separated list of actions that should be
|
||||||
|
returned. Leave empty to return all.
|
||||||
|
:arg detailed: Return detailed task information (default: false)
|
||||||
|
:arg group_by: Group tasks by nodes or parent/child
|
||||||
|
relationships Valid choices: nodes, parents, none Default: nodes
|
||||||
|
:arg nodes: A comma-separated list of node IDs or names to limit
|
||||||
|
the returned information; use `_local` to return information from the
|
||||||
|
node you're connecting to, leave empty to get information from all nodes
|
||||||
|
:arg parent_task_id: Return tasks with specified parent task id
|
||||||
|
(node_id:task_number). Set to -1 to return all.
|
||||||
|
:arg timeout: Explicit operation timeout
|
||||||
|
:arg wait_for_completion: Wait for the matching tasks to
|
||||||
|
complete (default: false)
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET", "/_tasks", params=params, headers=headers
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("actions", "nodes", "parent_task_id", "wait_for_completion")
|
||||||
|
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>`_
|
||||||
|
|
||||||
|
:arg task_id: Cancel the task with specified task id
|
||||||
|
(node_id:task_number)
|
||||||
|
:arg actions: A comma-separated list of actions that should be
|
||||||
|
cancelled. Leave empty to cancel all.
|
||||||
|
:arg nodes: A comma-separated list of node IDs or names to limit
|
||||||
|
the returned information; use `_local` to return information from the
|
||||||
|
node you're connecting to, leave empty to get information from all nodes
|
||||||
|
:arg parent_task_id: Cancel tasks with specified parent task id
|
||||||
|
(node_id:task_number). Set to -1 to cancel all.
|
||||||
|
:arg wait_for_completion: Should the request block until the
|
||||||
|
cancellation of the task and its descendant tasks is completed. Defaults
|
||||||
|
to false
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"POST",
|
||||||
|
_make_path("_tasks", task_id, "_cancel"),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("timeout", "wait_for_completion")
|
||||||
|
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>`_
|
||||||
|
|
||||||
|
:arg task_id: Return the task with specified id
|
||||||
|
(node_id:task_number)
|
||||||
|
:arg timeout: Explicit operation timeout
|
||||||
|
:arg wait_for_completion: Wait for the matching tasks to
|
||||||
|
complete (default: false)
|
||||||
|
"""
|
||||||
|
if task_id in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'task_id'.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET", _make_path("_tasks", task_id), params=params, headers=headers
|
||||||
|
)
|
||||||
@@ -0,0 +1,208 @@
|
|||||||
|
# Licensed to Elasticsearch B.V under one or more agreements.
|
||||||
|
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||||
|
# See the LICENSE file in the project root for more information
|
||||||
|
|
||||||
|
from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH
|
||||||
|
|
||||||
|
|
||||||
|
class TransformClient(NamespacedClient):
|
||||||
|
@query_params("force")
|
||||||
|
def delete_transform(self, transform_id, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Deletes an existing transform.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-transform.html>`_
|
||||||
|
|
||||||
|
:arg transform_id: The id of the transform to delete
|
||||||
|
:arg force: When `true`, the transform is deleted regardless of
|
||||||
|
its current state. The default value is `false`, meaning that the
|
||||||
|
transform must be `stopped` before it can be deleted.
|
||||||
|
"""
|
||||||
|
if transform_id in SKIP_IN_PATH:
|
||||||
|
raise ValueError(
|
||||||
|
"Empty value passed for a required argument 'transform_id'."
|
||||||
|
)
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"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, headers=None):
|
||||||
|
"""
|
||||||
|
Retrieves configuration information for transforms.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/get-transform.html>`_
|
||||||
|
|
||||||
|
:arg transform_id: The id or comma delimited list of id
|
||||||
|
expressions of the transforms to get, '_all' or '*' implies get all
|
||||||
|
transforms
|
||||||
|
:arg allow_no_match: Whether to ignore if a wildcard expression
|
||||||
|
matches no transforms. (This includes `_all` string or when no
|
||||||
|
transforms have been specified)
|
||||||
|
:arg from\\_: skips a number of transform configs, defaults to 0
|
||||||
|
:arg size: specifies a max number of transforms to get, defaults
|
||||||
|
to 100
|
||||||
|
"""
|
||||||
|
# from is a reserved word so it cannot be used, use from_ instead
|
||||||
|
if "from_" in params:
|
||||||
|
params["from"] = params.pop("from_")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET",
|
||||||
|
_make_path("_transform", transform_id),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("allow_no_match", "from_", "size")
|
||||||
|
def get_transform_stats(self, transform_id, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Retrieves usage information for transforms.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/get-transform-stats.html>`_
|
||||||
|
|
||||||
|
:arg transform_id: The id of the transform for which to get
|
||||||
|
stats. '_all' or '*' implies all transforms
|
||||||
|
:arg allow_no_match: Whether to ignore if a wildcard expression
|
||||||
|
matches no transforms. (This includes `_all` string or when no
|
||||||
|
transforms have been specified)
|
||||||
|
:arg from\\_: skips a number of transform stats, defaults to 0
|
||||||
|
:arg size: specifies a max number of transform stats to get,
|
||||||
|
defaults to 100
|
||||||
|
"""
|
||||||
|
# from is a reserved word so it cannot be used, use from_ instead
|
||||||
|
if "from_" in params:
|
||||||
|
params["from"] = params.pop("from_")
|
||||||
|
|
||||||
|
if transform_id in SKIP_IN_PATH:
|
||||||
|
raise ValueError(
|
||||||
|
"Empty value passed for a required argument 'transform_id'."
|
||||||
|
)
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET",
|
||||||
|
_make_path("_transform", transform_id, "_stats"),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def preview_transform(self, body, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Previews a transform.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/preview-transform.html>`_
|
||||||
|
|
||||||
|
:arg body: The definition for the transform to preview
|
||||||
|
"""
|
||||||
|
if body in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'body'.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"POST", "/_transform/_preview", params=params, headers=headers, body=body
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("defer_validation")
|
||||||
|
def put_transform(self, transform_id, body, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Instantiates a transform.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/put-transform.html>`_
|
||||||
|
|
||||||
|
:arg transform_id: The id of the new transform.
|
||||||
|
:arg body: The transform definition
|
||||||
|
:arg defer_validation: If validations should be deferred until
|
||||||
|
transform starts, defaults to false.
|
||||||
|
"""
|
||||||
|
for param in (transform_id, body):
|
||||||
|
if param in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"PUT",
|
||||||
|
_make_path("_transform", transform_id),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
body=body,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("timeout")
|
||||||
|
def start_transform(self, transform_id, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Starts one or more transforms.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/start-transform.html>`_
|
||||||
|
|
||||||
|
:arg transform_id: The id of the transform to start
|
||||||
|
:arg timeout: Controls the time to wait for the transform to
|
||||||
|
start
|
||||||
|
"""
|
||||||
|
if transform_id in SKIP_IN_PATH:
|
||||||
|
raise ValueError(
|
||||||
|
"Empty value passed for a required argument 'transform_id'."
|
||||||
|
)
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"POST",
|
||||||
|
_make_path("_transform", transform_id, "_start"),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params(
|
||||||
|
"allow_no_match",
|
||||||
|
"force",
|
||||||
|
"timeout",
|
||||||
|
"wait_for_checkpoint",
|
||||||
|
"wait_for_completion",
|
||||||
|
)
|
||||||
|
def stop_transform(self, transform_id, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Stops one or more transforms.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/stop-transform.html>`_
|
||||||
|
|
||||||
|
:arg transform_id: The id of the transform to stop
|
||||||
|
:arg allow_no_match: Whether to ignore if a wildcard expression
|
||||||
|
matches no transforms. (This includes `_all` string or when no
|
||||||
|
transforms have been specified)
|
||||||
|
:arg force: Whether to force stop a failed transform or not.
|
||||||
|
Default to false
|
||||||
|
:arg timeout: Controls the time to wait until the transform has
|
||||||
|
stopped. Default to 30 seconds
|
||||||
|
:arg wait_for_checkpoint: Whether to wait for the transform to
|
||||||
|
reach a checkpoint before stopping. Default to false
|
||||||
|
:arg wait_for_completion: Whether to wait for the transform to
|
||||||
|
fully stop before returning or not. Default to false
|
||||||
|
"""
|
||||||
|
if transform_id in SKIP_IN_PATH:
|
||||||
|
raise ValueError(
|
||||||
|
"Empty value passed for a required argument 'transform_id'."
|
||||||
|
)
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"POST",
|
||||||
|
_make_path("_transform", transform_id, "_stop"),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("defer_validation")
|
||||||
|
def update_transform(self, transform_id, body, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Updates certain properties of a transform.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/update-transform.html>`_
|
||||||
|
|
||||||
|
:arg transform_id: The id of the transform.
|
||||||
|
:arg body: The update transform definition
|
||||||
|
:arg defer_validation: If validations should be deferred until
|
||||||
|
transform starts, defaults to false.
|
||||||
|
"""
|
||||||
|
for param in (transform_id, body):
|
||||||
|
if param in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"POST",
|
||||||
|
_make_path("_transform", transform_id, "_update"),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
body=body,
|
||||||
|
)
|
||||||
@@ -0,0 +1,130 @@
|
|||||||
|
# Licensed to Elasticsearch B.V under one or more agreements.
|
||||||
|
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||||
|
# See the LICENSE file in the project root for more information
|
||||||
|
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import weakref
|
||||||
|
from datetime import date, datetime
|
||||||
|
from functools import wraps
|
||||||
|
from ..compat import string_types, quote, PY2
|
||||||
|
|
||||||
|
# parts of URL to be omitted
|
||||||
|
SKIP_IN_PATH = (None, "", b"", [], ())
|
||||||
|
|
||||||
|
|
||||||
|
def _escape(value):
|
||||||
|
"""
|
||||||
|
Escape a single value of a URL string or a query parameter. If it is a list
|
||||||
|
or tuple, turn it into a comma-separated string first.
|
||||||
|
"""
|
||||||
|
|
||||||
|
# make sequences into comma-separated stings
|
||||||
|
if isinstance(value, (list, tuple)):
|
||||||
|
value = ",".join(value)
|
||||||
|
|
||||||
|
# dates and datetimes into isoformat
|
||||||
|
elif isinstance(value, (date, datetime)):
|
||||||
|
value = value.isoformat()
|
||||||
|
|
||||||
|
# make bools into true/false strings
|
||||||
|
elif isinstance(value, bool):
|
||||||
|
value = str(value).lower()
|
||||||
|
|
||||||
|
# don't decode bytestrings
|
||||||
|
elif isinstance(value, bytes):
|
||||||
|
return value
|
||||||
|
|
||||||
|
# encode strings to utf-8
|
||||||
|
if isinstance(value, string_types):
|
||||||
|
if PY2 and isinstance(value, unicode): # noqa: F821
|
||||||
|
return value.encode("utf-8")
|
||||||
|
if not PY2 and isinstance(value, str):
|
||||||
|
return value.encode("utf-8")
|
||||||
|
|
||||||
|
return str(value)
|
||||||
|
|
||||||
|
|
||||||
|
def _make_path(*parts):
|
||||||
|
"""
|
||||||
|
Create a URL string from parts, omit all `None` values and empty strings.
|
||||||
|
Convert lists and tuples to comma separated values.
|
||||||
|
"""
|
||||||
|
# TODO: maybe only allow some parts to be lists/tuples ?
|
||||||
|
return "/" + "/".join(
|
||||||
|
# preserve ',' and '*' in url for nicer URLs in logs
|
||||||
|
quote(_escape(p), b",*")
|
||||||
|
for p in parts
|
||||||
|
if p not in SKIP_IN_PATH
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# parameters that apply to all methods
|
||||||
|
GLOBAL_PARAMS = ("pretty", "human", "error_trace", "format", "filter_path")
|
||||||
|
|
||||||
|
|
||||||
|
def query_params(*es_query_params):
|
||||||
|
"""
|
||||||
|
Decorator that pops all accepted parameters from method's kwargs and puts
|
||||||
|
them in the params argument.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def _wrapper(func):
|
||||||
|
@wraps(func)
|
||||||
|
def _wrapped(*args, **kwargs):
|
||||||
|
params = (kwargs.pop("params", None) or {}).copy()
|
||||||
|
headers = {
|
||||||
|
k.lower(): v
|
||||||
|
for k, v in (kwargs.pop("headers", None) or {}).copy().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, 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, headers=headers, **kwargs)
|
||||||
|
|
||||||
|
return _wrapped
|
||||||
|
|
||||||
|
return _wrapper
|
||||||
|
|
||||||
|
|
||||||
|
def _bulk_body(serializer, body):
|
||||||
|
# if not passed in a string, serialize items and join by newline
|
||||||
|
if not isinstance(body, string_types):
|
||||||
|
body = "\n".join(map(serializer.dumps, body))
|
||||||
|
|
||||||
|
# bulk body must end with a newline
|
||||||
|
if isinstance(body, bytes):
|
||||||
|
if not body.endswith(b"\n"):
|
||||||
|
body += b"\n"
|
||||||
|
elif isinstance(body, string_types) and not body.endswith("\n"):
|
||||||
|
body += "\n"
|
||||||
|
|
||||||
|
return body
|
||||||
|
|
||||||
|
|
||||||
|
class NamespacedClient(object):
|
||||||
|
def __init__(self, client):
|
||||||
|
self.client = client
|
||||||
|
|
||||||
|
@property
|
||||||
|
def transport(self):
|
||||||
|
return self.client.transport
|
||||||
|
|
||||||
|
|
||||||
|
class AddonClient(NamespacedClient):
|
||||||
|
@classmethod
|
||||||
|
def infect_client(cls, client):
|
||||||
|
addon = cls(weakref.proxy(client))
|
||||||
|
setattr(client, cls.namespace, addon)
|
||||||
|
return client
|
||||||
@@ -0,0 +1,180 @@
|
|||||||
|
# Licensed to Elasticsearch B.V under one or more agreements.
|
||||||
|
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||||
|
# See the LICENSE file in the project root for more information
|
||||||
|
|
||||||
|
from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH
|
||||||
|
|
||||||
|
|
||||||
|
class WatcherClient(NamespacedClient):
|
||||||
|
@query_params()
|
||||||
|
def ack_watch(self, watch_id, action_id=None, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Acknowledges a watch, manually throttling the execution of the watch's actions.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/watcher-api-ack-watch.html>`_
|
||||||
|
|
||||||
|
:arg watch_id: Watch ID
|
||||||
|
:arg action_id: A comma-separated list of the action ids to be
|
||||||
|
acked
|
||||||
|
"""
|
||||||
|
if watch_id in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'watch_id'.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"PUT",
|
||||||
|
_make_path("_watcher", "watch", watch_id, "_ack", action_id),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def activate_watch(self, watch_id, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Activates a currently inactive watch.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/watcher-api-activate-watch.html>`_
|
||||||
|
|
||||||
|
:arg watch_id: Watch ID
|
||||||
|
"""
|
||||||
|
if watch_id in SKIP_IN_PATH:
|
||||||
|
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,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def deactivate_watch(self, watch_id, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Deactivates a currently active watch.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/watcher-api-deactivate-watch.html>`_
|
||||||
|
|
||||||
|
:arg watch_id: Watch ID
|
||||||
|
"""
|
||||||
|
if watch_id in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'watch_id'.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"PUT",
|
||||||
|
_make_path("_watcher", "watch", watch_id, "_deactivate"),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def delete_watch(self, id, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Removes a watch from Watcher.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/watcher-api-delete-watch.html>`_
|
||||||
|
|
||||||
|
:arg id: Watch ID
|
||||||
|
"""
|
||||||
|
if id in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'id'.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"DELETE",
|
||||||
|
_make_path("_watcher", "watch", id),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("debug")
|
||||||
|
def execute_watch(self, body=None, id=None, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Forces the execution of a stored watch.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/watcher-api-execute-watch.html>`_
|
||||||
|
|
||||||
|
:arg body: Execution control
|
||||||
|
:arg id: Watch ID
|
||||||
|
:arg debug: indicates whether the watch should execute in debug
|
||||||
|
mode
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"PUT",
|
||||||
|
_make_path("_watcher", "watch", id, "_execute"),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
body=body,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def get_watch(self, id, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Retrieves a watch by its ID.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/watcher-api-get-watch.html>`_
|
||||||
|
|
||||||
|
:arg id: Watch ID
|
||||||
|
"""
|
||||||
|
if id in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'id'.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"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, headers=None):
|
||||||
|
"""
|
||||||
|
Creates a new watch, or updates an existing one.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/watcher-api-put-watch.html>`_
|
||||||
|
|
||||||
|
:arg id: Watch ID
|
||||||
|
:arg body: The watch
|
||||||
|
:arg active: Specify whether the watch is in/active by default
|
||||||
|
:arg if_primary_term: only update the watch if the last
|
||||||
|
operation that has changed the watch has the specified primary term
|
||||||
|
:arg if_seq_no: only update the watch if the last operation that
|
||||||
|
has changed the watch has the specified sequence number
|
||||||
|
:arg version: Explicit version number for concurrency control
|
||||||
|
"""
|
||||||
|
if id in SKIP_IN_PATH:
|
||||||
|
raise ValueError("Empty value passed for a required argument 'id'.")
|
||||||
|
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"PUT",
|
||||||
|
_make_path("_watcher", "watch", id),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
body=body,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def start(self, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Starts Watcher if it is not already running.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/watcher-api-start.html>`_
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"POST", "/_watcher/_start", params=params, headers=headers
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("emit_stacktraces")
|
||||||
|
def stats(self, metric=None, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Retrieves the current Watcher metrics.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/watcher-api-stats.html>`_
|
||||||
|
|
||||||
|
:arg metric: Controls what additional stat metrics should be
|
||||||
|
include in the response Valid choices: _all, queued_watches,
|
||||||
|
current_watches, pending_watches
|
||||||
|
:arg emit_stacktraces: Emits stack traces of currently running
|
||||||
|
watches
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET",
|
||||||
|
_make_path("_watcher", "stats", metric),
|
||||||
|
params=params,
|
||||||
|
headers=headers,
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params()
|
||||||
|
def stop(self, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Stops Watcher if it is running.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/watcher-api-stop.html>`_
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"POST", "/_watcher/_stop", params=params, headers=headers
|
||||||
|
)
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
# Licensed to Elasticsearch B.V under one or more agreements.
|
||||||
|
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
|
||||||
|
# See the LICENSE file in the project root for more information
|
||||||
|
|
||||||
|
from .utils import NamespacedClient, query_params
|
||||||
|
|
||||||
|
|
||||||
|
class XPackClient(NamespacedClient):
|
||||||
|
def __getattr__(self, attr_name):
|
||||||
|
return getattr(self.client, attr_name)
|
||||||
|
|
||||||
|
# AUTO-GENERATED-API-DEFINITIONS #
|
||||||
|
@query_params("categories")
|
||||||
|
def info(self, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Retrieves information about the installed X-Pack features.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/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, headers=headers
|
||||||
|
)
|
||||||
|
|
||||||
|
@query_params("master_timeout")
|
||||||
|
def usage(self, params=None, headers=None):
|
||||||
|
"""
|
||||||
|
Retrieves usage information about the installed X-Pack features.
|
||||||
|
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/usage-api.html>`_
|
||||||
|
|
||||||
|
:arg master_timeout: Specify timeout for watch write operation
|
||||||
|
"""
|
||||||
|
return self.transport.perform_request(
|
||||||
|
"GET", "/_xpack/usage", params=params, headers=headers
|
||||||
|
)
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
# See the LICENSE file in the project root for more information
|
# See the LICENSE file in the project root for more information
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
from ..compat import * # noqa
|
||||||
|
|
||||||
# Hack supporting Python 3.6 asyncio which didn't have 'get_running_loop()'.
|
# Hack supporting Python 3.6 asyncio which didn't have 'get_running_loop()'.
|
||||||
# Essentially we want to get away from having users pass in a loop to us.
|
# Essentially we want to get away from having users pass in a loop to us.
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ from .remote import RemoteClient
|
|||||||
from .snapshot import SnapshotClient
|
from .snapshot import SnapshotClient
|
||||||
from .tasks import TasksClient
|
from .tasks import TasksClient
|
||||||
from .xpack import XPackClient
|
from .xpack import XPackClient
|
||||||
from .utils import query_params, _make_path, SKIP_IN_PATH, _bulk_body
|
from .utils import query_params, _make_path, SKIP_IN_PATH, _bulk_body, _normalize_hosts
|
||||||
|
|
||||||
# xpack APIs
|
# xpack APIs
|
||||||
from .async_search import AsyncSearchClient
|
from .async_search import AsyncSearchClient
|
||||||
@@ -47,51 +47,6 @@ from .transform import TransformClient
|
|||||||
logger = logging.getLogger("elasticsearch")
|
logger = logging.getLogger("elasticsearch")
|
||||||
|
|
||||||
|
|
||||||
def _normalize_hosts(hosts):
|
|
||||||
"""
|
|
||||||
Helper function to transform hosts argument to
|
|
||||||
:class:`~elasticsearch.Elasticsearch` to a list of dicts.
|
|
||||||
"""
|
|
||||||
# if hosts are empty, just defer to defaults down the line
|
|
||||||
if hosts is None:
|
|
||||||
return [{}]
|
|
||||||
|
|
||||||
# passed in just one string
|
|
||||||
if isinstance(hosts, string_types):
|
|
||||||
hosts = [hosts]
|
|
||||||
|
|
||||||
out = []
|
|
||||||
# normalize hosts to dicts
|
|
||||||
for host in hosts:
|
|
||||||
if isinstance(host, string_types):
|
|
||||||
if "://" not in host:
|
|
||||||
host = "//%s" % host
|
|
||||||
|
|
||||||
parsed_url = urlparse(host)
|
|
||||||
h = {"host": parsed_url.hostname}
|
|
||||||
|
|
||||||
if parsed_url.port:
|
|
||||||
h["port"] = parsed_url.port
|
|
||||||
|
|
||||||
if parsed_url.scheme == "https":
|
|
||||||
h["port"] = parsed_url.port or 443
|
|
||||||
h["use_ssl"] = True
|
|
||||||
|
|
||||||
if parsed_url.username or parsed_url.password:
|
|
||||||
h["http_auth"] = "%s:%s" % (
|
|
||||||
unquote(parsed_url.username),
|
|
||||||
unquote(parsed_url.password),
|
|
||||||
)
|
|
||||||
|
|
||||||
if parsed_url.path and parsed_url.path != "/":
|
|
||||||
h["url_prefix"] = parsed_url.path
|
|
||||||
|
|
||||||
out.append(h)
|
|
||||||
else:
|
|
||||||
out.append(host)
|
|
||||||
return out
|
|
||||||
|
|
||||||
|
|
||||||
class Elasticsearch(object):
|
class Elasticsearch(object):
|
||||||
"""
|
"""
|
||||||
Elasticsearch low-level client. Provides a straightforward mapping from
|
Elasticsearch low-level client. Provides a straightforward mapping from
|
||||||
@@ -280,6 +235,17 @@ class Elasticsearch(object):
|
|||||||
# probably operating on custom transport and connection_pool, ignore
|
# probably operating on custom transport and connection_pool, ignore
|
||||||
return super(Elasticsearch, self).__repr__()
|
return super(Elasticsearch, self).__repr__()
|
||||||
|
|
||||||
|
def __enter__(self):
|
||||||
|
if hasattr(self.transport, "_async_call"):
|
||||||
|
self.transport._async_call()
|
||||||
|
return self
|
||||||
|
|
||||||
|
def __exit__(self, *_):
|
||||||
|
self.close()
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
self.transport.close()
|
||||||
|
|
||||||
# AUTO-GENERATED-API-DEFINITIONS #
|
# AUTO-GENERATED-API-DEFINITIONS #
|
||||||
@query_params()
|
@query_params()
|
||||||
def ping(self, params=None, headers=None):
|
def ping(self, params=None, headers=None):
|
||||||
|
|||||||
@@ -7,12 +7,57 @@ from __future__ import unicode_literals
|
|||||||
import weakref
|
import weakref
|
||||||
from datetime import date, datetime
|
from datetime import date, datetime
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
from ..compat import string_types, quote, PY2
|
from ..compat import string_types, quote, PY2, unquote, urlparse
|
||||||
|
|
||||||
# parts of URL to be omitted
|
# parts of URL to be omitted
|
||||||
SKIP_IN_PATH = (None, "", b"", [], ())
|
SKIP_IN_PATH = (None, "", b"", [], ())
|
||||||
|
|
||||||
|
|
||||||
|
def _normalize_hosts(hosts):
|
||||||
|
"""
|
||||||
|
Helper function to transform hosts argument to
|
||||||
|
:class:`~elasticsearch.Elasticsearch` to a list of dicts.
|
||||||
|
"""
|
||||||
|
# if hosts are empty, just defer to defaults down the line
|
||||||
|
if hosts is None:
|
||||||
|
return [{}]
|
||||||
|
|
||||||
|
# passed in just one string
|
||||||
|
if isinstance(hosts, string_types):
|
||||||
|
hosts = [hosts]
|
||||||
|
|
||||||
|
out = []
|
||||||
|
# normalize hosts to dicts
|
||||||
|
for host in hosts:
|
||||||
|
if isinstance(host, string_types):
|
||||||
|
if "://" not in host:
|
||||||
|
host = "//%s" % host
|
||||||
|
|
||||||
|
parsed_url = urlparse(host)
|
||||||
|
h = {"host": parsed_url.hostname}
|
||||||
|
|
||||||
|
if parsed_url.port:
|
||||||
|
h["port"] = parsed_url.port
|
||||||
|
|
||||||
|
if parsed_url.scheme == "https":
|
||||||
|
h["port"] = parsed_url.port or 443
|
||||||
|
h["use_ssl"] = True
|
||||||
|
|
||||||
|
if parsed_url.username or parsed_url.password:
|
||||||
|
h["http_auth"] = "%s:%s" % (
|
||||||
|
unquote(parsed_url.username),
|
||||||
|
unquote(parsed_url.password),
|
||||||
|
)
|
||||||
|
|
||||||
|
if parsed_url.path and parsed_url.path != "/":
|
||||||
|
h["url_prefix"] = parsed_url.path
|
||||||
|
|
||||||
|
out.append(h)
|
||||||
|
else:
|
||||||
|
out.append(host)
|
||||||
|
return out
|
||||||
|
|
||||||
|
|
||||||
def _escape(value):
|
def _escape(value):
|
||||||
"""
|
"""
|
||||||
Escape a single value of a URL string or a query parameter. If it is a list
|
Escape a single value of a URL string or a query parameter. If it is a list
|
||||||
|
|||||||
+35
-7
@@ -15,6 +15,7 @@ from click.testing import CliRunner
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from jinja2 import Environment, FileSystemLoader, TemplateNotFound
|
from jinja2 import Environment, FileSystemLoader, TemplateNotFound
|
||||||
|
import unasync
|
||||||
|
|
||||||
|
|
||||||
http = urllib3.PoolManager()
|
http = urllib3.PoolManager()
|
||||||
@@ -78,9 +79,8 @@ class Module:
|
|||||||
def parse_orig(self):
|
def parse_orig(self):
|
||||||
self.orders = []
|
self.orders = []
|
||||||
self.header = "class C:"
|
self.header = "class C:"
|
||||||
fname = CODE_ROOT / "elasticsearch" / "client" / f"{self.namespace}.py"
|
if os.path.exists(self.filepath):
|
||||||
if os.path.exists(fname):
|
with open(self.filepath) as f:
|
||||||
with open(fname) as f:
|
|
||||||
content = f.read()
|
content = f.read()
|
||||||
header_lines = []
|
header_lines = []
|
||||||
for line in content.split("\n"):
|
for line in content.split("\n"):
|
||||||
@@ -96,7 +96,7 @@ class Module:
|
|||||||
break
|
break
|
||||||
self.header = "\n".join(header_lines)
|
self.header = "\n".join(header_lines)
|
||||||
self.orders = re.findall(
|
self.orders = re.findall(
|
||||||
r'\n def ([a-z_]+)\(',
|
r'\n (?:async )?def ([a-z_]+)\(',
|
||||||
content,
|
content,
|
||||||
re.MULTILINE
|
re.MULTILINE
|
||||||
)
|
)
|
||||||
@@ -112,12 +112,15 @@ class Module:
|
|||||||
|
|
||||||
def dump(self):
|
def dump(self):
|
||||||
self.sort()
|
self.sort()
|
||||||
fname = CODE_ROOT / "elasticsearch" / "client" / f"{self.namespace}.py"
|
with open(self.filepath, "w") as f:
|
||||||
with open(fname, "w") as f:
|
|
||||||
f.write(self.header)
|
f.write(self.header)
|
||||||
for api in self._apis:
|
for api in self._apis:
|
||||||
f.write(api.to_python())
|
f.write(api.to_python())
|
||||||
blacken(fname)
|
blacken(self.filepath)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def filepath(self):
|
||||||
|
return CODE_ROOT / f"elasticsearch/_async/client/{self.namespace}.py"
|
||||||
|
|
||||||
|
|
||||||
class API:
|
class API:
|
||||||
@@ -305,6 +308,31 @@ def dump_modules(modules):
|
|||||||
for mod in modules.values():
|
for mod in modules.values():
|
||||||
mod.dump()
|
mod.dump()
|
||||||
|
|
||||||
|
# Unasync all the generated async code
|
||||||
|
additional_replacements = {
|
||||||
|
# We want to rewrite to 'Transport' instead of 'SyncTransport', etc
|
||||||
|
"AsyncTransport": "Transport",
|
||||||
|
"AsyncElasticsearch": "Elasticsearch",
|
||||||
|
# We don't want to rewrite this class
|
||||||
|
"AsyncSearchClient": "AsyncSearchClient",
|
||||||
|
}
|
||||||
|
rules = [
|
||||||
|
unasync.Rule(
|
||||||
|
fromdir="/elasticsearch/_async/client/",
|
||||||
|
todir="/elasticsearch/client/",
|
||||||
|
additional_replacements=additional_replacements
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
||||||
|
filepaths = []
|
||||||
|
for root, _, filenames in os.walk(CODE_ROOT / "elasticsearch/_async"):
|
||||||
|
for filename in filenames:
|
||||||
|
if filename.endswith(".py") and filename != "utils.py":
|
||||||
|
filepaths.append(os.path.join(root, filename))
|
||||||
|
|
||||||
|
unasync.unasync_files(filepaths, rules)
|
||||||
|
blacken(CODE_ROOT / "elasticsearch")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
dump_modules(read_modules())
|
dump_modules(read_modules())
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
@query_params({{ api.query_params|map("tojson")|join(", ")}})
|
@query_params({{ api.query_params|map("tojson")|join(", ")}})
|
||||||
def {{ api.name }}(self, {% include "func_params" %}):
|
async def {{ api.name }}(self, {% include "func_params" %}):
|
||||||
"""
|
"""
|
||||||
{% if api.description %}
|
{% if api.description %}
|
||||||
{{ api.description|replace("\n", " ")|wordwrap(wrapstring="\n ") }}
|
{{ api.description|replace("\n", " ")|wordwrap(wrapstring="\n ") }}
|
||||||
@@ -24,6 +24,6 @@
|
|||||||
body = _bulk_body(self.transport.serializer, body)
|
body = _bulk_body(self.transport.serializer, body)
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% block request %}
|
{% block request %}
|
||||||
return self.transport.perform_request("{{ api.method }}", {% include "url" %}, params=params, headers=headers{% if api.body %}, body=body{% endif %})
|
return await self.transport.perform_request("{{ api.method }}", {% include "url" %}, params=params, headers=headers{% if api.body %}, body=body{% endif %})
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,6 @@
|
|||||||
elif scroll_id:
|
elif scroll_id:
|
||||||
params["scroll_id"] = scroll_id
|
params["scroll_id"] = scroll_id
|
||||||
|
|
||||||
return self.transport.perform_request("{{ api.method }}", "/_search/scroll", params=params, headers=headers, body=body)
|
return await self.transport.perform_request("{{ api.method }}", "/_search/scroll", params=params, headers=headers, body=body)
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,6 @@
|
|||||||
doc_type = "_doc"
|
doc_type = "_doc"
|
||||||
|
|
||||||
|
|
||||||
return self.transport.perform_request("POST" if id in SKIP_IN_PATH else "PUT", {% include "url" %}, params=params, headers=headers, body=body)
|
return await self.transport.perform_request("POST" if id in SKIP_IN_PATH else "PUT", {% include "url" %}, params=params, headers=headers, body=body)
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,6 @@
|
|||||||
elif scroll_id:
|
elif scroll_id:
|
||||||
params["scroll_id"] = scroll_id
|
params["scroll_id"] = scroll_id
|
||||||
|
|
||||||
return self.transport.perform_request("{{ api.method }}", "/_search/scroll", params=params, headers=headers, body=body)
|
return await self.transport.perform_request("{{ api.method }}", "/_search/scroll", params=params, headers=headers, body=body)
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{% extends "base" %}
|
{% extends "base" %}
|
||||||
{% block request %}
|
{% 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, headers=headers)
|
return await 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%}
|
{% endblock%}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user