1#![allow(unused_imports)]
33use crate::{
34 client::OpenSearch,
35 error::Error,
36 http::{
37 headers::{HeaderMap, HeaderName, HeaderValue, ACCEPT, CONTENT_TYPE},
38 request::{Body, JsonBody, NdBody, PARTS_ENCODED},
39 response::Response,
40 transport::Transport,
41 Method,
42 },
43 params::*,
44};
45use percent_encoding::percent_encode;
46use serde::Serialize;
47use std::{borrow::Cow, time::Duration};
48#[derive(Debug, Clone, PartialEq)]
49#[doc = "API parts for the Nodes Hot Threads API"]
50pub enum NodesHotThreadsParts<'b> {
51 #[doc = "No parts"]
52 None,
53 #[doc = "NodeId"]
54 NodeId(&'b [&'b str]),
55}
56impl<'b> NodesHotThreadsParts<'b> {
57 #[doc = "Builds a relative URL path to the Nodes Hot Threads API"]
58 pub fn url(self) -> Cow<'static, str> {
59 match self {
60 NodesHotThreadsParts::None => "/_nodes/hot_threads".into(),
61 NodesHotThreadsParts::NodeId(ref node_id) => {
62 let node_id_str = node_id.join(",");
63 let encoded_node_id: Cow<str> =
64 percent_encode(node_id_str.as_bytes(), PARTS_ENCODED).into();
65 let mut p = String::with_capacity(20usize + encoded_node_id.len());
66 p.push_str("/_nodes/");
67 p.push_str(encoded_node_id.as_ref());
68 p.push_str("/hot_threads");
69 p.into()
70 }
71 }
72 }
73}
74#[doc = "Builder for the [Nodes Hot Threads API](https://opensearch.org/docs/)\n\nReturns information about hot threads on each node in the cluster."]
75#[derive(Clone, Debug)]
76pub struct NodesHotThreads<'a, 'b> {
77 transport: &'a Transport,
78 parts: NodesHotThreadsParts<'b>,
79 error_trace: Option<bool>,
80 filter_path: Option<&'b [&'b str]>,
81 headers: HeaderMap,
82 human: Option<bool>,
83 ignore_idle_threads: Option<bool>,
84 interval: Option<&'b str>,
85 pretty: Option<bool>,
86 request_timeout: Option<Duration>,
87 snapshots: Option<i64>,
88 source: Option<&'b str>,
89 threads: Option<i64>,
90 timeout: Option<&'b str>,
91 ty: Option<Type>,
92}
93impl<'a, 'b> NodesHotThreads<'a, 'b> {
94 #[doc = "Creates a new instance of [NodesHotThreads] with the specified API parts"]
95 pub fn new(transport: &'a Transport, parts: NodesHotThreadsParts<'b>) -> Self {
96 let headers = HeaderMap::new();
97 NodesHotThreads {
98 transport,
99 parts,
100 headers,
101 error_trace: None,
102 filter_path: None,
103 human: None,
104 ignore_idle_threads: None,
105 interval: None,
106 pretty: None,
107 request_timeout: None,
108 snapshots: None,
109 source: None,
110 threads: None,
111 timeout: None,
112 ty: None,
113 }
114 }
115 #[doc = "Include the stack trace of returned errors."]
116 pub fn error_trace(mut self, error_trace: bool) -> Self {
117 self.error_trace = Some(error_trace);
118 self
119 }
120 #[doc = "A comma-separated list of filters used to reduce the response."]
121 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
122 self.filter_path = Some(filter_path);
123 self
124 }
125 #[doc = "Adds a HTTP header"]
126 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
127 self.headers.insert(key, value);
128 self
129 }
130 #[doc = "Return human readable values for statistics."]
131 pub fn human(mut self, human: bool) -> Self {
132 self.human = Some(human);
133 self
134 }
135 #[doc = "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)"]
136 pub fn ignore_idle_threads(mut self, ignore_idle_threads: bool) -> Self {
137 self.ignore_idle_threads = Some(ignore_idle_threads);
138 self
139 }
140 #[doc = "The interval for the second sampling of threads"]
141 pub fn interval(mut self, interval: &'b str) -> Self {
142 self.interval = Some(interval);
143 self
144 }
145 #[doc = "Pretty format the returned JSON response."]
146 pub fn pretty(mut self, pretty: bool) -> Self {
147 self.pretty = Some(pretty);
148 self
149 }
150 #[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."]
151 pub fn request_timeout(mut self, timeout: Duration) -> Self {
152 self.request_timeout = Some(timeout);
153 self
154 }
155 #[doc = "Number of samples of thread stacktrace (default: 10)"]
156 pub fn snapshots(mut self, snapshots: i64) -> Self {
157 self.snapshots = Some(snapshots);
158 self
159 }
160 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
161 pub fn source(mut self, source: &'b str) -> Self {
162 self.source = Some(source);
163 self
164 }
165 #[doc = "Specify the number of threads to provide information for (default: 3)"]
166 pub fn threads(mut self, threads: i64) -> Self {
167 self.threads = Some(threads);
168 self
169 }
170 #[doc = "Explicit operation timeout"]
171 pub fn timeout(mut self, timeout: &'b str) -> Self {
172 self.timeout = Some(timeout);
173 self
174 }
175 #[doc = "The type to sample (default: cpu)"]
176 pub fn ty(mut self, ty: Type) -> Self {
177 self.ty = Some(ty);
178 self
179 }
180 #[doc = "Creates an asynchronous call to the Nodes Hot Threads API that can be awaited"]
181 pub async fn send(self) -> Result<Response, Error> {
182 let path = self.parts.url();
183 let method = Method::Get;
184 let headers = self.headers;
185 let timeout = self.request_timeout;
186 let query_string = {
187 #[serde_with::skip_serializing_none]
188 #[derive(Serialize)]
189 struct QueryParams<'b> {
190 error_trace: Option<bool>,
191 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
192 filter_path: Option<&'b [&'b str]>,
193 human: Option<bool>,
194 ignore_idle_threads: Option<bool>,
195 interval: Option<&'b str>,
196 pretty: Option<bool>,
197 snapshots: Option<i64>,
198 source: Option<&'b str>,
199 threads: Option<i64>,
200 timeout: Option<&'b str>,
201 #[serde(rename = "type")]
202 ty: Option<Type>,
203 }
204 let query_params = QueryParams {
205 error_trace: self.error_trace,
206 filter_path: self.filter_path,
207 human: self.human,
208 ignore_idle_threads: self.ignore_idle_threads,
209 interval: self.interval,
210 pretty: self.pretty,
211 snapshots: self.snapshots,
212 source: self.source,
213 threads: self.threads,
214 timeout: self.timeout,
215 ty: self.ty,
216 };
217 Some(query_params)
218 };
219 let body = Option::<()>::None;
220 let response = self
221 .transport
222 .send(method, &path, headers, query_string.as_ref(), body, timeout)
223 .await?;
224 Ok(response)
225 }
226}
227#[derive(Debug, Clone, PartialEq)]
228#[doc = "API parts for the Nodes Info API"]
229pub enum NodesInfoParts<'b> {
230 #[doc = "No parts"]
231 None,
232 #[doc = "NodeId"]
233 NodeId(&'b [&'b str]),
234 #[doc = "Metric"]
235 Metric(&'b [&'b str]),
236 #[doc = "NodeId and Metric"]
237 NodeIdMetric(&'b [&'b str], &'b [&'b str]),
238}
239impl<'b> NodesInfoParts<'b> {
240 #[doc = "Builds a relative URL path to the Nodes Info API"]
241 pub fn url(self) -> Cow<'static, str> {
242 match self {
243 NodesInfoParts::None => "/_nodes".into(),
244 NodesInfoParts::NodeId(ref node_id) => {
245 let node_id_str = node_id.join(",");
246 let encoded_node_id: Cow<str> =
247 percent_encode(node_id_str.as_bytes(), PARTS_ENCODED).into();
248 let mut p = String::with_capacity(8usize + encoded_node_id.len());
249 p.push_str("/_nodes/");
250 p.push_str(encoded_node_id.as_ref());
251 p.into()
252 }
253 NodesInfoParts::Metric(ref metric) => {
254 let metric_str = metric.join(",");
255 let encoded_metric: Cow<str> =
256 percent_encode(metric_str.as_bytes(), PARTS_ENCODED).into();
257 let mut p = String::with_capacity(8usize + encoded_metric.len());
258 p.push_str("/_nodes/");
259 p.push_str(encoded_metric.as_ref());
260 p.into()
261 }
262 NodesInfoParts::NodeIdMetric(ref node_id, ref metric) => {
263 let node_id_str = node_id.join(",");
264 let metric_str = metric.join(",");
265 let encoded_node_id: Cow<str> =
266 percent_encode(node_id_str.as_bytes(), PARTS_ENCODED).into();
267 let encoded_metric: Cow<str> =
268 percent_encode(metric_str.as_bytes(), PARTS_ENCODED).into();
269 let mut p =
270 String::with_capacity(9usize + encoded_node_id.len() + encoded_metric.len());
271 p.push_str("/_nodes/");
272 p.push_str(encoded_node_id.as_ref());
273 p.push_str("/");
274 p.push_str(encoded_metric.as_ref());
275 p.into()
276 }
277 }
278 }
279}
280#[doc = "Builder for the [Nodes Info API](https://opensearch.org/docs/)\n\nReturns information about nodes in the cluster."]
281#[derive(Clone, Debug)]
282pub struct NodesInfo<'a, 'b> {
283 transport: &'a Transport,
284 parts: NodesInfoParts<'b>,
285 error_trace: Option<bool>,
286 filter_path: Option<&'b [&'b str]>,
287 flat_settings: Option<bool>,
288 headers: HeaderMap,
289 human: Option<bool>,
290 pretty: Option<bool>,
291 request_timeout: Option<Duration>,
292 source: Option<&'b str>,
293 timeout: Option<&'b str>,
294}
295impl<'a, 'b> NodesInfo<'a, 'b> {
296 #[doc = "Creates a new instance of [NodesInfo] with the specified API parts"]
297 pub fn new(transport: &'a Transport, parts: NodesInfoParts<'b>) -> Self {
298 let headers = HeaderMap::new();
299 NodesInfo {
300 transport,
301 parts,
302 headers,
303 error_trace: None,
304 filter_path: None,
305 flat_settings: None,
306 human: None,
307 pretty: None,
308 request_timeout: None,
309 source: None,
310 timeout: None,
311 }
312 }
313 #[doc = "Include the stack trace of returned errors."]
314 pub fn error_trace(mut self, error_trace: bool) -> Self {
315 self.error_trace = Some(error_trace);
316 self
317 }
318 #[doc = "A comma-separated list of filters used to reduce the response."]
319 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
320 self.filter_path = Some(filter_path);
321 self
322 }
323 #[doc = "Return settings in flat format (default: false)"]
324 pub fn flat_settings(mut self, flat_settings: bool) -> Self {
325 self.flat_settings = Some(flat_settings);
326 self
327 }
328 #[doc = "Adds a HTTP header"]
329 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
330 self.headers.insert(key, value);
331 self
332 }
333 #[doc = "Return human readable values for statistics."]
334 pub fn human(mut self, human: bool) -> Self {
335 self.human = Some(human);
336 self
337 }
338 #[doc = "Pretty format the returned JSON response."]
339 pub fn pretty(mut self, pretty: bool) -> Self {
340 self.pretty = Some(pretty);
341 self
342 }
343 #[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."]
344 pub fn request_timeout(mut self, timeout: Duration) -> Self {
345 self.request_timeout = Some(timeout);
346 self
347 }
348 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
349 pub fn source(mut self, source: &'b str) -> Self {
350 self.source = Some(source);
351 self
352 }
353 #[doc = "Explicit operation timeout"]
354 pub fn timeout(mut self, timeout: &'b str) -> Self {
355 self.timeout = Some(timeout);
356 self
357 }
358 #[doc = "Creates an asynchronous call to the Nodes Info API that can be awaited"]
359 pub async fn send(self) -> Result<Response, Error> {
360 let path = self.parts.url();
361 let method = Method::Get;
362 let headers = self.headers;
363 let timeout = self.request_timeout;
364 let query_string = {
365 #[serde_with::skip_serializing_none]
366 #[derive(Serialize)]
367 struct QueryParams<'b> {
368 error_trace: Option<bool>,
369 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
370 filter_path: Option<&'b [&'b str]>,
371 flat_settings: Option<bool>,
372 human: Option<bool>,
373 pretty: Option<bool>,
374 source: Option<&'b str>,
375 timeout: Option<&'b str>,
376 }
377 let query_params = QueryParams {
378 error_trace: self.error_trace,
379 filter_path: self.filter_path,
380 flat_settings: self.flat_settings,
381 human: self.human,
382 pretty: self.pretty,
383 source: self.source,
384 timeout: self.timeout,
385 };
386 Some(query_params)
387 };
388 let body = Option::<()>::None;
389 let response = self
390 .transport
391 .send(method, &path, headers, query_string.as_ref(), body, timeout)
392 .await?;
393 Ok(response)
394 }
395}
396#[derive(Debug, Clone, PartialEq)]
397#[doc = "API parts for the Nodes Reload Secure Settings API"]
398pub enum NodesReloadSecureSettingsParts<'b> {
399 #[doc = "No parts"]
400 None,
401 #[doc = "NodeId"]
402 NodeId(&'b [&'b str]),
403}
404impl<'b> NodesReloadSecureSettingsParts<'b> {
405 #[doc = "Builds a relative URL path to the Nodes Reload Secure Settings API"]
406 pub fn url(self) -> Cow<'static, str> {
407 match self {
408 NodesReloadSecureSettingsParts::None => "/_nodes/reload_secure_settings".into(),
409 NodesReloadSecureSettingsParts::NodeId(ref node_id) => {
410 let node_id_str = node_id.join(",");
411 let encoded_node_id: Cow<str> =
412 percent_encode(node_id_str.as_bytes(), PARTS_ENCODED).into();
413 let mut p = String::with_capacity(31usize + encoded_node_id.len());
414 p.push_str("/_nodes/");
415 p.push_str(encoded_node_id.as_ref());
416 p.push_str("/reload_secure_settings");
417 p.into()
418 }
419 }
420 }
421}
422#[doc = "Builder for the [Nodes Reload Secure Settings API](https://opensearch.org/docs/)\n\nReloads secure settings."]
423#[derive(Clone, Debug)]
424pub struct NodesReloadSecureSettings<'a, 'b, B> {
425 transport: &'a Transport,
426 parts: NodesReloadSecureSettingsParts<'b>,
427 body: Option<B>,
428 error_trace: Option<bool>,
429 filter_path: Option<&'b [&'b str]>,
430 headers: HeaderMap,
431 human: Option<bool>,
432 pretty: Option<bool>,
433 request_timeout: Option<Duration>,
434 source: Option<&'b str>,
435 timeout: Option<&'b str>,
436}
437impl<'a, 'b, B> NodesReloadSecureSettings<'a, 'b, B>
438where
439 B: Body,
440{
441 #[doc = "Creates a new instance of [NodesReloadSecureSettings] with the specified API parts"]
442 pub fn new(transport: &'a Transport, parts: NodesReloadSecureSettingsParts<'b>) -> Self {
443 let headers = HeaderMap::new();
444 NodesReloadSecureSettings {
445 transport,
446 parts,
447 headers,
448 body: None,
449 error_trace: None,
450 filter_path: None,
451 human: None,
452 pretty: None,
453 request_timeout: None,
454 source: None,
455 timeout: None,
456 }
457 }
458 #[doc = "The body for the API call"]
459 pub fn body<T>(self, body: T) -> NodesReloadSecureSettings<'a, 'b, JsonBody<T>>
460 where
461 T: Serialize,
462 {
463 NodesReloadSecureSettings {
464 transport: self.transport,
465 parts: self.parts,
466 body: Some(body.into()),
467 error_trace: self.error_trace,
468 filter_path: self.filter_path,
469 headers: self.headers,
470 human: self.human,
471 pretty: self.pretty,
472 request_timeout: self.request_timeout,
473 source: self.source,
474 timeout: self.timeout,
475 }
476 }
477 #[doc = "Include the stack trace of returned errors."]
478 pub fn error_trace(mut self, error_trace: bool) -> Self {
479 self.error_trace = Some(error_trace);
480 self
481 }
482 #[doc = "A comma-separated list of filters used to reduce the response."]
483 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
484 self.filter_path = Some(filter_path);
485 self
486 }
487 #[doc = "Adds a HTTP header"]
488 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
489 self.headers.insert(key, value);
490 self
491 }
492 #[doc = "Return human readable values for statistics."]
493 pub fn human(mut self, human: bool) -> Self {
494 self.human = Some(human);
495 self
496 }
497 #[doc = "Pretty format the returned JSON response."]
498 pub fn pretty(mut self, pretty: bool) -> Self {
499 self.pretty = Some(pretty);
500 self
501 }
502 #[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."]
503 pub fn request_timeout(mut self, timeout: Duration) -> Self {
504 self.request_timeout = Some(timeout);
505 self
506 }
507 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
508 pub fn source(mut self, source: &'b str) -> Self {
509 self.source = Some(source);
510 self
511 }
512 #[doc = "Explicit operation timeout"]
513 pub fn timeout(mut self, timeout: &'b str) -> Self {
514 self.timeout = Some(timeout);
515 self
516 }
517 #[doc = "Creates an asynchronous call to the Nodes Reload Secure Settings API that can be awaited"]
518 pub async fn send(self) -> Result<Response, Error> {
519 let path = self.parts.url();
520 let method = Method::Post;
521 let headers = self.headers;
522 let timeout = self.request_timeout;
523 let query_string = {
524 #[serde_with::skip_serializing_none]
525 #[derive(Serialize)]
526 struct QueryParams<'b> {
527 error_trace: Option<bool>,
528 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
529 filter_path: Option<&'b [&'b str]>,
530 human: Option<bool>,
531 pretty: Option<bool>,
532 source: Option<&'b str>,
533 timeout: Option<&'b str>,
534 }
535 let query_params = QueryParams {
536 error_trace: self.error_trace,
537 filter_path: self.filter_path,
538 human: self.human,
539 pretty: self.pretty,
540 source: self.source,
541 timeout: self.timeout,
542 };
543 Some(query_params)
544 };
545 let body = self.body;
546 let response = self
547 .transport
548 .send(method, &path, headers, query_string.as_ref(), body, timeout)
549 .await?;
550 Ok(response)
551 }
552}
553#[derive(Debug, Clone, PartialEq)]
554#[doc = "API parts for the Nodes Stats API"]
555pub enum NodesStatsParts<'b> {
556 #[doc = "No parts"]
557 None,
558 #[doc = "NodeId"]
559 NodeId(&'b [&'b str]),
560 #[doc = "Metric"]
561 Metric(&'b [&'b str]),
562 #[doc = "NodeId and Metric"]
563 NodeIdMetric(&'b [&'b str], &'b [&'b str]),
564 #[doc = "Metric and IndexMetric"]
565 MetricIndexMetric(&'b [&'b str], &'b [&'b str]),
566 #[doc = "NodeId, Metric and IndexMetric"]
567 NodeIdMetricIndexMetric(&'b [&'b str], &'b [&'b str], &'b [&'b str]),
568}
569impl<'b> NodesStatsParts<'b> {
570 #[doc = "Builds a relative URL path to the Nodes Stats API"]
571 pub fn url(self) -> Cow<'static, str> {
572 match self {
573 NodesStatsParts::None => "/_nodes/stats".into(),
574 NodesStatsParts::NodeId(ref node_id) => {
575 let node_id_str = node_id.join(",");
576 let encoded_node_id: Cow<str> =
577 percent_encode(node_id_str.as_bytes(), PARTS_ENCODED).into();
578 let mut p = String::with_capacity(14usize + encoded_node_id.len());
579 p.push_str("/_nodes/");
580 p.push_str(encoded_node_id.as_ref());
581 p.push_str("/stats");
582 p.into()
583 }
584 NodesStatsParts::Metric(ref metric) => {
585 let metric_str = metric.join(",");
586 let encoded_metric: Cow<str> =
587 percent_encode(metric_str.as_bytes(), PARTS_ENCODED).into();
588 let mut p = String::with_capacity(14usize + encoded_metric.len());
589 p.push_str("/_nodes/stats/");
590 p.push_str(encoded_metric.as_ref());
591 p.into()
592 }
593 NodesStatsParts::NodeIdMetric(ref node_id, ref metric) => {
594 let node_id_str = node_id.join(",");
595 let metric_str = metric.join(",");
596 let encoded_node_id: Cow<str> =
597 percent_encode(node_id_str.as_bytes(), PARTS_ENCODED).into();
598 let encoded_metric: Cow<str> =
599 percent_encode(metric_str.as_bytes(), PARTS_ENCODED).into();
600 let mut p =
601 String::with_capacity(15usize + encoded_node_id.len() + encoded_metric.len());
602 p.push_str("/_nodes/");
603 p.push_str(encoded_node_id.as_ref());
604 p.push_str("/stats/");
605 p.push_str(encoded_metric.as_ref());
606 p.into()
607 }
608 NodesStatsParts::MetricIndexMetric(ref metric, ref index_metric) => {
609 let metric_str = metric.join(",");
610 let index_metric_str = index_metric.join(",");
611 let encoded_metric: Cow<str> =
612 percent_encode(metric_str.as_bytes(), PARTS_ENCODED).into();
613 let encoded_index_metric: Cow<str> =
614 percent_encode(index_metric_str.as_bytes(), PARTS_ENCODED).into();
615 let mut p = String::with_capacity(
616 15usize + encoded_metric.len() + encoded_index_metric.len(),
617 );
618 p.push_str("/_nodes/stats/");
619 p.push_str(encoded_metric.as_ref());
620 p.push_str("/");
621 p.push_str(encoded_index_metric.as_ref());
622 p.into()
623 }
624 NodesStatsParts::NodeIdMetricIndexMetric(ref node_id, ref metric, ref index_metric) => {
625 let node_id_str = node_id.join(",");
626 let metric_str = metric.join(",");
627 let index_metric_str = index_metric.join(",");
628 let encoded_node_id: Cow<str> =
629 percent_encode(node_id_str.as_bytes(), PARTS_ENCODED).into();
630 let encoded_metric: Cow<str> =
631 percent_encode(metric_str.as_bytes(), PARTS_ENCODED).into();
632 let encoded_index_metric: Cow<str> =
633 percent_encode(index_metric_str.as_bytes(), PARTS_ENCODED).into();
634 let mut p = String::with_capacity(
635 16usize
636 + encoded_node_id.len()
637 + encoded_metric.len()
638 + encoded_index_metric.len(),
639 );
640 p.push_str("/_nodes/");
641 p.push_str(encoded_node_id.as_ref());
642 p.push_str("/stats/");
643 p.push_str(encoded_metric.as_ref());
644 p.push_str("/");
645 p.push_str(encoded_index_metric.as_ref());
646 p.into()
647 }
648 }
649 }
650}
651#[doc = "Builder for the [Nodes Stats API](https://opensearch.org/docs/)\n\nReturns statistical information about nodes in the cluster."]
652#[derive(Clone, Debug)]
653pub struct NodesStats<'a, 'b> {
654 transport: &'a Transport,
655 parts: NodesStatsParts<'b>,
656 completion_fields: Option<&'b [&'b str]>,
657 error_trace: Option<bool>,
658 fielddata_fields: Option<&'b [&'b str]>,
659 fields: Option<&'b [&'b str]>,
660 filter_path: Option<&'b [&'b str]>,
661 groups: Option<bool>,
662 headers: HeaderMap,
663 human: Option<bool>,
664 include_segment_file_sizes: Option<bool>,
665 level: Option<Level>,
666 pretty: Option<bool>,
667 request_timeout: Option<Duration>,
668 source: Option<&'b str>,
669 timeout: Option<&'b str>,
670 types: Option<&'b [&'b str]>,
671}
672impl<'a, 'b> NodesStats<'a, 'b> {
673 #[doc = "Creates a new instance of [NodesStats] with the specified API parts"]
674 pub fn new(transport: &'a Transport, parts: NodesStatsParts<'b>) -> Self {
675 let headers = HeaderMap::new();
676 NodesStats {
677 transport,
678 parts,
679 headers,
680 completion_fields: None,
681 error_trace: None,
682 fielddata_fields: None,
683 fields: None,
684 filter_path: None,
685 groups: None,
686 human: None,
687 include_segment_file_sizes: None,
688 level: None,
689 pretty: None,
690 request_timeout: None,
691 source: None,
692 timeout: None,
693 types: None,
694 }
695 }
696 #[doc = "A comma-separated list of fields for `fielddata` and `suggest` index metric (supports wildcards)"]
697 pub fn completion_fields(mut self, completion_fields: &'b [&'b str]) -> Self {
698 self.completion_fields = Some(completion_fields);
699 self
700 }
701 #[doc = "Include the stack trace of returned errors."]
702 pub fn error_trace(mut self, error_trace: bool) -> Self {
703 self.error_trace = Some(error_trace);
704 self
705 }
706 #[doc = "A comma-separated list of fields for `fielddata` index metric (supports wildcards)"]
707 pub fn fielddata_fields(mut self, fielddata_fields: &'b [&'b str]) -> Self {
708 self.fielddata_fields = Some(fielddata_fields);
709 self
710 }
711 #[doc = "A comma-separated list of fields for `fielddata` and `completion` index metric (supports wildcards)"]
712 pub fn fields(mut self, fields: &'b [&'b str]) -> Self {
713 self.fields = Some(fields);
714 self
715 }
716 #[doc = "A comma-separated list of filters used to reduce the response."]
717 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
718 self.filter_path = Some(filter_path);
719 self
720 }
721 #[doc = "A comma-separated list of search groups for `search` index metric"]
722 pub fn groups(mut self, groups: bool) -> Self {
723 self.groups = Some(groups);
724 self
725 }
726 #[doc = "Adds a HTTP header"]
727 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
728 self.headers.insert(key, value);
729 self
730 }
731 #[doc = "Return human readable values for statistics."]
732 pub fn human(mut self, human: bool) -> Self {
733 self.human = Some(human);
734 self
735 }
736 #[doc = "Whether to report the aggregated disk usage of each one of the Lucene index files (only applies if segment stats are requested)"]
737 pub fn include_segment_file_sizes(mut self, include_segment_file_sizes: bool) -> Self {
738 self.include_segment_file_sizes = Some(include_segment_file_sizes);
739 self
740 }
741 #[doc = "Return indices stats aggregated at index, node or shard level"]
742 pub fn level(mut self, level: Level) -> Self {
743 self.level = Some(level);
744 self
745 }
746 #[doc = "Pretty format the returned JSON response."]
747 pub fn pretty(mut self, pretty: bool) -> Self {
748 self.pretty = Some(pretty);
749 self
750 }
751 #[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."]
752 pub fn request_timeout(mut self, timeout: Duration) -> Self {
753 self.request_timeout = Some(timeout);
754 self
755 }
756 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
757 pub fn source(mut self, source: &'b str) -> Self {
758 self.source = Some(source);
759 self
760 }
761 #[doc = "Explicit operation timeout"]
762 pub fn timeout(mut self, timeout: &'b str) -> Self {
763 self.timeout = Some(timeout);
764 self
765 }
766 #[doc = "A comma-separated list of document types for the `indexing` index metric"]
767 pub fn types(mut self, types: &'b [&'b str]) -> Self {
768 self.types = Some(types);
769 self
770 }
771 #[doc = "Creates an asynchronous call to the Nodes Stats API that can be awaited"]
772 pub async fn send(self) -> Result<Response, Error> {
773 let path = self.parts.url();
774 let method = Method::Get;
775 let headers = self.headers;
776 let timeout = self.request_timeout;
777 let query_string = {
778 #[serde_with::skip_serializing_none]
779 #[derive(Serialize)]
780 struct QueryParams<'b> {
781 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
782 completion_fields: Option<&'b [&'b str]>,
783 error_trace: Option<bool>,
784 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
785 fielddata_fields: Option<&'b [&'b str]>,
786 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
787 fields: Option<&'b [&'b str]>,
788 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
789 filter_path: Option<&'b [&'b str]>,
790 groups: Option<bool>,
791 human: Option<bool>,
792 include_segment_file_sizes: Option<bool>,
793 level: Option<Level>,
794 pretty: Option<bool>,
795 source: Option<&'b str>,
796 timeout: Option<&'b str>,
797 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
798 types: Option<&'b [&'b str]>,
799 }
800 let query_params = QueryParams {
801 completion_fields: self.completion_fields,
802 error_trace: self.error_trace,
803 fielddata_fields: self.fielddata_fields,
804 fields: self.fields,
805 filter_path: self.filter_path,
806 groups: self.groups,
807 human: self.human,
808 include_segment_file_sizes: self.include_segment_file_sizes,
809 level: self.level,
810 pretty: self.pretty,
811 source: self.source,
812 timeout: self.timeout,
813 types: self.types,
814 };
815 Some(query_params)
816 };
817 let body = Option::<()>::None;
818 let response = self
819 .transport
820 .send(method, &path, headers, query_string.as_ref(), body, timeout)
821 .await?;
822 Ok(response)
823 }
824}
825#[derive(Debug, Clone, PartialEq)]
826#[doc = "API parts for the Nodes Usage API"]
827pub enum NodesUsageParts<'b> {
828 #[doc = "No parts"]
829 None,
830 #[doc = "NodeId"]
831 NodeId(&'b [&'b str]),
832 #[doc = "Metric"]
833 Metric(&'b [&'b str]),
834 #[doc = "NodeId and Metric"]
835 NodeIdMetric(&'b [&'b str], &'b [&'b str]),
836}
837impl<'b> NodesUsageParts<'b> {
838 #[doc = "Builds a relative URL path to the Nodes Usage API"]
839 pub fn url(self) -> Cow<'static, str> {
840 match self {
841 NodesUsageParts::None => "/_nodes/usage".into(),
842 NodesUsageParts::NodeId(ref node_id) => {
843 let node_id_str = node_id.join(",");
844 let encoded_node_id: Cow<str> =
845 percent_encode(node_id_str.as_bytes(), PARTS_ENCODED).into();
846 let mut p = String::with_capacity(14usize + encoded_node_id.len());
847 p.push_str("/_nodes/");
848 p.push_str(encoded_node_id.as_ref());
849 p.push_str("/usage");
850 p.into()
851 }
852 NodesUsageParts::Metric(ref metric) => {
853 let metric_str = metric.join(",");
854 let encoded_metric: Cow<str> =
855 percent_encode(metric_str.as_bytes(), PARTS_ENCODED).into();
856 let mut p = String::with_capacity(14usize + encoded_metric.len());
857 p.push_str("/_nodes/usage/");
858 p.push_str(encoded_metric.as_ref());
859 p.into()
860 }
861 NodesUsageParts::NodeIdMetric(ref node_id, ref metric) => {
862 let node_id_str = node_id.join(",");
863 let metric_str = metric.join(",");
864 let encoded_node_id: Cow<str> =
865 percent_encode(node_id_str.as_bytes(), PARTS_ENCODED).into();
866 let encoded_metric: Cow<str> =
867 percent_encode(metric_str.as_bytes(), PARTS_ENCODED).into();
868 let mut p =
869 String::with_capacity(15usize + encoded_node_id.len() + encoded_metric.len());
870 p.push_str("/_nodes/");
871 p.push_str(encoded_node_id.as_ref());
872 p.push_str("/usage/");
873 p.push_str(encoded_metric.as_ref());
874 p.into()
875 }
876 }
877 }
878}
879#[doc = "Builder for the [Nodes Usage API](https://opensearch.org/docs/)\n\nReturns low-level information about REST actions usage on nodes."]
880#[derive(Clone, Debug)]
881pub struct NodesUsage<'a, 'b> {
882 transport: &'a Transport,
883 parts: NodesUsageParts<'b>,
884 error_trace: Option<bool>,
885 filter_path: Option<&'b [&'b str]>,
886 headers: HeaderMap,
887 human: Option<bool>,
888 pretty: Option<bool>,
889 request_timeout: Option<Duration>,
890 source: Option<&'b str>,
891 timeout: Option<&'b str>,
892}
893impl<'a, 'b> NodesUsage<'a, 'b> {
894 #[doc = "Creates a new instance of [NodesUsage] with the specified API parts"]
895 pub fn new(transport: &'a Transport, parts: NodesUsageParts<'b>) -> Self {
896 let headers = HeaderMap::new();
897 NodesUsage {
898 transport,
899 parts,
900 headers,
901 error_trace: None,
902 filter_path: None,
903 human: None,
904 pretty: None,
905 request_timeout: None,
906 source: None,
907 timeout: None,
908 }
909 }
910 #[doc = "Include the stack trace of returned errors."]
911 pub fn error_trace(mut self, error_trace: bool) -> Self {
912 self.error_trace = Some(error_trace);
913 self
914 }
915 #[doc = "A comma-separated list of filters used to reduce the response."]
916 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
917 self.filter_path = Some(filter_path);
918 self
919 }
920 #[doc = "Adds a HTTP header"]
921 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
922 self.headers.insert(key, value);
923 self
924 }
925 #[doc = "Return human readable values for statistics."]
926 pub fn human(mut self, human: bool) -> Self {
927 self.human = Some(human);
928 self
929 }
930 #[doc = "Pretty format the returned JSON response."]
931 pub fn pretty(mut self, pretty: bool) -> Self {
932 self.pretty = Some(pretty);
933 self
934 }
935 #[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."]
936 pub fn request_timeout(mut self, timeout: Duration) -> Self {
937 self.request_timeout = Some(timeout);
938 self
939 }
940 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
941 pub fn source(mut self, source: &'b str) -> Self {
942 self.source = Some(source);
943 self
944 }
945 #[doc = "Explicit operation timeout"]
946 pub fn timeout(mut self, timeout: &'b str) -> Self {
947 self.timeout = Some(timeout);
948 self
949 }
950 #[doc = "Creates an asynchronous call to the Nodes Usage API that can be awaited"]
951 pub async fn send(self) -> Result<Response, Error> {
952 let path = self.parts.url();
953 let method = Method::Get;
954 let headers = self.headers;
955 let timeout = self.request_timeout;
956 let query_string = {
957 #[serde_with::skip_serializing_none]
958 #[derive(Serialize)]
959 struct QueryParams<'b> {
960 error_trace: Option<bool>,
961 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
962 filter_path: Option<&'b [&'b str]>,
963 human: Option<bool>,
964 pretty: Option<bool>,
965 source: Option<&'b str>,
966 timeout: Option<&'b str>,
967 }
968 let query_params = QueryParams {
969 error_trace: self.error_trace,
970 filter_path: self.filter_path,
971 human: self.human,
972 pretty: self.pretty,
973 source: self.source,
974 timeout: self.timeout,
975 };
976 Some(query_params)
977 };
978 let body = Option::<()>::None;
979 let response = self
980 .transport
981 .send(method, &path, headers, query_string.as_ref(), body, timeout)
982 .await?;
983 Ok(response)
984 }
985}
986#[doc = "Namespace client for Nodes APIs"]
987pub struct Nodes<'a> {
988 transport: &'a Transport,
989}
990impl<'a> Nodes<'a> {
991 #[doc = "Creates a new instance of [Nodes]"]
992 pub fn new(transport: &'a Transport) -> Self {
993 Self { transport }
994 }
995 pub fn transport(&self) -> &Transport {
996 self.transport
997 }
998 #[doc = "[Nodes Hot Threads API](https://opensearch.org/docs/)\n\nReturns information about hot threads on each node in the cluster."]
999 pub fn hot_threads<'b>(&'a self, parts: NodesHotThreadsParts<'b>) -> NodesHotThreads<'a, 'b> {
1000 NodesHotThreads::new(self.transport(), parts)
1001 }
1002 #[doc = "[Nodes Info API](https://opensearch.org/docs/)\n\nReturns information about nodes in the cluster."]
1003 pub fn info<'b>(&'a self, parts: NodesInfoParts<'b>) -> NodesInfo<'a, 'b> {
1004 NodesInfo::new(self.transport(), parts)
1005 }
1006 #[doc = "[Nodes Reload Secure Settings API](https://opensearch.org/docs/)\n\nReloads secure settings."]
1007 pub fn reload_secure_settings<'b>(
1008 &'a self,
1009 parts: NodesReloadSecureSettingsParts<'b>,
1010 ) -> NodesReloadSecureSettings<'a, 'b, ()> {
1011 NodesReloadSecureSettings::new(self.transport(), parts)
1012 }
1013 #[doc = "[Nodes Stats API](https://opensearch.org/docs/)\n\nReturns statistical information about nodes in the cluster."]
1014 pub fn stats<'b>(&'a self, parts: NodesStatsParts<'b>) -> NodesStats<'a, 'b> {
1015 NodesStats::new(self.transport(), parts)
1016 }
1017 #[doc = "[Nodes Usage API](https://opensearch.org/docs/)\n\nReturns low-level information about REST actions usage on nodes."]
1018 pub fn usage<'b>(&'a self, parts: NodesUsageParts<'b>) -> NodesUsage<'a, 'b> {
1019 NodesUsage::new(self.transport(), parts)
1020 }
1021}
1022impl OpenSearch {
1023 #[doc = "Creates a namespace client for Nodes APIs"]
1024 pub fn nodes(&self) -> Nodes {
1025 Nodes::new(self.transport())
1026 }
1027}