@@ -34,7 +34,13 @@ async def delete_node(
34
34
t .Union [str , t .Union [t .List [str ], t .Tuple [str , ...]]]
35
35
] = None ,
36
36
human : t .Optional [bool ] = None ,
37
+ master_timeout : t .Optional [
38
+ t .Union ["t.Literal['d', 'h', 'm', 'micros', 'ms', 'nanos', 's']" , str ]
39
+ ] = None ,
37
40
pretty : t .Optional [bool ] = None ,
41
+ timeout : t .Optional [
42
+ t .Union ["t.Literal['d', 'h', 'm', 'micros', 'ms', 'nanos', 's']" , str ]
43
+ ] = None ,
38
44
) -> ObjectApiResponse [t .Any ]:
39
45
"""
40
46
Removes a node from the shutdown list. Designed for indirect use by ECE/ESS and
@@ -43,6 +49,11 @@ async def delete_node(
43
49
`<https://www.elastic.co/guide/en/elasticsearch/reference/current>`_
44
50
45
51
:param node_id: The node id of node to be removed from the shutdown state
52
+ :param master_timeout: Period to wait for a connection to the master node. If
53
+ no response is received before the timeout expires, the request fails and
54
+ returns an error.
55
+ :param timeout: Period to wait for a response. If no response is received before
56
+ the timeout expires, the request fails and returns an error.
46
57
"""
47
58
if node_id in SKIP_IN_PATH :
48
59
raise ValueError ("Empty value passed for parameter 'node_id'" )
@@ -54,8 +65,12 @@ async def delete_node(
54
65
__query ["filter_path" ] = filter_path
55
66
if human is not None :
56
67
__query ["human" ] = human
68
+ if master_timeout is not None :
69
+ __query ["master_timeout" ] = master_timeout
57
70
if pretty is not None :
58
71
__query ["pretty" ] = pretty
72
+ if timeout is not None :
73
+ __query ["timeout" ] = timeout
59
74
__headers = {"accept" : "application/json" }
60
75
return await self .perform_request ( # type: ignore[return-value]
61
76
"DELETE" , __path , params = __query , headers = __headers
@@ -73,7 +88,13 @@ async def get_node(
73
88
t .Union [str , t .Union [t .List [str ], t .Tuple [str , ...]]]
74
89
] = None ,
75
90
human : t .Optional [bool ] = None ,
91
+ master_timeout : t .Optional [
92
+ t .Union ["t.Literal['d', 'h', 'm', 'micros', 'ms', 'nanos', 's']" , str ]
93
+ ] = None ,
76
94
pretty : t .Optional [bool ] = None ,
95
+ timeout : t .Optional [
96
+ t .Union ["t.Literal['d', 'h', 'm', 'micros', 'ms', 'nanos', 's']" , str ]
97
+ ] = None ,
77
98
) -> ObjectApiResponse [t .Any ]:
78
99
"""
79
100
Retrieve status of a node or nodes that are currently marked as shutting down.
@@ -82,6 +103,11 @@ async def get_node(
82
103
`<https://www.elastic.co/guide/en/elasticsearch/reference/current>`_
83
104
84
105
:param node_id: Which node for which to retrieve the shutdown status
106
+ :param master_timeout: Period to wait for a connection to the master node. If
107
+ no response is received before the timeout expires, the request fails and
108
+ returns an error.
109
+ :param timeout: Period to wait for a response. If no response is received before
110
+ the timeout expires, the request fails and returns an error.
85
111
"""
86
112
if node_id not in SKIP_IN_PATH :
87
113
__path = f"/_nodes/{ _quote (node_id )} /shutdown"
@@ -94,24 +120,40 @@ async def get_node(
94
120
__query ["filter_path" ] = filter_path
95
121
if human is not None :
96
122
__query ["human" ] = human
123
+ if master_timeout is not None :
124
+ __query ["master_timeout" ] = master_timeout
97
125
if pretty is not None :
98
126
__query ["pretty" ] = pretty
127
+ if timeout is not None :
128
+ __query ["timeout" ] = timeout
99
129
__headers = {"accept" : "application/json" }
100
130
return await self .perform_request ( # type: ignore[return-value]
101
131
"GET" , __path , params = __query , headers = __headers
102
132
)
103
133
104
- @_rewrite_parameters ()
134
+ @_rewrite_parameters (
135
+ body_fields = True ,
136
+ )
105
137
async def put_node (
106
138
self ,
107
139
* ,
108
140
node_id : str ,
141
+ reason : str ,
142
+ type : t .Union ["t.Literal['remove', 'replace', 'restart']" , str ],
143
+ allocation_delay : t .Optional [str ] = None ,
109
144
error_trace : t .Optional [bool ] = None ,
110
145
filter_path : t .Optional [
111
146
t .Union [str , t .Union [t .List [str ], t .Tuple [str , ...]]]
112
147
] = None ,
113
148
human : t .Optional [bool ] = None ,
149
+ master_timeout : t .Optional [
150
+ t .Union ["t.Literal['d', 'h', 'm', 'micros', 'ms', 'nanos', 's']" , str ]
151
+ ] = None ,
114
152
pretty : t .Optional [bool ] = None ,
153
+ target_node_name : t .Optional [str ] = None ,
154
+ timeout : t .Optional [
155
+ t .Union ["t.Literal['d', 'h', 'm', 'micros', 'ms', 'nanos', 's']" , str ]
156
+ ] = None ,
115
157
) -> ObjectApiResponse [t .Any ]:
116
158
"""
117
159
Adds a node to be shut down. Designed for indirect use by ECE/ESS and ECK. Direct
@@ -120,20 +162,68 @@ async def put_node(
120
162
`<https://www.elastic.co/guide/en/elasticsearch/reference/current>`_
121
163
122
164
:param node_id: The node id of node to be shut down
165
+ :param reason: A human-readable reason that the node is being shut down. This
166
+ field provides information for other cluster operators; it does not affect
167
+ the shut down process.
168
+ :param type: Valid values are restart, remove, or replace. Use restart when you
169
+ need to temporarily shut down a node to perform an upgrade, make configuration
170
+ changes, or perform other maintenance. Because the node is expected to rejoin
171
+ the cluster, data is not migrated off of the node. Use remove when you need
172
+ to permanently remove a node from the cluster. The node is not marked ready
173
+ for shutdown until data is migrated off of the node Use replace to do a 1:1
174
+ replacement of a node with another node. Certain allocation decisions will
175
+ be ignored (such as disk watermarks) in the interest of true replacement
176
+ of the source node with the target node. During a replace-type shutdown,
177
+ rollover and index creation may result in unassigned shards, and shrink may
178
+ fail until the replacement is complete.
179
+ :param allocation_delay: Only valid if type is restart. Controls how long Elasticsearch
180
+ will wait for the node to restart and join the cluster before reassigning
181
+ its shards to other nodes. This works the same as delaying allocation with
182
+ the index.unassigned.node_left.delayed_timeout setting. If you specify both
183
+ a restart allocation delay and an index-level allocation delay, the longer
184
+ of the two is used.
185
+ :param master_timeout: Period to wait for a connection to the master node. If
186
+ no response is received before the timeout expires, the request fails and
187
+ returns an error.
188
+ :param target_node_name: Only valid if type is replace. Specifies the name of
189
+ the node that is replacing the node being shut down. Shards from the shut
190
+ down node are only allowed to be allocated to the target node, and no other
191
+ data will be allocated to the target node. During relocation of data certain
192
+ allocation rules are ignored, such as disk watermarks or user attribute filtering
193
+ rules.
194
+ :param timeout: Period to wait for a response. If no response is received before
195
+ the timeout expires, the request fails and returns an error.
123
196
"""
124
197
if node_id in SKIP_IN_PATH :
125
198
raise ValueError ("Empty value passed for parameter 'node_id'" )
199
+ if reason is None :
200
+ raise ValueError ("Empty value passed for parameter 'reason'" )
201
+ if type is None :
202
+ raise ValueError ("Empty value passed for parameter 'type'" )
126
203
__path = f"/_nodes/{ _quote (node_id )} /shutdown"
204
+ __body : t .Dict [str , t .Any ] = {}
127
205
__query : t .Dict [str , t .Any ] = {}
206
+ if reason is not None :
207
+ __body ["reason" ] = reason
208
+ if type is not None :
209
+ __body ["type" ] = type
210
+ if allocation_delay is not None :
211
+ __body ["allocation_delay" ] = allocation_delay
128
212
if error_trace is not None :
129
213
__query ["error_trace" ] = error_trace
130
214
if filter_path is not None :
131
215
__query ["filter_path" ] = filter_path
132
216
if human is not None :
133
217
__query ["human" ] = human
218
+ if master_timeout is not None :
219
+ __query ["master_timeout" ] = master_timeout
134
220
if pretty is not None :
135
221
__query ["pretty" ] = pretty
136
- __headers = {"accept" : "application/json" }
222
+ if target_node_name is not None :
223
+ __body ["target_node_name" ] = target_node_name
224
+ if timeout is not None :
225
+ __query ["timeout" ] = timeout
226
+ __headers = {"accept" : "application/json" , "content-type" : "application/json" }
137
227
return await self .perform_request ( # type: ignore[return-value]
138
- "PUT" , __path , params = __query , headers = __headers
228
+ "PUT" , __path , params = __query , headers = __headers , body = __body
139
229
)
0 commit comments