1#![allow(unused_imports)]
30use crate::{
31 client::Elasticsearch,
32 error::Error,
33 http::{
34 self,
35 headers::{HeaderMap, HeaderName, HeaderValue, ACCEPT, CONTENT_TYPE},
36 request::{Body, JsonBody, NdBody, PARTS_ENCODED},
37 response::Response,
38 transport::Transport,
39 },
40 params::*,
41};
42use percent_encoding::percent_encode;
43use serde::Serialize;
44use std::{borrow::Cow, time::Duration};
45#[derive(Debug, Clone, PartialEq, Eq)]
46#[doc = "API parts for the Shutdown Delete Node API"]
47pub enum ShutdownDeleteNodeParts<'b> {
48 #[doc = "NodeId"]
49 NodeId(&'b str),
50}
51impl<'b> ShutdownDeleteNodeParts<'b> {
52 #[doc = "Builds a relative URL path to the Shutdown Delete Node API"]
53 pub fn url(self) -> Cow<'static, str> {
54 match self {
55 ShutdownDeleteNodeParts::NodeId(node_id) => {
56 let encoded_node_id: Cow<str> =
57 percent_encode(node_id.as_bytes(), PARTS_ENCODED).into();
58 let mut p = String::with_capacity(17usize + encoded_node_id.len());
59 p.push_str("/_nodes/");
60 p.push_str(encoded_node_id.as_ref());
61 p.push_str("/shutdown");
62 p.into()
63 }
64 }
65 }
66}
67#[doc = "Builder for the [Shutdown Delete Node API](https://www.elastic.co/guide/en/elasticsearch/reference/9.1)\n\nRemoves a node from the shutdown list. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported."]
68#[derive(Clone, Debug)]
69pub struct ShutdownDeleteNode<'a, 'b> {
70 transport: &'a Transport,
71 parts: ShutdownDeleteNodeParts<'b>,
72 error_trace: Option<bool>,
73 filter_path: Option<&'b [&'b str]>,
74 headers: HeaderMap,
75 human: Option<bool>,
76 master_timeout: Option<&'b str>,
77 pretty: Option<bool>,
78 request_timeout: Option<Duration>,
79 source: Option<&'b str>,
80 timeout: Option<&'b str>,
81}
82impl<'a, 'b> ShutdownDeleteNode<'a, 'b> {
83 #[doc = "Creates a new instance of [ShutdownDeleteNode] with the specified API parts"]
84 pub fn new(transport: &'a Transport, parts: ShutdownDeleteNodeParts<'b>) -> Self {
85 let headers = HeaderMap::new();
86 ShutdownDeleteNode {
87 transport,
88 parts,
89 headers,
90 error_trace: None,
91 filter_path: None,
92 human: None,
93 master_timeout: None,
94 pretty: None,
95 request_timeout: None,
96 source: None,
97 timeout: None,
98 }
99 }
100 #[doc = "Include the stack trace of returned errors."]
101 pub fn error_trace(mut self, error_trace: bool) -> Self {
102 self.error_trace = Some(error_trace);
103 self
104 }
105 #[doc = "A comma-separated list of filters used to reduce the response."]
106 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
107 self.filter_path = Some(filter_path);
108 self
109 }
110 #[doc = "Adds a HTTP header"]
111 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
112 self.headers.insert(key, value);
113 self
114 }
115 #[doc = "Return human readable values for statistics."]
116 pub fn human(mut self, human: bool) -> Self {
117 self.human = Some(human);
118 self
119 }
120 #[doc = "Explicit operation timeout for connection to master node"]
121 pub fn master_timeout(mut self, master_timeout: &'b str) -> Self {
122 self.master_timeout = Some(master_timeout);
123 self
124 }
125 #[doc = "Pretty format the returned JSON response."]
126 pub fn pretty(mut self, pretty: bool) -> Self {
127 self.pretty = Some(pretty);
128 self
129 }
130 #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."]
131 pub fn request_timeout(mut self, timeout: Duration) -> Self {
132 self.request_timeout = Some(timeout);
133 self
134 }
135 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
136 pub fn source(mut self, source: &'b str) -> Self {
137 self.source = Some(source);
138 self
139 }
140 #[doc = "Explicit operation timeout"]
141 pub fn timeout(mut self, timeout: &'b str) -> Self {
142 self.timeout = Some(timeout);
143 self
144 }
145 #[doc = "Creates an asynchronous call to the Shutdown Delete Node API that can be awaited"]
146 pub async fn send(self) -> Result<Response, Error> {
147 let path = self.parts.url();
148 let method = http::Method::Delete;
149 let headers = self.headers;
150 let timeout = self.request_timeout;
151 let query_string = {
152 #[serde_with::skip_serializing_none]
153 #[derive(Serialize)]
154 struct QueryParams<'b> {
155 error_trace: Option<bool>,
156 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
157 filter_path: Option<&'b [&'b str]>,
158 human: Option<bool>,
159 master_timeout: Option<&'b str>,
160 pretty: Option<bool>,
161 source: Option<&'b str>,
162 timeout: Option<&'b str>,
163 }
164 let query_params = QueryParams {
165 error_trace: self.error_trace,
166 filter_path: self.filter_path,
167 human: self.human,
168 master_timeout: self.master_timeout,
169 pretty: self.pretty,
170 source: self.source,
171 timeout: self.timeout,
172 };
173 Some(query_params)
174 };
175 let body = Option::<()>::None;
176 let response = self
177 .transport
178 .send(method, &path, headers, query_string.as_ref(), body, timeout)
179 .await?;
180 Ok(response)
181 }
182}
183#[derive(Debug, Clone, PartialEq, Eq)]
184#[doc = "API parts for the Shutdown Get Node API"]
185pub enum ShutdownGetNodeParts<'b> {
186 #[doc = "No parts"]
187 None,
188 #[doc = "NodeId"]
189 NodeId(&'b str),
190}
191impl<'b> ShutdownGetNodeParts<'b> {
192 #[doc = "Builds a relative URL path to the Shutdown Get Node API"]
193 pub fn url(self) -> Cow<'static, str> {
194 match self {
195 ShutdownGetNodeParts::None => "/_nodes/shutdown".into(),
196 ShutdownGetNodeParts::NodeId(node_id) => {
197 let encoded_node_id: Cow<str> =
198 percent_encode(node_id.as_bytes(), PARTS_ENCODED).into();
199 let mut p = String::with_capacity(17usize + encoded_node_id.len());
200 p.push_str("/_nodes/");
201 p.push_str(encoded_node_id.as_ref());
202 p.push_str("/shutdown");
203 p.into()
204 }
205 }
206 }
207}
208#[doc = "Builder for the [Shutdown Get Node API](https://www.elastic.co/guide/en/elasticsearch/reference/9.1)\n\nRetrieve status of a node or nodes that are currently marked as shutting down. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported."]
209#[derive(Clone, Debug)]
210pub struct ShutdownGetNode<'a, 'b> {
211 transport: &'a Transport,
212 parts: ShutdownGetNodeParts<'b>,
213 error_trace: Option<bool>,
214 filter_path: Option<&'b [&'b str]>,
215 headers: HeaderMap,
216 human: Option<bool>,
217 master_timeout: Option<&'b str>,
218 pretty: Option<bool>,
219 request_timeout: Option<Duration>,
220 source: Option<&'b str>,
221}
222impl<'a, 'b> ShutdownGetNode<'a, 'b> {
223 #[doc = "Creates a new instance of [ShutdownGetNode] with the specified API parts"]
224 pub fn new(transport: &'a Transport, parts: ShutdownGetNodeParts<'b>) -> Self {
225 let headers = HeaderMap::new();
226 ShutdownGetNode {
227 transport,
228 parts,
229 headers,
230 error_trace: None,
231 filter_path: None,
232 human: None,
233 master_timeout: None,
234 pretty: None,
235 request_timeout: None,
236 source: None,
237 }
238 }
239 #[doc = "Include the stack trace of returned errors."]
240 pub fn error_trace(mut self, error_trace: bool) -> Self {
241 self.error_trace = Some(error_trace);
242 self
243 }
244 #[doc = "A comma-separated list of filters used to reduce the response."]
245 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
246 self.filter_path = Some(filter_path);
247 self
248 }
249 #[doc = "Adds a HTTP header"]
250 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
251 self.headers.insert(key, value);
252 self
253 }
254 #[doc = "Return human readable values for statistics."]
255 pub fn human(mut self, human: bool) -> Self {
256 self.human = Some(human);
257 self
258 }
259 #[doc = "Timeout for processing on master node"]
260 pub fn master_timeout(mut self, master_timeout: &'b str) -> Self {
261 self.master_timeout = Some(master_timeout);
262 self
263 }
264 #[doc = "Pretty format the returned JSON response."]
265 pub fn pretty(mut self, pretty: bool) -> Self {
266 self.pretty = Some(pretty);
267 self
268 }
269 #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."]
270 pub fn request_timeout(mut self, timeout: Duration) -> Self {
271 self.request_timeout = Some(timeout);
272 self
273 }
274 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
275 pub fn source(mut self, source: &'b str) -> Self {
276 self.source = Some(source);
277 self
278 }
279 #[doc = "Creates an asynchronous call to the Shutdown Get Node API that can be awaited"]
280 pub async fn send(self) -> Result<Response, Error> {
281 let path = self.parts.url();
282 let method = http::Method::Get;
283 let headers = self.headers;
284 let timeout = self.request_timeout;
285 let query_string = {
286 #[serde_with::skip_serializing_none]
287 #[derive(Serialize)]
288 struct QueryParams<'b> {
289 error_trace: Option<bool>,
290 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
291 filter_path: Option<&'b [&'b str]>,
292 human: Option<bool>,
293 master_timeout: Option<&'b str>,
294 pretty: Option<bool>,
295 source: Option<&'b str>,
296 }
297 let query_params = QueryParams {
298 error_trace: self.error_trace,
299 filter_path: self.filter_path,
300 human: self.human,
301 master_timeout: self.master_timeout,
302 pretty: self.pretty,
303 source: self.source,
304 };
305 Some(query_params)
306 };
307 let body = Option::<()>::None;
308 let response = self
309 .transport
310 .send(method, &path, headers, query_string.as_ref(), body, timeout)
311 .await?;
312 Ok(response)
313 }
314}
315#[derive(Debug, Clone, PartialEq, Eq)]
316#[doc = "API parts for the Shutdown Put Node API"]
317pub enum ShutdownPutNodeParts<'b> {
318 #[doc = "NodeId"]
319 NodeId(&'b str),
320}
321impl<'b> ShutdownPutNodeParts<'b> {
322 #[doc = "Builds a relative URL path to the Shutdown Put Node API"]
323 pub fn url(self) -> Cow<'static, str> {
324 match self {
325 ShutdownPutNodeParts::NodeId(node_id) => {
326 let encoded_node_id: Cow<str> =
327 percent_encode(node_id.as_bytes(), PARTS_ENCODED).into();
328 let mut p = String::with_capacity(17usize + encoded_node_id.len());
329 p.push_str("/_nodes/");
330 p.push_str(encoded_node_id.as_ref());
331 p.push_str("/shutdown");
332 p.into()
333 }
334 }
335 }
336}
337#[doc = "Builder for the [Shutdown Put Node API](https://www.elastic.co/guide/en/elasticsearch/reference/9.1)\n\nAdds a node to be shut down. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported."]
338#[derive(Clone, Debug)]
339pub struct ShutdownPutNode<'a, 'b, B> {
340 transport: &'a Transport,
341 parts: ShutdownPutNodeParts<'b>,
342 body: Option<B>,
343 error_trace: Option<bool>,
344 filter_path: Option<&'b [&'b str]>,
345 headers: HeaderMap,
346 human: Option<bool>,
347 master_timeout: Option<&'b str>,
348 pretty: Option<bool>,
349 request_timeout: Option<Duration>,
350 source: Option<&'b str>,
351 timeout: Option<&'b str>,
352}
353impl<'a, 'b, B> ShutdownPutNode<'a, 'b, B>
354where
355 B: Body,
356{
357 #[doc = "Creates a new instance of [ShutdownPutNode] with the specified API parts"]
358 pub fn new(transport: &'a Transport, parts: ShutdownPutNodeParts<'b>) -> Self {
359 let headers = HeaderMap::new();
360 ShutdownPutNode {
361 transport,
362 parts,
363 headers,
364 body: None,
365 error_trace: None,
366 filter_path: None,
367 human: None,
368 master_timeout: None,
369 pretty: None,
370 request_timeout: None,
371 source: None,
372 timeout: None,
373 }
374 }
375 #[doc = "The body for the API call"]
376 pub fn body<T>(self, body: T) -> ShutdownPutNode<'a, 'b, JsonBody<T>>
377 where
378 T: Serialize,
379 {
380 ShutdownPutNode {
381 transport: self.transport,
382 parts: self.parts,
383 body: Some(body.into()),
384 error_trace: self.error_trace,
385 filter_path: self.filter_path,
386 headers: self.headers,
387 human: self.human,
388 master_timeout: self.master_timeout,
389 pretty: self.pretty,
390 request_timeout: self.request_timeout,
391 source: self.source,
392 timeout: self.timeout,
393 }
394 }
395 #[doc = "Include the stack trace of returned errors."]
396 pub fn error_trace(mut self, error_trace: bool) -> Self {
397 self.error_trace = Some(error_trace);
398 self
399 }
400 #[doc = "A comma-separated list of filters used to reduce the response."]
401 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
402 self.filter_path = Some(filter_path);
403 self
404 }
405 #[doc = "Adds a HTTP header"]
406 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
407 self.headers.insert(key, value);
408 self
409 }
410 #[doc = "Return human readable values for statistics."]
411 pub fn human(mut self, human: bool) -> Self {
412 self.human = Some(human);
413 self
414 }
415 #[doc = "Explicit operation timeout for connection to master node"]
416 pub fn master_timeout(mut self, master_timeout: &'b str) -> Self {
417 self.master_timeout = Some(master_timeout);
418 self
419 }
420 #[doc = "Pretty format the returned JSON response."]
421 pub fn pretty(mut self, pretty: bool) -> Self {
422 self.pretty = Some(pretty);
423 self
424 }
425 #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."]
426 pub fn request_timeout(mut self, timeout: Duration) -> Self {
427 self.request_timeout = Some(timeout);
428 self
429 }
430 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
431 pub fn source(mut self, source: &'b str) -> Self {
432 self.source = Some(source);
433 self
434 }
435 #[doc = "Explicit operation timeout"]
436 pub fn timeout(mut self, timeout: &'b str) -> Self {
437 self.timeout = Some(timeout);
438 self
439 }
440 #[doc = "Creates an asynchronous call to the Shutdown Put Node API that can be awaited"]
441 pub async fn send(self) -> Result<Response, Error> {
442 let path = self.parts.url();
443 let method = http::Method::Put;
444 let headers = self.headers;
445 let timeout = self.request_timeout;
446 let query_string = {
447 #[serde_with::skip_serializing_none]
448 #[derive(Serialize)]
449 struct QueryParams<'b> {
450 error_trace: Option<bool>,
451 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
452 filter_path: Option<&'b [&'b str]>,
453 human: Option<bool>,
454 master_timeout: Option<&'b str>,
455 pretty: Option<bool>,
456 source: Option<&'b str>,
457 timeout: Option<&'b str>,
458 }
459 let query_params = QueryParams {
460 error_trace: self.error_trace,
461 filter_path: self.filter_path,
462 human: self.human,
463 master_timeout: self.master_timeout,
464 pretty: self.pretty,
465 source: self.source,
466 timeout: self.timeout,
467 };
468 Some(query_params)
469 };
470 let body = self.body;
471 let response = self
472 .transport
473 .send(method, &path, headers, query_string.as_ref(), body, timeout)
474 .await?;
475 Ok(response)
476 }
477}
478#[doc = "Namespace client for Shutdown APIs"]
479pub struct Shutdown<'a> {
480 transport: &'a Transport,
481}
482impl<'a> Shutdown<'a> {
483 #[doc = "Creates a new instance of [Shutdown]"]
484 pub fn new(transport: &'a Transport) -> Self {
485 Self { transport }
486 }
487 pub fn transport(&self) -> &Transport {
488 self.transport
489 }
490 #[doc = "[Shutdown Delete Node API](https://www.elastic.co/guide/en/elasticsearch/reference/9.1)\n\nRemoves a node from the shutdown list. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported."]
491 pub fn delete_node<'b>(
492 &'a self,
493 parts: ShutdownDeleteNodeParts<'b>,
494 ) -> ShutdownDeleteNode<'a, 'b> {
495 ShutdownDeleteNode::new(self.transport(), parts)
496 }
497 #[doc = "[Shutdown Get Node API](https://www.elastic.co/guide/en/elasticsearch/reference/9.1)\n\nRetrieve status of a node or nodes that are currently marked as shutting down. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported."]
498 pub fn get_node<'b>(&'a self, parts: ShutdownGetNodeParts<'b>) -> ShutdownGetNode<'a, 'b> {
499 ShutdownGetNode::new(self.transport(), parts)
500 }
501 #[doc = "[Shutdown Put Node API](https://www.elastic.co/guide/en/elasticsearch/reference/9.1)\n\nAdds a node to be shut down. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported."]
502 pub fn put_node<'b>(&'a self, parts: ShutdownPutNodeParts<'b>) -> ShutdownPutNode<'a, 'b, ()> {
503 ShutdownPutNode::new(self.transport(), parts)
504 }
505}
506impl Elasticsearch {
507 #[doc = "Creates a namespace client for Shutdown APIs"]
508 pub fn shutdown(&self) -> Shutdown {
509 Shutdown::new(self.transport())
510 }
511}