Skip to content

Commit b639369

Browse files
committed
update xpack apis
1 parent c4b4bcc commit b639369

File tree

15 files changed

+1286
-387
lines changed

15 files changed

+1286
-387
lines changed

elasticsearch/client/xpack/__init__.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
from elasticsearch.client.utils import NamespacedClient, query_params
1+
from ..utils import NamespacedClient, query_params
22

33
from .graph import GraphClient
44
from .license import LicenseClient
5+
from .migration import MigrationClient
6+
from .ml import MlClient
57
from .monitoring import MonitoringClient
8+
from .rollup import RollupClient
69
from .security import SecurityClient
10+
from .sql import SqlClient
11+
from .ssl import SslClient
712
from .watcher import WatcherClient
8-
from .ml import MlClient
9-
from .migration import MigrationClient
1013
from .deprecation import DeprecationClient
1114

1215

@@ -17,11 +20,14 @@ def __init__(self, *args, **kwargs):
1720
super(XPackClient, self).__init__(*args, **kwargs)
1821
self.graph = GraphClient(self.client)
1922
self.license = LicenseClient(self.client)
23+
self.migration = MigrationClient(self.client)
24+
self.ml = MlClient(self.client)
2025
self.monitoring = MonitoringClient(self.client)
26+
self.rollup = RollupClient(self.client)
2127
self.security = SecurityClient(self.client)
28+
self.sql = SqlClient(self.client)
29+
self.ssl = SslClient(self.client)
2230
self.watcher = WatcherClient(self.client)
23-
self.ml = MlClient(self.client)
24-
self.migration = MigrationClient(self.client)
2531
self.deprecation = DeprecationClient(self.client)
2632

2733
@query_params("categories", "human")

elasticsearch/client/xpack/ccr.py

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
from ..utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH
2+
3+
4+
class CcrClient(NamespacedClient):
5+
@query_params()
6+
def delete_auto_follow_pattern(self, name, params=None):
7+
"""
8+
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-delete-auto-follow-pattern.html>`_
9+
10+
:arg name: The name of the auto follow pattern.
11+
"""
12+
if name in SKIP_IN_PATH:
13+
raise ValueError("Empty value passed for a required argument 'name'.")
14+
return self.transport.perform_request(
15+
"DELETE", _make_path("_ccr", "auto_follow", name), params=params
16+
)
17+
18+
@query_params("wait_for_active_shards")
19+
def follow(self, index, body, params=None):
20+
"""
21+
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-follow.html>`_
22+
23+
:arg index: The name of the follower index
24+
:arg body: The name of the leader index and other optional ccr related
25+
parameters
26+
:arg wait_for_active_shards: Sets the number of shard copies that must
27+
be active before returning. Defaults to 0. Set to `all` for all
28+
shard copies, otherwise set to any non-negative value less than or
29+
equal to the total number of copies for the shard (number of
30+
replicas + 1), default '0'
31+
"""
32+
for param in (index, body):
33+
if param in SKIP_IN_PATH:
34+
raise ValueError("Empty value passed for a required argument.")
35+
return self.transport.perform_request(
36+
"PUT", _make_path(index, "_ccr", "follow"), params=params, body=body
37+
)
38+
39+
@query_params()
40+
def follow_info(self, index=None, params=None):
41+
"""
42+
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-follow-info.html>`_
43+
44+
:arg index: A comma-separated list of index patterns; use `_all` to
45+
perform the operation on all indices
46+
"""
47+
return self.transport.perform_request(
48+
"GET", _make_path(index, "_ccr", "info"), params=params
49+
)
50+
51+
@query_params()
52+
def follow_stats(self, index=None, params=None):
53+
"""
54+
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-follow-stats.html>`_
55+
56+
:arg index: A comma-separated list of index patterns; use `_all` to
57+
perform the operation on all indices
58+
"""
59+
return self.transport.perform_request(
60+
"GET", _make_path(index, "_ccr", "stats"), params=params
61+
)
62+
63+
@query_params()
64+
def forget_follower(self, index, body, params=None):
65+
"""
66+
`<http://www.elastic.co/guide/en/elasticsearch/reference/current>`_
67+
68+
:arg index: the name of the leader index for which specified follower
69+
retention leases should be removed
70+
:arg body: the name and UUID of the follower index, the name of the
71+
cluster containing the follower index, and the alias from the
72+
perspective of that cluster for the remote cluster containing the
73+
leader index
74+
"""
75+
for param in (index, body):
76+
if param in SKIP_IN_PATH:
77+
raise ValueError("Empty value passed for a required argument.")
78+
return self.transport.perform_request(
79+
"POST",
80+
_make_path(index, "_ccr", "forget_follower"),
81+
params=params,
82+
body=body,
83+
)
84+
85+
@query_params()
86+
def get_auto_follow_pattern(self, name=None, params=None):
87+
"""
88+
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-auto-follow-pattern.html>`_
89+
90+
:arg name: The name of the auto follow pattern.
91+
"""
92+
return self.transport.perform_request(
93+
"GET", _make_path("_ccr", "auto_follow", name), params=params
94+
)
95+
96+
@query_params()
97+
def pause_follow(self, index, params=None):
98+
"""
99+
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-pause-follow.html>`_
100+
101+
:arg index: The name of the follower index that should pause following
102+
its leader index.
103+
"""
104+
if index in SKIP_IN_PATH:
105+
raise ValueError("Empty value passed for a required argument 'index'.")
106+
return self.transport.perform_request(
107+
"POST", _make_path(index, "_ccr", "pause_follow"), params=params
108+
)
109+
110+
@query_params()
111+
def put_auto_follow_pattern(self, name, body, params=None):
112+
"""
113+
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-auto-follow-pattern.html>`_
114+
115+
:arg name: The name of the auto follow pattern.
116+
:arg body: The specification of the auto follow pattern
117+
"""
118+
for param in (name, body):
119+
if param in SKIP_IN_PATH:
120+
raise ValueError("Empty value passed for a required argument.")
121+
return self.transport.perform_request(
122+
"PUT", _make_path("_ccr", "auto_follow", name), params=params, body=body
123+
)
124+
125+
@query_params()
126+
def resume_follow(self, index, body=None, params=None):
127+
"""
128+
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-resume-follow.html>`_
129+
130+
:arg index: The name of the follow index to resume following.
131+
:arg body: The name of the leader index and other optional ccr related
132+
parameters
133+
"""
134+
if index in SKIP_IN_PATH:
135+
raise ValueError("Empty value passed for a required argument 'index'.")
136+
return self.transport.perform_request(
137+
"POST", _make_path(index, "_ccr", "resume_follow"), params=params, body=body
138+
)
139+
140+
@query_params()
141+
def stats(self, params=None):
142+
"""
143+
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-stats.html>`_
144+
"""
145+
return self.transport.perform_request("GET", "/_ccr/stats", params=params)
146+
147+
@query_params()
148+
def unfollow(self, index, params=None):
149+
"""
150+
`<http://www.elastic.co/guide/en/elasticsearch/reference/current>`_
151+
152+
:arg index: The name of the follower index that should be turned into a
153+
regular index.
154+
"""
155+
if index in SKIP_IN_PATH:
156+
raise ValueError("Empty value passed for a required argument 'index'.")
157+
return self.transport.perform_request(
158+
"POST", _make_path(index, "_ccr", "unfollow"), params=params
159+
)

