1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
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/7.8/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/7.8/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/7.8/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/7.8/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/7.8/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/7.8/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/7.8/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/7.8/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/7.8/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/7.8/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/7.8/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/7.8/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/7.8/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,
)