1#![allow(unused_imports)]
44use crate::{
45 client::OpenSearch,
46 error::Error,
47 http::{
48 headers::{HeaderMap, HeaderName, HeaderValue, ACCEPT, CONTENT_TYPE},
49 request::{Body, JsonBody, NdBody, PARTS_ENCODED},
50 response::Response,
51 transport::Transport,
52 Method,
53 },
54 params::*,
55};
56use percent_encoding::percent_encode;
57use serde::Serialize;
58use std::{borrow::Cow, time::Duration};
59#[derive(Debug, Clone, PartialEq, Eq)]
60#[doc = "API parts for the Ingest Delete Pipeline API"]
61pub enum IngestDeletePipelineParts<'b> {
62 #[doc = "Id"]
63 Id(&'b str),
64}
65impl<'b> IngestDeletePipelineParts<'b> {
66 #[doc = "Builds a relative URL path to the Ingest Delete Pipeline API"]
67 pub fn url(self) -> Cow<'static, str> {
68 match self {
69 IngestDeletePipelineParts::Id(id) => {
70 let encoded_id: Cow<str> = percent_encode(id.as_bytes(), PARTS_ENCODED).into();
71 let mut p = String::with_capacity(18usize + encoded_id.len());
72 p.push_str("/_ingest/pipeline/");
73 p.push_str(encoded_id.as_ref());
74 p.into()
75 }
76 }
77 }
78}
79#[doc = "Builder for the [Ingest Delete Pipeline API](https://opensearch.org/docs/)\n\nDeletes a pipeline."]
80#[derive(Clone, Debug)]
81pub struct IngestDeletePipeline<'a, 'b> {
82 transport: &'a Transport,
83 parts: IngestDeletePipelineParts<'b>,
84 cluster_manager_timeout: Option<&'b str>,
85 error_trace: Option<bool>,
86 filter_path: Option<&'b [&'b str]>,
87 headers: HeaderMap,
88 human: Option<bool>,
89 master_timeout: Option<&'b str>,
90 pretty: Option<bool>,
91 request_timeout: Option<Duration>,
92 source: Option<&'b str>,
93 timeout: Option<&'b str>,
94}
95impl<'a, 'b> IngestDeletePipeline<'a, 'b> {
96 #[doc = "Creates a new instance of [IngestDeletePipeline] with the specified API parts"]
97 pub fn new(transport: &'a Transport, parts: IngestDeletePipelineParts<'b>) -> Self {
98 let headers = HeaderMap::new();
99 IngestDeletePipeline {
100 transport,
101 parts,
102 headers,
103 cluster_manager_timeout: None,
104 error_trace: None,
105 filter_path: None,
106 human: None,
107 master_timeout: None,
108 pretty: None,
109 request_timeout: None,
110 source: None,
111 timeout: None,
112 }
113 }
114 #[doc = "Explicit operation timeout for connection to cluster-manager node"]
115 pub fn cluster_manager_timeout(mut self, cluster_manager_timeout: &'b str) -> Self {
116 self.cluster_manager_timeout = Some(cluster_manager_timeout);
117 self
118 }
119 #[doc = "Include the stack trace of returned errors."]
120 pub fn error_trace(mut self, error_trace: bool) -> Self {
121 self.error_trace = Some(error_trace);
122 self
123 }
124 #[doc = "A comma-separated list of filters used to reduce the response."]
125 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
126 self.filter_path = Some(filter_path);
127 self
128 }
129 #[doc = "Adds a HTTP header"]
130 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
131 self.headers.insert(key, value);
132 self
133 }
134 #[doc = "Return human readable values for statistics."]
135 pub fn human(mut self, human: bool) -> Self {
136 self.human = Some(human);
137 self
138 }
139 #[doc = "Explicit operation timeout for connection to cluster-manager node"]
140 #[deprecated = "To support inclusive language, use 'cluster_manager_timeout' instead."]
141 pub fn master_timeout(mut self, master_timeout: &'b str) -> Self {
142 self.master_timeout = Some(master_timeout);
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 = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
156 pub fn source(mut self, source: &'b str) -> Self {
157 self.source = Some(source);
158 self
159 }
160 #[doc = "Explicit operation timeout"]
161 pub fn timeout(mut self, timeout: &'b str) -> Self {
162 self.timeout = Some(timeout);
163 self
164 }
165 #[doc = "Creates an asynchronous call to the Ingest Delete Pipeline API that can be awaited"]
166 pub async fn send(self) -> Result<Response, Error> {
167 let path = self.parts.url();
168 let method = Method::Delete;
169 let headers = self.headers;
170 let timeout = self.request_timeout;
171 let query_string = {
172 #[serde_with::skip_serializing_none]
173 #[derive(Serialize)]
174 struct QueryParams<'b> {
175 cluster_manager_timeout: Option<&'b str>,
176 error_trace: Option<bool>,
177 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
178 filter_path: Option<&'b [&'b str]>,
179 human: Option<bool>,
180 master_timeout: Option<&'b str>,
181 pretty: Option<bool>,
182 source: Option<&'b str>,
183 timeout: Option<&'b str>,
184 }
185 let query_params = QueryParams {
186 cluster_manager_timeout: self.cluster_manager_timeout,
187 error_trace: self.error_trace,
188 filter_path: self.filter_path,
189 human: self.human,
190 master_timeout: self.master_timeout,
191 pretty: self.pretty,
192 source: self.source,
193 timeout: self.timeout,
194 };
195 Some(query_params)
196 };
197 let body = Option::<()>::None;
198 let response = self
199 .transport
200 .send(method, &path, headers, query_string.as_ref(), body, timeout)
201 .await?;
202 Ok(response)
203 }
204}
205#[derive(Debug, Clone, PartialEq, Eq)]
206#[doc = "API parts for the Ingest Get Pipeline API"]
207pub enum IngestGetPipelineParts<'b> {
208 #[doc = "No parts"]
209 None,
210 #[doc = "Id"]
211 Id(&'b str),
212}
213impl<'b> IngestGetPipelineParts<'b> {
214 #[doc = "Builds a relative URL path to the Ingest Get Pipeline API"]
215 pub fn url(self) -> Cow<'static, str> {
216 match self {
217 IngestGetPipelineParts::None => "/_ingest/pipeline".into(),
218 IngestGetPipelineParts::Id(id) => {
219 let encoded_id: Cow<str> = percent_encode(id.as_bytes(), PARTS_ENCODED).into();
220 let mut p = String::with_capacity(18usize + encoded_id.len());
221 p.push_str("/_ingest/pipeline/");
222 p.push_str(encoded_id.as_ref());
223 p.into()
224 }
225 }
226 }
227}
228#[doc = "Builder for the [Ingest Get Pipeline API](https://opensearch.org/docs/)\n\nReturns a pipeline."]
229#[derive(Clone, Debug)]
230pub struct IngestGetPipeline<'a, 'b> {
231 transport: &'a Transport,
232 parts: IngestGetPipelineParts<'b>,
233 cluster_manager_timeout: Option<&'b str>,
234 error_trace: Option<bool>,
235 filter_path: Option<&'b [&'b str]>,
236 headers: HeaderMap,
237 human: Option<bool>,
238 master_timeout: Option<&'b str>,
239 pretty: Option<bool>,
240 request_timeout: Option<Duration>,
241 source: Option<&'b str>,
242}
243impl<'a, 'b> IngestGetPipeline<'a, 'b> {
244 #[doc = "Creates a new instance of [IngestGetPipeline] with the specified API parts"]
245 pub fn new(transport: &'a Transport, parts: IngestGetPipelineParts<'b>) -> Self {
246 let headers = HeaderMap::new();
247 IngestGetPipeline {
248 transport,
249 parts,
250 headers,
251 cluster_manager_timeout: None,
252 error_trace: None,
253 filter_path: None,
254 human: None,
255 master_timeout: None,
256 pretty: None,
257 request_timeout: None,
258 source: None,
259 }
260 }
261 #[doc = "Explicit operation timeout for connection to cluster-manager node"]
262 pub fn cluster_manager_timeout(mut self, cluster_manager_timeout: &'b str) -> Self {
263 self.cluster_manager_timeout = Some(cluster_manager_timeout);
264 self
265 }
266 #[doc = "Include the stack trace of returned errors."]
267 pub fn error_trace(mut self, error_trace: bool) -> Self {
268 self.error_trace = Some(error_trace);
269 self
270 }
271 #[doc = "A comma-separated list of filters used to reduce the response."]
272 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
273 self.filter_path = Some(filter_path);
274 self
275 }
276 #[doc = "Adds a HTTP header"]
277 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
278 self.headers.insert(key, value);
279 self
280 }
281 #[doc = "Return human readable values for statistics."]
282 pub fn human(mut self, human: bool) -> Self {
283 self.human = Some(human);
284 self
285 }
286 #[doc = "Explicit operation timeout for connection to cluster-manager node"]
287 #[deprecated = "To support inclusive language, use 'cluster_manager_timeout' instead."]
288 pub fn master_timeout(mut self, master_timeout: &'b str) -> Self {
289 self.master_timeout = Some(master_timeout);
290 self
291 }
292 #[doc = "Pretty format the returned JSON response."]
293 pub fn pretty(mut self, pretty: bool) -> Self {
294 self.pretty = Some(pretty);
295 self
296 }
297 #[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."]
298 pub fn request_timeout(mut self, timeout: Duration) -> Self {
299 self.request_timeout = Some(timeout);
300 self
301 }
302 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
303 pub fn source(mut self, source: &'b str) -> Self {
304 self.source = Some(source);
305 self
306 }
307 #[doc = "Creates an asynchronous call to the Ingest Get Pipeline API that can be awaited"]
308 pub async fn send(self) -> Result<Response, Error> {
309 let path = self.parts.url();
310 let method = Method::Get;
311 let headers = self.headers;
312 let timeout = self.request_timeout;
313 let query_string = {
314 #[serde_with::skip_serializing_none]
315 #[derive(Serialize)]
316 struct QueryParams<'b> {
317 cluster_manager_timeout: Option<&'b str>,
318 error_trace: Option<bool>,
319 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
320 filter_path: Option<&'b [&'b str]>,
321 human: Option<bool>,
322 master_timeout: Option<&'b str>,
323 pretty: Option<bool>,
324 source: Option<&'b str>,
325 }
326 let query_params = QueryParams {
327 cluster_manager_timeout: self.cluster_manager_timeout,
328 error_trace: self.error_trace,
329 filter_path: self.filter_path,
330 human: self.human,
331 master_timeout: self.master_timeout,
332 pretty: self.pretty,
333 source: self.source,
334 };
335 Some(query_params)
336 };
337 let body = Option::<()>::None;
338 let response = self
339 .transport
340 .send(method, &path, headers, query_string.as_ref(), body, timeout)
341 .await?;
342 Ok(response)
343 }
344}
345#[derive(Debug, Clone, PartialEq, Eq)]
346#[doc = "API parts for the Ingest Processor Grok API"]
347pub enum IngestProcessorGrokParts {
348 #[doc = "No parts"]
349 None,
350}
351impl IngestProcessorGrokParts {
352 #[doc = "Builds a relative URL path to the Ingest Processor Grok API"]
353 pub fn url(self) -> Cow<'static, str> {
354 match self {
355 IngestProcessorGrokParts::None => "/_ingest/processor/grok".into(),
356 }
357 }
358}
359#[doc = "Builder for the [Ingest Processor Grok API](https://opensearch.org/docs/)\n\nReturns a list of the built-in patterns."]
360#[derive(Clone, Debug)]
361pub struct IngestProcessorGrok<'a, 'b> {
362 transport: &'a Transport,
363 parts: IngestProcessorGrokParts,
364 error_trace: Option<bool>,
365 filter_path: Option<&'b [&'b str]>,
366 headers: HeaderMap,
367 human: Option<bool>,
368 pretty: Option<bool>,
369 request_timeout: Option<Duration>,
370 source: Option<&'b str>,
371}
372impl<'a, 'b> IngestProcessorGrok<'a, 'b> {
373 #[doc = "Creates a new instance of [IngestProcessorGrok]"]
374 pub fn new(transport: &'a Transport) -> Self {
375 let headers = HeaderMap::new();
376 IngestProcessorGrok {
377 transport,
378 parts: IngestProcessorGrokParts::None,
379 headers,
380 error_trace: None,
381 filter_path: None,
382 human: None,
383 pretty: None,
384 request_timeout: None,
385 source: None,
386 }
387 }
388 #[doc = "Include the stack trace of returned errors."]
389 pub fn error_trace(mut self, error_trace: bool) -> Self {
390 self.error_trace = Some(error_trace);
391 self
392 }
393 #[doc = "A comma-separated list of filters used to reduce the response."]
394 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
395 self.filter_path = Some(filter_path);
396 self
397 }
398 #[doc = "Adds a HTTP header"]
399 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
400 self.headers.insert(key, value);
401 self
402 }
403 #[doc = "Return human readable values for statistics."]
404 pub fn human(mut self, human: bool) -> Self {
405 self.human = Some(human);
406 self
407 }
408 #[doc = "Pretty format the returned JSON response."]
409 pub fn pretty(mut self, pretty: bool) -> Self {
410 self.pretty = Some(pretty);
411 self
412 }
413 #[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."]
414 pub fn request_timeout(mut self, timeout: Duration) -> Self {
415 self.request_timeout = Some(timeout);
416 self
417 }
418 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
419 pub fn source(mut self, source: &'b str) -> Self {
420 self.source = Some(source);
421 self
422 }
423 #[doc = "Creates an asynchronous call to the Ingest Processor Grok API that can be awaited"]
424 pub async fn send(self) -> Result<Response, Error> {
425 let path = self.parts.url();
426 let method = Method::Get;
427 let headers = self.headers;
428 let timeout = self.request_timeout;
429 let query_string = {
430 #[serde_with::skip_serializing_none]
431 #[derive(Serialize)]
432 struct QueryParams<'b> {
433 error_trace: Option<bool>,
434 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
435 filter_path: Option<&'b [&'b str]>,
436 human: Option<bool>,
437 pretty: Option<bool>,
438 source: Option<&'b str>,
439 }
440 let query_params = QueryParams {
441 error_trace: self.error_trace,
442 filter_path: self.filter_path,
443 human: self.human,
444 pretty: self.pretty,
445 source: self.source,
446 };
447 Some(query_params)
448 };
449 let body = Option::<()>::None;
450 let response = self
451 .transport
452 .send(method, &path, headers, query_string.as_ref(), body, timeout)
453 .await?;
454 Ok(response)
455 }
456}
457#[derive(Debug, Clone, PartialEq, Eq)]
458#[doc = "API parts for the Ingest Put Pipeline API"]
459pub enum IngestPutPipelineParts<'b> {
460 #[doc = "Id"]
461 Id(&'b str),
462}
463impl<'b> IngestPutPipelineParts<'b> {
464 #[doc = "Builds a relative URL path to the Ingest Put Pipeline API"]
465 pub fn url(self) -> Cow<'static, str> {
466 match self {
467 IngestPutPipelineParts::Id(id) => {
468 let encoded_id: Cow<str> = percent_encode(id.as_bytes(), PARTS_ENCODED).into();
469 let mut p = String::with_capacity(18usize + encoded_id.len());
470 p.push_str("/_ingest/pipeline/");
471 p.push_str(encoded_id.as_ref());
472 p.into()
473 }
474 }
475 }
476}
477#[doc = "Builder for the [Ingest Put Pipeline API](https://opensearch.org/docs/)\n\nCreates or updates a pipeline."]
478#[derive(Clone, Debug)]
479pub struct IngestPutPipeline<'a, 'b, B> {
480 transport: &'a Transport,
481 parts: IngestPutPipelineParts<'b>,
482 body: Option<B>,
483 cluster_manager_timeout: Option<&'b str>,
484 error_trace: Option<bool>,
485 filter_path: Option<&'b [&'b str]>,
486 headers: HeaderMap,
487 human: Option<bool>,
488 master_timeout: Option<&'b str>,
489 pretty: Option<bool>,
490 request_timeout: Option<Duration>,
491 source: Option<&'b str>,
492 timeout: Option<&'b str>,
493}
494impl<'a, 'b, B> IngestPutPipeline<'a, 'b, B>
495where
496 B: Body,
497{
498 #[doc = "Creates a new instance of [IngestPutPipeline] with the specified API parts"]
499 pub fn new(transport: &'a Transport, parts: IngestPutPipelineParts<'b>) -> Self {
500 let headers = HeaderMap::new();
501 IngestPutPipeline {
502 transport,
503 parts,
504 headers,
505 body: None,
506 cluster_manager_timeout: None,
507 error_trace: None,
508 filter_path: None,
509 human: None,
510 master_timeout: None,
511 pretty: None,
512 request_timeout: None,
513 source: None,
514 timeout: None,
515 }
516 }
517 #[doc = "The body for the API call"]
518 pub fn body<T>(self, body: T) -> IngestPutPipeline<'a, 'b, JsonBody<T>>
519 where
520 T: Serialize,
521 {
522 IngestPutPipeline {
523 transport: self.transport,
524 parts: self.parts,
525 body: Some(body.into()),
526 cluster_manager_timeout: self.cluster_manager_timeout,
527 error_trace: self.error_trace,
528 filter_path: self.filter_path,
529 headers: self.headers,
530 human: self.human,
531 master_timeout: self.master_timeout,
532 pretty: self.pretty,
533 request_timeout: self.request_timeout,
534 source: self.source,
535 timeout: self.timeout,
536 }
537 }
538 #[doc = "Explicit operation timeout for connection to cluster-manager node"]
539 pub fn cluster_manager_timeout(mut self, cluster_manager_timeout: &'b str) -> Self {
540 self.cluster_manager_timeout = Some(cluster_manager_timeout);
541 self
542 }
543 #[doc = "Include the stack trace of returned errors."]
544 pub fn error_trace(mut self, error_trace: bool) -> Self {
545 self.error_trace = Some(error_trace);
546 self
547 }
548 #[doc = "A comma-separated list of filters used to reduce the response."]
549 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
550 self.filter_path = Some(filter_path);
551 self
552 }
553 #[doc = "Adds a HTTP header"]
554 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
555 self.headers.insert(key, value);
556 self
557 }
558 #[doc = "Return human readable values for statistics."]
559 pub fn human(mut self, human: bool) -> Self {
560 self.human = Some(human);
561 self
562 }
563 #[doc = "Explicit operation timeout for connection to cluster-manager node"]
564 #[deprecated = "To support inclusive language, use 'cluster_manager_timeout' instead."]
565 pub fn master_timeout(mut self, master_timeout: &'b str) -> Self {
566 self.master_timeout = Some(master_timeout);
567 self
568 }
569 #[doc = "Pretty format the returned JSON response."]
570 pub fn pretty(mut self, pretty: bool) -> Self {
571 self.pretty = Some(pretty);
572 self
573 }
574 #[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."]
575 pub fn request_timeout(mut self, timeout: Duration) -> Self {
576 self.request_timeout = Some(timeout);
577 self
578 }
579 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
580 pub fn source(mut self, source: &'b str) -> Self {
581 self.source = Some(source);
582 self
583 }
584 #[doc = "Explicit operation timeout"]
585 pub fn timeout(mut self, timeout: &'b str) -> Self {
586 self.timeout = Some(timeout);
587 self
588 }
589 #[doc = "Creates an asynchronous call to the Ingest Put Pipeline API that can be awaited"]
590 pub async fn send(self) -> Result<Response, Error> {
591 let path = self.parts.url();
592 let method = Method::Put;
593 let headers = self.headers;
594 let timeout = self.request_timeout;
595 let query_string = {
596 #[serde_with::skip_serializing_none]
597 #[derive(Serialize)]
598 struct QueryParams<'b> {
599 cluster_manager_timeout: Option<&'b str>,
600 error_trace: Option<bool>,
601 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
602 filter_path: Option<&'b [&'b str]>,
603 human: Option<bool>,
604 master_timeout: Option<&'b str>,
605 pretty: Option<bool>,
606 source: Option<&'b str>,
607 timeout: Option<&'b str>,
608 }
609 let query_params = QueryParams {
610 cluster_manager_timeout: self.cluster_manager_timeout,
611 error_trace: self.error_trace,
612 filter_path: self.filter_path,
613 human: self.human,
614 master_timeout: self.master_timeout,
615 pretty: self.pretty,
616 source: self.source,
617 timeout: self.timeout,
618 };
619 Some(query_params)
620 };
621 let body = self.body;
622 let response = self
623 .transport
624 .send(method, &path, headers, query_string.as_ref(), body, timeout)
625 .await?;
626 Ok(response)
627 }
628}
629#[derive(Debug, Clone, PartialEq, Eq)]
630#[doc = "API parts for the Ingest Simulate API"]
631pub enum IngestSimulateParts<'b> {
632 #[doc = "No parts"]
633 None,
634 #[doc = "Id"]
635 Id(&'b str),
636}
637impl<'b> IngestSimulateParts<'b> {
638 #[doc = "Builds a relative URL path to the Ingest Simulate API"]
639 pub fn url(self) -> Cow<'static, str> {
640 match self {
641 IngestSimulateParts::None => "/_ingest/pipeline/_simulate".into(),
642 IngestSimulateParts::Id(id) => {
643 let encoded_id: Cow<str> = percent_encode(id.as_bytes(), PARTS_ENCODED).into();
644 let mut p = String::with_capacity(28usize + encoded_id.len());
645 p.push_str("/_ingest/pipeline/");
646 p.push_str(encoded_id.as_ref());
647 p.push_str("/_simulate");
648 p.into()
649 }
650 }
651 }
652}
653#[doc = "Builder for the [Ingest Simulate API](https://opensearch.org/docs/)\n\nAllows to simulate a pipeline with example documents."]
654#[derive(Clone, Debug)]
655pub struct IngestSimulate<'a, 'b, B> {
656 transport: &'a Transport,
657 parts: IngestSimulateParts<'b>,
658 body: Option<B>,
659 error_trace: Option<bool>,
660 filter_path: Option<&'b [&'b str]>,
661 headers: HeaderMap,
662 human: Option<bool>,
663 pretty: Option<bool>,
664 request_timeout: Option<Duration>,
665 source: Option<&'b str>,
666 verbose: Option<bool>,
667}
668impl<'a, 'b, B> IngestSimulate<'a, 'b, B>
669where
670 B: Body,
671{
672 #[doc = "Creates a new instance of [IngestSimulate] with the specified API parts"]
673 pub fn new(transport: &'a Transport, parts: IngestSimulateParts<'b>) -> Self {
674 let headers = HeaderMap::new();
675 IngestSimulate {
676 transport,
677 parts,
678 headers,
679 body: None,
680 error_trace: None,
681 filter_path: None,
682 human: None,
683 pretty: None,
684 request_timeout: None,
685 source: None,
686 verbose: None,
687 }
688 }
689 #[doc = "The body for the API call"]
690 pub fn body<T>(self, body: T) -> IngestSimulate<'a, 'b, JsonBody<T>>
691 where
692 T: Serialize,
693 {
694 IngestSimulate {
695 transport: self.transport,
696 parts: self.parts,
697 body: Some(body.into()),
698 error_trace: self.error_trace,
699 filter_path: self.filter_path,
700 headers: self.headers,
701 human: self.human,
702 pretty: self.pretty,
703 request_timeout: self.request_timeout,
704 source: self.source,
705 verbose: self.verbose,
706 }
707 }
708 #[doc = "Include the stack trace of returned errors."]
709 pub fn error_trace(mut self, error_trace: bool) -> Self {
710 self.error_trace = Some(error_trace);
711 self
712 }
713 #[doc = "A comma-separated list of filters used to reduce the response."]
714 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
715 self.filter_path = Some(filter_path);
716 self
717 }
718 #[doc = "Adds a HTTP header"]
719 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
720 self.headers.insert(key, value);
721 self
722 }
723 #[doc = "Return human readable values for statistics."]
724 pub fn human(mut self, human: bool) -> Self {
725 self.human = Some(human);
726 self
727 }
728 #[doc = "Pretty format the returned JSON response."]
729 pub fn pretty(mut self, pretty: bool) -> Self {
730 self.pretty = Some(pretty);
731 self
732 }
733 #[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."]
734 pub fn request_timeout(mut self, timeout: Duration) -> Self {
735 self.request_timeout = Some(timeout);
736 self
737 }
738 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
739 pub fn source(mut self, source: &'b str) -> Self {
740 self.source = Some(source);
741 self
742 }
743 #[doc = "Verbose mode. Display data output for each processor in executed pipeline"]
744 pub fn verbose(mut self, verbose: bool) -> Self {
745 self.verbose = Some(verbose);
746 self
747 }
748 #[doc = "Creates an asynchronous call to the Ingest Simulate API that can be awaited"]
749 pub async fn send(self) -> Result<Response, Error> {
750 let path = self.parts.url();
751 let method = match self.body {
752 Some(_) => Method::Post,
753 None => Method::Get,
754 };
755 let headers = self.headers;
756 let timeout = self.request_timeout;
757 let query_string = {
758 #[serde_with::skip_serializing_none]
759 #[derive(Serialize)]
760 struct QueryParams<'b> {
761 error_trace: Option<bool>,
762 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
763 filter_path: Option<&'b [&'b str]>,
764 human: Option<bool>,
765 pretty: Option<bool>,
766 source: Option<&'b str>,
767 verbose: Option<bool>,
768 }
769 let query_params = QueryParams {
770 error_trace: self.error_trace,
771 filter_path: self.filter_path,
772 human: self.human,
773 pretty: self.pretty,
774 source: self.source,
775 verbose: self.verbose,
776 };
777 Some(query_params)
778 };
779 let body = self.body;
780 let response = self
781 .transport
782 .send(method, &path, headers, query_string.as_ref(), body, timeout)
783 .await?;
784 Ok(response)
785 }
786}
787#[doc = "Namespace client for Ingest APIs"]
788pub struct Ingest<'a> {
789 transport: &'a Transport,
790}
791impl<'a> Ingest<'a> {
792 #[doc = "Creates a new instance of [Ingest]"]
793 pub fn new(transport: &'a Transport) -> Self {
794 Self { transport }
795 }
796 pub fn transport(&self) -> &Transport {
797 self.transport
798 }
799 #[doc = "[Ingest Delete Pipeline API](https://opensearch.org/docs/)\n\nDeletes a pipeline."]
800 pub fn delete_pipeline<'b>(
801 &'a self,
802 parts: IngestDeletePipelineParts<'b>,
803 ) -> IngestDeletePipeline<'a, 'b> {
804 IngestDeletePipeline::new(self.transport(), parts)
805 }
806 #[doc = "[Ingest Get Pipeline API](https://opensearch.org/docs/)\n\nReturns a pipeline."]
807 pub fn get_pipeline<'b>(
808 &'a self,
809 parts: IngestGetPipelineParts<'b>,
810 ) -> IngestGetPipeline<'a, 'b> {
811 IngestGetPipeline::new(self.transport(), parts)
812 }
813 #[doc = "[Ingest Processor Grok API](https://opensearch.org/docs/)\n\nReturns a list of the built-in patterns."]
814 pub fn processor_grok<'b>(&'a self) -> IngestProcessorGrok<'a, 'b> {
815 IngestProcessorGrok::new(self.transport())
816 }
817 #[doc = "[Ingest Put Pipeline API](https://opensearch.org/docs/)\n\nCreates or updates a pipeline."]
818 pub fn put_pipeline<'b>(
819 &'a self,
820 parts: IngestPutPipelineParts<'b>,
821 ) -> IngestPutPipeline<'a, 'b, ()> {
822 IngestPutPipeline::new(self.transport(), parts)
823 }
824 #[doc = "[Ingest Simulate API](https://opensearch.org/docs/)\n\nAllows to simulate a pipeline with example documents."]
825 pub fn simulate<'b>(&'a self, parts: IngestSimulateParts<'b>) -> IngestSimulate<'a, 'b, ()> {
826 IngestSimulate::new(self.transport(), parts)
827 }
828}
829impl OpenSearch {
830 #[doc = "Creates a namespace client for Ingest APIs"]
831 pub fn ingest(&self) -> Ingest {
832 Ingest::new(self.transport())
833 }
834}