elasticsearch/client/xpack/deprecation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from elasticsearch.client.utils import NamespacedClient, query_params, _make_path
1+
from ..utils import NamespacedClient, query_params, _make_path
22

33

44
class DeprecationClient(NamespacedClient):

elasticsearch/client/xpack/graph.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from elasticsearch.client.utils import NamespacedClient, query_params, _make_path
1+
from ..utils import NamespacedClient, query_params, _make_path
22

33

44
class GraphClient(NamespacedClient):

elasticsearch/client/xpack/ilm.py

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
from ..utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH
2+
3+
4+
class IlmClient(NamespacedClient):
5+
@query_params()
6+
def delete_lifecycle(self, policy=None, params=None):
7+
"""
8+
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-delete-lifecycle.html>`_
9+
10+
:arg policy: The name of the index lifecycle policy
11+
"""
12+
return self.transport.perform_request(
13+
"DELETE", _make_path("_ilm", "policy", policy), params=params
14+
)
15+
16+
@query_params("human")
17+
def explain_lifecycle(self, index=None, params=None):
18+
"""
19+
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-explain-lifecycle.html>`_
20+
21+
:arg index: The name of the index to explain
22+
:arg human: Return data such as dates in a human readable format,
23+
default 'false'
24+
"""
25+
return self.transport.perform_request(
26+
"GET", _make_path(index, "_ilm", "explain"), params=params
27+
)
28+
29+
@query_params()
30+
def get_lifecycle(self, policy=None, params=None):
31+
"""
32+
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-get-lifecycle.html>`_
33+
34+
:arg policy: The name of the index lifecycle policy
35+
"""
36+
return self.transport.perform_request(
37+
"GET", _make_path("_ilm", "policy", policy), params=params
38+
)
39+
40+
@query_params()
41+
def get_status(self, params=None):
42+
"""
43+
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-get-status.html>`_
44+
"""
45+
return self.transport.perform_request("GET", "/_ilm/status", params=params)
46+
47+
@query_params()
48+
def move_to_step(self, index=None, body=None, params=None):
49+
"""
50+
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-move-to-step.html>`_
51+
52+
:arg index: The name of the index whose lifecycle step is to change
53+
:arg body: The new lifecycle step to move to
54+
"""
55+
return self.transport.perform_request(
56+
"POST", _make_path("_ilm", "move", index), params=params, body=body
57+
)
58+
59+
@query_params()
60+
def put_lifecycle(self, policy=None, body=None, params=None):
61+
"""
62+
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-put-lifecycle.html>`_
63+
64+
:arg policy: The name of the index lifecycle policy
65+
:arg body: The lifecycle policy definition to register
66+
"""
67+
return self.transport.perform_request(
68+
"PUT", _make_path("_ilm", "policy", policy), params=params, body=body
69+
)
70+
71+
@query_params()
72+
def remove_policy(self, index=None, params=None):
73+
"""
74+
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-remove-policy.html>`_
75+
76+
:arg index: The name of the index to remove policy on
77+
"""
78+
return self.transport.perform_request(
79+
"POST", _make_path(index, "_ilm", "remove"), params=params
80+
)
81+
82+
@query_params()
83+
def retry(self, index=None, params=None):
84+
"""
85+
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-retry-policy.html>`_
86+
87+
:arg index: The name of the indices (comma-separated) whose failed
88+
lifecycle step is to be retry
89+
"""
90+
return self.transport.perform_request(
91+
"POST", _make_path(index, "_ilm", "retry"), params=params
92+
)
93+
94+
@query_params()
95+
def start(self, params=None):
96+
"""
97+
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-start.html>`_
98+
"""
99+
return self.transport.perform_request("POST", "/_ilm/start", params=params)
100+
101+
@query_params()
102+
def stop(self, params=None):
103+
"""
104+
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-stop.html>`_
105+
"""
106+
return self.transport.perform_request("POST", "/_ilm/stop", params=params)

elasticsearch/client/xpack/indices.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
from ..utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH
2+
3+
4+
class IndicesClient(NamespacedClient):
5+
@query_params(
6+
"allow_no_indices",
7+
"expand_wildcards",
8+
"ignore_unavailable",
9+
"master_timeout",
10+
"timeout",
11+
"wait_for_active_shards",
12+
)
13+
def freeze(self, index, params=None):
14+
"""
15+
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/frozen.html>`_
16+
17+
:arg index: The name of the index to freeze
18+
:arg allow_no_indices: Whether to ignore if a wildcard indices
19+
expression resolves into no concrete indices. (This includes `_all`
20+
string or when no indices have been specified)
21+
:arg expand_wildcards: Whether to expand wildcard expression to concrete
22+
indices that are open, closed or both., default 'closed', valid
23+
choices are: 'open', 'closed', 'none', 'all'
24+
:arg ignore_unavailable: Whether specified concrete indices should be
25+
ignored when unavailable (missing or closed)
26+
:arg master_timeout: Specify timeout for connection to master
27+
:arg timeout: Explicit operation timeout
28+
:arg wait_for_active_shards: Sets the number of active shards to wait
29+
for before the operation returns.
30+
"""
31+
if index in SKIP_IN_PATH:
32+
raise ValueError("Empty value passed for a required argument 'index'.")
33+
return self.transport.perform_request(
34+
"POST", _make_path(index, "_freeze"), params=params
35+
)
36+
37+
@query_params(
38+
"allow_no_indices",
39+
"expand_wildcards",
40+
"ignore_unavailable",
41+
"master_timeout",
42+
"timeout",
43+
"wait_for_active_shards",
44+
)
45+
def unfreeze(self, index, params=None):
46+
"""
47+
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/frozen.html>`_
48+
49+
:arg index: The name of the index to unfreeze
50+
:arg allow_no_indices: Whether to ignore if a wildcard indices
51+
expression resolves into no concrete indices. (This includes `_all`
52+
string or when no indices have been specified)
53+
:arg expand_wildcards: Whether to expand wildcard expression to concrete
54+
indices that are open, closed or both., default 'closed', valid
55+
choices are: 'open', 'closed', 'none', 'all'
56+
:arg ignore_unavailable: Whether specified concrete indices should be
57+
ignored when unavailable (missing or closed)
58+
:arg master_timeout: Specify timeout for connection to master
59+
:arg timeout: Explicit operation timeout
60+
:arg wait_for_active_shards: Sets the number of active shards to wait
61+
for before the operation returns.
62+
"""
63+
if index in SKIP_IN_PATH:
64+
raise ValueError("Empty value passed for a required argument 'index'.")
65+
return self.transport.perform_request(
66+
"POST", _make_path(index, "_unfreeze"), params=params
67+
)

0 commit comments

Comments
 (0)