opensearch/root/
mod.rs

1/*
2 * Licensed to Elasticsearch B.V. under one or more contributor
3 * license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright
5 * ownership. Elasticsearch B.V. licenses this file to you under
6 * the Apache License, Version 2.0 (the "License"); you may
7 * not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 *	http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied.  See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20// -----------------------------------------------
21// This file is generated, Please do not edit it manually.
22// Run the following in the root of the repo to regenerate:
23//
24// cargo make generate-api
25// -----------------------------------------------
26
27#![allow(unused_imports)]
28use crate::{
29    client::OpenSearch,
30    error::Error,
31    http::{
32        headers::{HeaderMap, HeaderName, HeaderValue, ACCEPT, CONTENT_TYPE},
33        request::{Body, JsonBody, NdBody, PARTS_ENCODED},
34        response::Response,
35        transport::Transport,
36        Method,
37    },
38    params::*,
39};
40use percent_encoding::percent_encode;
41use serde::Serialize;
42use std::{borrow::Cow, time::Duration};
43#[derive(Debug, Clone, PartialEq, Eq)]
44#[doc = "API parts for the Bulk API"]
45pub enum BulkParts<'b> {
46    #[doc = "No parts"]
47    None,
48    #[doc = "Index"]
49    Index(&'b str),
50}
51impl<'b> BulkParts<'b> {
52    #[doc = "Builds a relative URL path to the Bulk API"]
53    pub fn url(self) -> Cow<'static, str> {
54        match self {
55            BulkParts::None => "/_bulk".into(),
56            BulkParts::Index(index) => {
57                let encoded_index: Cow<str> =
58                    percent_encode(index.as_bytes(), PARTS_ENCODED).into();
59                let mut p = String::with_capacity(7usize + encoded_index.len());
60                p.push('/');
61                p.push_str(encoded_index.as_ref());
62                p.push_str("/_bulk");
63                p.into()
64            }
65        }
66    }
67}
68#[doc = "Builder for the [Bulk API](https://opensearch.org/docs/)\n\nAllows to perform multiple index/update/delete operations in a single request."]
69#[derive(Clone, Debug)]
70pub struct Bulk<'a, 'b, B> {
71    transport: &'a Transport,
72    parts: BulkParts<'b>,
73    _source: Option<&'b [&'b str]>,
74    _source_excludes: Option<&'b [&'b str]>,
75    _source_includes: Option<&'b [&'b str]>,
76    body: Option<B>,
77    error_trace: Option<bool>,
78    filter_path: Option<&'b [&'b str]>,
79    headers: HeaderMap,
80    human: Option<bool>,
81    pipeline: Option<&'b str>,
82    pretty: Option<bool>,
83    refresh: Option<Refresh>,
84    request_timeout: Option<Duration>,
85    require_alias: Option<bool>,
86    routing: Option<&'b str>,
87    source: Option<&'b str>,
88    timeout: Option<&'b str>,
89    ty: Option<&'b str>,
90    wait_for_active_shards: Option<&'b str>,
91}
92impl<'a, 'b, B> Bulk<'a, 'b, B>
93where
94    B: Body,
95{
96    #[doc = "Creates a new instance of [Bulk] with the specified API parts"]
97    pub fn new(transport: &'a Transport, parts: BulkParts<'b>) -> Self {
98        let headers = HeaderMap::new();
99        Bulk {
100            transport,
101            parts,
102            headers,
103            _source: None,
104            _source_excludes: None,
105            _source_includes: None,
106            body: None,
107            error_trace: None,
108            filter_path: None,
109            human: None,
110            pipeline: None,
111            pretty: None,
112            refresh: None,
113            request_timeout: None,
114            require_alias: None,
115            routing: None,
116            source: None,
117            timeout: None,
118            ty: None,
119            wait_for_active_shards: None,
120        }
121    }
122    #[doc = "True or false to return the _source field or not, or default list of fields to return, can be overridden on each sub-request"]
123    pub fn _source(mut self, _source: &'b [&'b str]) -> Self {
124        self._source = Some(_source);
125        self
126    }
127    #[doc = "Default list of fields to exclude from the returned _source field, can be overridden on each sub-request"]
128    pub fn _source_excludes(mut self, _source_excludes: &'b [&'b str]) -> Self {
129        self._source_excludes = Some(_source_excludes);
130        self
131    }
132    #[doc = "Default list of fields to extract and return from the _source field, can be overridden on each sub-request"]
133    pub fn _source_includes(mut self, _source_includes: &'b [&'b str]) -> Self {
134        self._source_includes = Some(_source_includes);
135        self
136    }
137    #[doc = "The body for the API call"]
138    pub fn body<T>(self, body: Vec<T>) -> Bulk<'a, 'b, NdBody<T>>
139    where
140        T: Body,
141    {
142        Bulk {
143            transport: self.transport,
144            parts: self.parts,
145            body: Some(NdBody(body)),
146            _source: self._source,
147            _source_excludes: self._source_excludes,
148            _source_includes: self._source_includes,
149            error_trace: self.error_trace,
150            filter_path: self.filter_path,
151            headers: self.headers,
152            human: self.human,
153            pipeline: self.pipeline,
154            pretty: self.pretty,
155            refresh: self.refresh,
156            request_timeout: self.request_timeout,
157            require_alias: self.require_alias,
158            routing: self.routing,
159            source: self.source,
160            timeout: self.timeout,
161            ty: self.ty,
162            wait_for_active_shards: self.wait_for_active_shards,
163        }
164    }
165    #[doc = "Include the stack trace of returned errors."]
166    pub fn error_trace(mut self, error_trace: bool) -> Self {
167        self.error_trace = Some(error_trace);
168        self
169    }
170    #[doc = "A comma-separated list of filters used to reduce the response."]
171    pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
172        self.filter_path = Some(filter_path);
173        self
174    }
175    #[doc = "Adds a HTTP header"]
176    pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
177        self.headers.insert(key, value);
178        self
179    }
180    #[doc = "Return human readable values for statistics."]
181    pub fn human(mut self, human: bool) -> Self {
182        self.human = Some(human);
183        self
184    }
185    #[doc = "The pipeline id to preprocess incoming documents with"]
186    pub fn pipeline(mut self, pipeline: &'b str) -> Self {
187        self.pipeline = Some(pipeline);
188        self
189    }
190    #[doc = "Pretty format the returned JSON response."]
191    pub fn pretty(mut self, pretty: bool) -> Self {
192        self.pretty = Some(pretty);
193        self
194    }
195    #[doc = "If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes."]
196    pub fn refresh(mut self, refresh: Refresh) -> Self {
197        self.refresh = Some(refresh);
198        self
199    }
200    #[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."]
201    pub fn request_timeout(mut self, timeout: Duration) -> Self {
202        self.request_timeout = Some(timeout);
203        self
204    }
205    #[doc = "Sets require_alias for all incoming documents. Defaults to unset (false)"]
206    pub fn require_alias(mut self, require_alias: bool) -> Self {
207        self.require_alias = Some(require_alias);
208        self
209    }
210    #[doc = "Specific routing value"]
211    pub fn routing(mut self, routing: &'b str) -> Self {
212        self.routing = Some(routing);
213        self
214    }
215    #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
216    pub fn source(mut self, source: &'b str) -> Self {
217        self.source = Some(source);
218        self
219    }
220    #[doc = "Explicit operation timeout"]
221    pub fn timeout(mut self, timeout: &'b str) -> Self {
222        self.timeout = Some(timeout);
223        self
224    }
225    #[doc = "Default document type for items which don't provide one"]
226    pub fn ty(mut self, ty: &'b str) -> Self {
227        self.ty = Some(ty);
228        self
229    }
230    #[doc = "Sets the number of shard copies that must be active before proceeding with the bulk operation. Defaults to 1, meaning the primary shard only. 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)"]
231    pub fn wait_for_active_shards(mut self, wait_for_active_shards: &'b str) -> Self {
232        self.wait_for_active_shards = Some(wait_for_active_shards);
233        self
234    }
235    #[doc = "Creates an asynchronous call to the Bulk API that can be awaited"]
236    pub async fn send(self) -> Result<Response, Error> {
237        let path = self.parts.url();
238        let method = Method::Post;
239        let headers = self.headers;
240        let timeout = self.request_timeout;
241        let query_string = {
242            #[serde_with::skip_serializing_none]
243            #[derive(Serialize)]
244            struct QueryParams<'b> {
245                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
246                _source: Option<&'b [&'b str]>,
247                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
248                _source_excludes: Option<&'b [&'b str]>,
249                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
250                _source_includes: Option<&'b [&'b str]>,
251                error_trace: Option<bool>,
252                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
253                filter_path: Option<&'b [&'b str]>,
254                human: Option<bool>,
255                pipeline: Option<&'b str>,
256                pretty: Option<bool>,
257                refresh: Option<Refresh>,
258                require_alias: Option<bool>,
259                routing: Option<&'b str>,
260                source: Option<&'b str>,
261                timeout: Option<&'b str>,
262                #[serde(rename = "type")]
263                ty: Option<&'b str>,
264                wait_for_active_shards: Option<&'b str>,
265            }
266            let query_params = QueryParams {
267                _source: self._source,
268                _source_excludes: self._source_excludes,
269                _source_includes: self._source_includes,
270                error_trace: self.error_trace,
271                filter_path: self.filter_path,
272                human: self.human,
273                pipeline: self.pipeline,
274                pretty: self.pretty,
275                refresh: self.refresh,
276                require_alias: self.require_alias,
277                routing: self.routing,
278                source: self.source,
279                timeout: self.timeout,
280                ty: self.ty,
281                wait_for_active_shards: self.wait_for_active_shards,
282            };
283            Some(query_params)
284        };
285        let body = self.body;
286        let response = self
287            .transport
288            .send(method, &path, headers, query_string.as_ref(), body, timeout)
289            .await?;
290        Ok(response)
291    }
292}
293#[derive(Debug, Clone, PartialEq, Eq)]
294#[doc = "API parts for the Clear Scroll API"]
295pub enum ClearScrollParts<'b> {
296    #[doc = "No parts"]
297    None,
298    #[doc = "ScrollId"]
299    ScrollId(&'b [&'b str]),
300}
301impl<'b> ClearScrollParts<'b> {
302    #[doc = "Builds a relative URL path to the Clear Scroll API"]
303    pub fn url(self) -> Cow<'static, str> {
304        match self {
305            ClearScrollParts::None => "/_search/scroll".into(),
306            ClearScrollParts::ScrollId(scroll_id) => {
307                let scroll_id_str = scroll_id.join(",");
308                let encoded_scroll_id: Cow<str> =
309                    percent_encode(scroll_id_str.as_bytes(), PARTS_ENCODED).into();
310                let mut p = String::with_capacity(16usize + encoded_scroll_id.len());
311                p.push_str("/_search/scroll/");
312                p.push_str(encoded_scroll_id.as_ref());
313                p.into()
314            }
315        }
316    }
317}
318#[doc = "Builder for the [Clear Scroll API](https://opensearch.org/docs/)\n\nExplicitly clears the search context for a scroll."]
319#[derive(Clone, Debug)]
320pub struct ClearScroll<'a, 'b, B> {
321    transport: &'a Transport,
322    parts: ClearScrollParts<'b>,
323    body: Option<B>,
324    error_trace: Option<bool>,
325    filter_path: Option<&'b [&'b str]>,
326    headers: HeaderMap,
327    human: Option<bool>,
328    pretty: Option<bool>,
329    request_timeout: Option<Duration>,
330    source: Option<&'b str>,
331}
332impl<'a, 'b, B> ClearScroll<'a, 'b, B>
333where
334    B: Body,
335{
336    #[doc = "Creates a new instance of [ClearScroll] with the specified API parts"]
337    pub fn new(transport: &'a Transport, parts: ClearScrollParts<'b>) -> Self {
338        let headers = HeaderMap::new();
339        ClearScroll {
340            transport,
341            parts,
342            headers,
343            body: None,
344            error_trace: None,
345            filter_path: None,
346            human: None,
347            pretty: None,
348            request_timeout: None,
349            source: None,
350        }
351    }
352    #[doc = "The body for the API call"]
353    pub fn body<T>(self, body: T) -> ClearScroll<'a, 'b, JsonBody<T>>
354    where
355        T: Serialize,
356    {
357        ClearScroll {
358            transport: self.transport,
359            parts: self.parts,
360            body: Some(body.into()),
361            error_trace: self.error_trace,
362            filter_path: self.filter_path,
363            headers: self.headers,
364            human: self.human,
365            pretty: self.pretty,
366            request_timeout: self.request_timeout,
367            source: self.source,
368        }
369    }
370    #[doc = "Include the stack trace of returned errors."]
371    pub fn error_trace(mut self, error_trace: bool) -> Self {
372        self.error_trace = Some(error_trace);
373        self
374    }
375    #[doc = "A comma-separated list of filters used to reduce the response."]
376    pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
377        self.filter_path = Some(filter_path);
378        self
379    }
380    #[doc = "Adds a HTTP header"]
381    pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
382        self.headers.insert(key, value);
383        self
384    }
385    #[doc = "Return human readable values for statistics."]
386    pub fn human(mut self, human: bool) -> Self {
387        self.human = Some(human);
388        self
389    }
390    #[doc = "Pretty format the returned JSON response."]
391    pub fn pretty(mut self, pretty: bool) -> Self {
392        self.pretty = Some(pretty);
393        self
394    }
395    #[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."]
396    pub fn request_timeout(mut self, timeout: Duration) -> Self {
397        self.request_timeout = Some(timeout);
398        self
399    }
400    #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
401    pub fn source(mut self, source: &'b str) -> Self {
402        self.source = Some(source);
403        self
404    }
405    #[doc = "Creates an asynchronous call to the Clear Scroll API that can be awaited"]
406    pub async fn send(self) -> Result<Response, Error> {
407        let path = self.parts.url();
408        let method = Method::Delete;
409        let headers = self.headers;
410        let timeout = self.request_timeout;
411        let query_string = {
412            #[serde_with::skip_serializing_none]
413            #[derive(Serialize)]
414            struct QueryParams<'b> {
415                error_trace: Option<bool>,
416                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
417                filter_path: Option<&'b [&'b str]>,
418                human: Option<bool>,
419                pretty: Option<bool>,
420                source: Option<&'b str>,
421            }
422            let query_params = QueryParams {
423                error_trace: self.error_trace,
424                filter_path: self.filter_path,
425                human: self.human,
426                pretty: self.pretty,
427                source: self.source,
428            };
429            Some(query_params)
430        };
431        let body = self.body;
432        let response = self
433            .transport
434            .send(method, &path, headers, query_string.as_ref(), body, timeout)
435            .await?;
436        Ok(response)
437    }
438}
439#[derive(Debug, Clone, PartialEq, Eq)]
440#[doc = "API parts for the Count API"]
441pub enum CountParts<'b> {
442    #[doc = "No parts"]
443    None,
444    #[doc = "Index"]
445    Index(&'b [&'b str]),
446}
447impl<'b> CountParts<'b> {
448    #[doc = "Builds a relative URL path to the Count API"]
449    pub fn url(self) -> Cow<'static, str> {
450        match self {
451            CountParts::None => "/_count".into(),
452            CountParts::Index(index) => {
453                let index_str = index.join(",");
454                let encoded_index: Cow<str> =
455                    percent_encode(index_str.as_bytes(), PARTS_ENCODED).into();
456                let mut p = String::with_capacity(8usize + encoded_index.len());
457                p.push('/');
458                p.push_str(encoded_index.as_ref());
459                p.push_str("/_count");
460                p.into()
461            }
462        }
463    }
464}
465#[doc = "Builder for the [Count API](https://opensearch.org/docs/)\n\nReturns number of documents matching a query."]
466#[derive(Clone, Debug)]
467pub struct Count<'a, 'b, B> {
468    transport: &'a Transport,
469    parts: CountParts<'b>,
470    allow_no_indices: Option<bool>,
471    analyze_wildcard: Option<bool>,
472    analyzer: Option<&'b str>,
473    body: Option<B>,
474    default_operator: Option<DefaultOperator>,
475    df: Option<&'b str>,
476    error_trace: Option<bool>,
477    expand_wildcards: Option<&'b [ExpandWildcards]>,
478    filter_path: Option<&'b [&'b str]>,
479    headers: HeaderMap,
480    human: Option<bool>,
481    ignore_throttled: Option<bool>,
482    ignore_unavailable: Option<bool>,
483    lenient: Option<bool>,
484    min_score: Option<i64>,
485    preference: Option<&'b str>,
486    pretty: Option<bool>,
487    q: Option<&'b str>,
488    request_timeout: Option<Duration>,
489    routing: Option<&'b [&'b str]>,
490    source: Option<&'b str>,
491    terminate_after: Option<i64>,
492}
493impl<'a, 'b, B> Count<'a, 'b, B>
494where
495    B: Body,
496{
497    #[doc = "Creates a new instance of [Count] with the specified API parts"]
498    pub fn new(transport: &'a Transport, parts: CountParts<'b>) -> Self {
499        let headers = HeaderMap::new();
500        Count {
501            transport,
502            parts,
503            headers,
504            allow_no_indices: None,
505            analyze_wildcard: None,
506            analyzer: None,
507            body: None,
508            default_operator: None,
509            df: None,
510            error_trace: None,
511            expand_wildcards: None,
512            filter_path: None,
513            human: None,
514            ignore_throttled: None,
515            ignore_unavailable: None,
516            lenient: None,
517            min_score: None,
518            preference: None,
519            pretty: None,
520            q: None,
521            request_timeout: None,
522            routing: None,
523            source: None,
524            terminate_after: None,
525        }
526    }
527    #[doc = "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)"]
528    pub fn allow_no_indices(mut self, allow_no_indices: bool) -> Self {
529        self.allow_no_indices = Some(allow_no_indices);
530        self
531    }
532    #[doc = "Specify whether wildcard and prefix queries should be analyzed (default: false)"]
533    pub fn analyze_wildcard(mut self, analyze_wildcard: bool) -> Self {
534        self.analyze_wildcard = Some(analyze_wildcard);
535        self
536    }
537    #[doc = "The analyzer to use for the query string"]
538    pub fn analyzer(mut self, analyzer: &'b str) -> Self {
539        self.analyzer = Some(analyzer);
540        self
541    }
542    #[doc = "The body for the API call"]
543    pub fn body<T>(self, body: T) -> Count<'a, 'b, JsonBody<T>>
544    where
545        T: Serialize,
546    {
547        Count {
548            transport: self.transport,
549            parts: self.parts,
550            body: Some(body.into()),
551            allow_no_indices: self.allow_no_indices,
552            analyze_wildcard: self.analyze_wildcard,
553            analyzer: self.analyzer,
554            default_operator: self.default_operator,
555            df: self.df,
556            error_trace: self.error_trace,
557            expand_wildcards: self.expand_wildcards,
558            filter_path: self.filter_path,
559            headers: self.headers,
560            human: self.human,
561            ignore_throttled: self.ignore_throttled,
562            ignore_unavailable: self.ignore_unavailable,
563            lenient: self.lenient,
564            min_score: self.min_score,
565            preference: self.preference,
566            pretty: self.pretty,
567            q: self.q,
568            request_timeout: self.request_timeout,
569            routing: self.routing,
570            source: self.source,
571            terminate_after: self.terminate_after,
572        }
573    }
574    #[doc = "The default operator for query string query (AND or OR)"]
575    pub fn default_operator(mut self, default_operator: DefaultOperator) -> Self {
576        self.default_operator = Some(default_operator);
577        self
578    }
579    #[doc = "The field to use as default where no field prefix is given in the query string"]
580    pub fn df(mut self, df: &'b str) -> Self {
581        self.df = Some(df);
582        self
583    }
584    #[doc = "Include the stack trace of returned errors."]
585    pub fn error_trace(mut self, error_trace: bool) -> Self {
586        self.error_trace = Some(error_trace);
587        self
588    }
589    #[doc = "Whether to expand wildcard expression to concrete indices that are open, closed or both."]
590    pub fn expand_wildcards(mut self, expand_wildcards: &'b [ExpandWildcards]) -> Self {
591        self.expand_wildcards = Some(expand_wildcards);
592        self
593    }
594    #[doc = "A comma-separated list of filters used to reduce the response."]
595    pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
596        self.filter_path = Some(filter_path);
597        self
598    }
599    #[doc = "Adds a HTTP header"]
600    pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
601        self.headers.insert(key, value);
602        self
603    }
604    #[doc = "Return human readable values for statistics."]
605    pub fn human(mut self, human: bool) -> Self {
606        self.human = Some(human);
607        self
608    }
609    #[doc = "Whether specified concrete, expanded or aliased indices should be ignored when throttled"]
610    pub fn ignore_throttled(mut self, ignore_throttled: bool) -> Self {
611        self.ignore_throttled = Some(ignore_throttled);
612        self
613    }
614    #[doc = "Whether specified concrete indices should be ignored when unavailable (missing or closed)"]
615    pub fn ignore_unavailable(mut self, ignore_unavailable: bool) -> Self {
616        self.ignore_unavailable = Some(ignore_unavailable);
617        self
618    }
619    #[doc = "Specify whether format-based query failures (such as providing text to a numeric field) should be ignored"]
620    pub fn lenient(mut self, lenient: bool) -> Self {
621        self.lenient = Some(lenient);
622        self
623    }
624    #[doc = "Include only documents with a specific `_score` value in the result"]
625    pub fn min_score(mut self, min_score: i64) -> Self {
626        self.min_score = Some(min_score);
627        self
628    }
629    #[doc = "Specify the node or shard the operation should be performed on (default: random)"]
630    pub fn preference(mut self, preference: &'b str) -> Self {
631        self.preference = Some(preference);
632        self
633    }
634    #[doc = "Pretty format the returned JSON response."]
635    pub fn pretty(mut self, pretty: bool) -> Self {
636        self.pretty = Some(pretty);
637        self
638    }
639    #[doc = "Query in the Lucene query string syntax"]
640    pub fn q(mut self, q: &'b str) -> Self {
641        self.q = Some(q);
642        self
643    }
644    #[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."]
645    pub fn request_timeout(mut self, timeout: Duration) -> Self {
646        self.request_timeout = Some(timeout);
647        self
648    }
649    #[doc = "A comma-separated list of specific routing values"]
650    pub fn routing(mut self, routing: &'b [&'b str]) -> Self {
651        self.routing = Some(routing);
652        self
653    }
654    #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
655    pub fn source(mut self, source: &'b str) -> Self {
656        self.source = Some(source);
657        self
658    }
659    #[doc = "The maximum count for each shard, upon reaching which the query execution will terminate early"]
660    pub fn terminate_after(mut self, terminate_after: i64) -> Self {
661        self.terminate_after = Some(terminate_after);
662        self
663    }
664    #[doc = "Creates an asynchronous call to the Count API that can be awaited"]
665    pub async fn send(self) -> Result<Response, Error> {
666        let path = self.parts.url();
667        let method = match self.body {
668            Some(_) => Method::Post,
669            None => Method::Get,
670        };
671        let headers = self.headers;
672        let timeout = self.request_timeout;
673        let query_string = {
674            #[serde_with::skip_serializing_none]
675            #[derive(Serialize)]
676            struct QueryParams<'b> {
677                allow_no_indices: Option<bool>,
678                analyze_wildcard: Option<bool>,
679                analyzer: Option<&'b str>,
680                default_operator: Option<DefaultOperator>,
681                df: Option<&'b str>,
682                error_trace: Option<bool>,
683                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
684                expand_wildcards: Option<&'b [ExpandWildcards]>,
685                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
686                filter_path: Option<&'b [&'b str]>,
687                human: Option<bool>,
688                ignore_throttled: Option<bool>,
689                ignore_unavailable: Option<bool>,
690                lenient: Option<bool>,
691                min_score: Option<i64>,
692                preference: Option<&'b str>,
693                pretty: Option<bool>,
694                q: Option<&'b str>,
695                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
696                routing: Option<&'b [&'b str]>,
697                source: Option<&'b str>,
698                terminate_after: Option<i64>,
699            }
700            let query_params = QueryParams {
701                allow_no_indices: self.allow_no_indices,
702                analyze_wildcard: self.analyze_wildcard,
703                analyzer: self.analyzer,
704                default_operator: self.default_operator,
705                df: self.df,
706                error_trace: self.error_trace,
707                expand_wildcards: self.expand_wildcards,
708                filter_path: self.filter_path,
709                human: self.human,
710                ignore_throttled: self.ignore_throttled,
711                ignore_unavailable: self.ignore_unavailable,
712                lenient: self.lenient,
713                min_score: self.min_score,
714                preference: self.preference,
715                pretty: self.pretty,
716                q: self.q,
717                routing: self.routing,
718                source: self.source,
719                terminate_after: self.terminate_after,
720            };
721            Some(query_params)
722        };
723        let body = self.body;
724        let response = self
725            .transport
726            .send(method, &path, headers, query_string.as_ref(), body, timeout)
727            .await?;
728        Ok(response)
729    }
730}
731#[derive(Debug, Clone, PartialEq, Eq)]
732#[doc = "API parts for the Create API"]
733pub enum CreateParts<'b> {
734    #[doc = "Index and Id"]
735    IndexId(&'b str, &'b str),
736}
737impl<'b> CreateParts<'b> {
738    #[doc = "Builds a relative URL path to the Create API"]
739    pub fn url(self) -> Cow<'static, str> {
740        match self {
741            CreateParts::IndexId(index, id) => {
742                let encoded_index: Cow<str> =
743                    percent_encode(index.as_bytes(), PARTS_ENCODED).into();
744                let encoded_id: Cow<str> = percent_encode(id.as_bytes(), PARTS_ENCODED).into();
745                let mut p = String::with_capacity(10usize + encoded_index.len() + encoded_id.len());
746                p.push('/');
747                p.push_str(encoded_index.as_ref());
748                p.push_str("/_create/");
749                p.push_str(encoded_id.as_ref());
750                p.into()
751            }
752        }
753    }
754}
755#[doc = "Builder for the [Create API](https://opensearch.org/docs/)\n\nCreates a new document in the index.\n\nReturns a 409 response when a document with a same ID already exists in the index."]
756#[derive(Clone, Debug)]
757pub struct Create<'a, 'b, B> {
758    transport: &'a Transport,
759    parts: CreateParts<'b>,
760    body: Option<B>,
761    error_trace: Option<bool>,
762    filter_path: Option<&'b [&'b str]>,
763    headers: HeaderMap,
764    human: Option<bool>,
765    pipeline: Option<&'b str>,
766    pretty: Option<bool>,
767    refresh: Option<Refresh>,
768    request_timeout: Option<Duration>,
769    routing: Option<&'b str>,
770    source: Option<&'b str>,
771    timeout: Option<&'b str>,
772    version: Option<i64>,
773    version_type: Option<VersionType>,
774    wait_for_active_shards: Option<&'b str>,
775}
776impl<'a, 'b, B> Create<'a, 'b, B>
777where
778    B: Body,
779{
780    #[doc = "Creates a new instance of [Create] with the specified API parts"]
781    pub fn new(transport: &'a Transport, parts: CreateParts<'b>) -> Self {
782        let headers = HeaderMap::new();
783        Create {
784            transport,
785            parts,
786            headers,
787            body: None,
788            error_trace: None,
789            filter_path: None,
790            human: None,
791            pipeline: None,
792            pretty: None,
793            refresh: None,
794            request_timeout: None,
795            routing: None,
796            source: None,
797            timeout: None,
798            version: None,
799            version_type: None,
800            wait_for_active_shards: None,
801        }
802    }
803    #[doc = "The body for the API call"]
804    pub fn body<T>(self, body: T) -> Create<'a, 'b, JsonBody<T>>
805    where
806        T: Serialize,
807    {
808        Create {
809            transport: self.transport,
810            parts: self.parts,
811            body: Some(body.into()),
812            error_trace: self.error_trace,
813            filter_path: self.filter_path,
814            headers: self.headers,
815            human: self.human,
816            pipeline: self.pipeline,
817            pretty: self.pretty,
818            refresh: self.refresh,
819            request_timeout: self.request_timeout,
820            routing: self.routing,
821            source: self.source,
822            timeout: self.timeout,
823            version: self.version,
824            version_type: self.version_type,
825            wait_for_active_shards: self.wait_for_active_shards,
826        }
827    }
828    #[doc = "Include the stack trace of returned errors."]
829    pub fn error_trace(mut self, error_trace: bool) -> Self {
830        self.error_trace = Some(error_trace);
831        self
832    }
833    #[doc = "A comma-separated list of filters used to reduce the response."]
834    pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
835        self.filter_path = Some(filter_path);
836        self
837    }
838    #[doc = "Adds a HTTP header"]
839    pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
840        self.headers.insert(key, value);
841        self
842    }
843    #[doc = "Return human readable values for statistics."]
844    pub fn human(mut self, human: bool) -> Self {
845        self.human = Some(human);
846        self
847    }
848    #[doc = "The pipeline id to preprocess incoming documents with"]
849    pub fn pipeline(mut self, pipeline: &'b str) -> Self {
850        self.pipeline = Some(pipeline);
851        self
852    }
853    #[doc = "Pretty format the returned JSON response."]
854    pub fn pretty(mut self, pretty: bool) -> Self {
855        self.pretty = Some(pretty);
856        self
857    }
858    #[doc = "If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes."]
859    pub fn refresh(mut self, refresh: Refresh) -> Self {
860        self.refresh = Some(refresh);
861        self
862    }
863    #[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."]
864    pub fn request_timeout(mut self, timeout: Duration) -> Self {
865        self.request_timeout = Some(timeout);
866        self
867    }
868    #[doc = "Specific routing value"]
869    pub fn routing(mut self, routing: &'b str) -> Self {
870        self.routing = Some(routing);
871        self
872    }
873    #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
874    pub fn source(mut self, source: &'b str) -> Self {
875        self.source = Some(source);
876        self
877    }
878    #[doc = "Explicit operation timeout"]
879    pub fn timeout(mut self, timeout: &'b str) -> Self {
880        self.timeout = Some(timeout);
881        self
882    }
883    #[doc = "Explicit version number for concurrency control"]
884    pub fn version(mut self, version: i64) -> Self {
885        self.version = Some(version);
886        self
887    }
888    #[doc = "Specific version type"]
889    pub fn version_type(mut self, version_type: VersionType) -> Self {
890        self.version_type = Some(version_type);
891        self
892    }
893    #[doc = "Sets the number of shard copies that must be active before proceeding with the index operation. Defaults to 1, meaning the primary shard only. 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)"]
894    pub fn wait_for_active_shards(mut self, wait_for_active_shards: &'b str) -> Self {
895        self.wait_for_active_shards = Some(wait_for_active_shards);
896        self
897    }
898    #[doc = "Creates an asynchronous call to the Create API that can be awaited"]
899    pub async fn send(self) -> Result<Response, Error> {
900        let path = self.parts.url();
901        let method = Method::Post;
902        let headers = self.headers;
903        let timeout = self.request_timeout;
904        let query_string = {
905            #[serde_with::skip_serializing_none]
906            #[derive(Serialize)]
907            struct QueryParams<'b> {
908                error_trace: Option<bool>,
909                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
910                filter_path: Option<&'b [&'b str]>,
911                human: Option<bool>,
912                pipeline: Option<&'b str>,
913                pretty: Option<bool>,
914                refresh: Option<Refresh>,
915                routing: Option<&'b str>,
916                source: Option<&'b str>,
917                timeout: Option<&'b str>,
918                version: Option<i64>,
919                version_type: Option<VersionType>,
920                wait_for_active_shards: Option<&'b str>,
921            }
922            let query_params = QueryParams {
923                error_trace: self.error_trace,
924                filter_path: self.filter_path,
925                human: self.human,
926                pipeline: self.pipeline,
927                pretty: self.pretty,
928                refresh: self.refresh,
929                routing: self.routing,
930                source: self.source,
931                timeout: self.timeout,
932                version: self.version,
933                version_type: self.version_type,
934                wait_for_active_shards: self.wait_for_active_shards,
935            };
936            Some(query_params)
937        };
938        let body = self.body;
939        let response = self
940            .transport
941            .send(method, &path, headers, query_string.as_ref(), body, timeout)
942            .await?;
943        Ok(response)
944    }
945}
946#[derive(Debug, Clone, PartialEq, Eq)]
947#[doc = "API parts for the Create Pit API"]
948pub enum CreatePitParts<'b> {
949    #[doc = "Index"]
950    Index(&'b [&'b str]),
951}
952impl<'b> CreatePitParts<'b> {
953    #[doc = "Builds a relative URL path to the Create Pit API"]
954    pub fn url(self) -> Cow<'static, str> {
955        match self {
956            CreatePitParts::Index(index) => {
957                let index_str = index.join(",");
958                let encoded_index: Cow<str> =
959                    percent_encode(index_str.as_bytes(), PARTS_ENCODED).into();
960                let mut p = String::with_capacity(23usize + encoded_index.len());
961                p.push('/');
962                p.push_str(encoded_index.as_ref());
963                p.push_str("/_search/point_in_time");
964                p.into()
965            }
966        }
967    }
968}
969#[doc = "Builder for the [Create Pit API](https://opensearch.org/docs/latest/opensearch/rest-api/point_in_time/)\n\nCreates point in time context."]
970#[derive(Clone, Debug)]
971pub struct CreatePit<'a, 'b, B> {
972    transport: &'a Transport,
973    parts: CreatePitParts<'b>,
974    allow_partial_pit_creation: Option<bool>,
975    body: Option<B>,
976    error_trace: Option<bool>,
977    expand_wildcards: Option<&'b [ExpandWildcards]>,
978    filter_path: Option<&'b [&'b str]>,
979    headers: HeaderMap,
980    human: Option<bool>,
981    ignore_unavailable: Option<bool>,
982    keep_alive: Option<&'b str>,
983    preference: Option<&'b str>,
984    pretty: Option<bool>,
985    request_timeout: Option<Duration>,
986    routing: Option<&'b [&'b str]>,
987    source: Option<&'b str>,
988}
989impl<'a, 'b, B> CreatePit<'a, 'b, B>
990where
991    B: Body,
992{
993    #[doc = "Creates a new instance of [CreatePit] with the specified API parts"]
994    pub fn new(transport: &'a Transport, parts: CreatePitParts<'b>) -> Self {
995        let headers = HeaderMap::new();
996        CreatePit {
997            transport,
998            parts,
999            headers,
1000            allow_partial_pit_creation: None,
1001            body: None,
1002            error_trace: None,
1003            expand_wildcards: None,
1004            filter_path: None,
1005            human: None,
1006            ignore_unavailable: None,
1007            keep_alive: None,
1008            preference: None,
1009            pretty: None,
1010            request_timeout: None,
1011            routing: None,
1012            source: None,
1013        }
1014    }
1015    #[doc = "Allow if point in time can be created with partial failures"]
1016    pub fn allow_partial_pit_creation(mut self, allow_partial_pit_creation: bool) -> Self {
1017        self.allow_partial_pit_creation = Some(allow_partial_pit_creation);
1018        self
1019    }
1020    #[doc = "The body for the API call"]
1021    pub fn body<T>(self, body: T) -> CreatePit<'a, 'b, JsonBody<T>>
1022    where
1023        T: Serialize,
1024    {
1025        CreatePit {
1026            transport: self.transport,
1027            parts: self.parts,
1028            body: Some(body.into()),
1029            allow_partial_pit_creation: self.allow_partial_pit_creation,
1030            error_trace: self.error_trace,
1031            expand_wildcards: self.expand_wildcards,
1032            filter_path: self.filter_path,
1033            headers: self.headers,
1034            human: self.human,
1035            ignore_unavailable: self.ignore_unavailable,
1036            keep_alive: self.keep_alive,
1037            preference: self.preference,
1038            pretty: self.pretty,
1039            request_timeout: self.request_timeout,
1040            routing: self.routing,
1041            source: self.source,
1042        }
1043    }
1044    #[doc = "Include the stack trace of returned errors."]
1045    pub fn error_trace(mut self, error_trace: bool) -> Self {
1046        self.error_trace = Some(error_trace);
1047        self
1048    }
1049    #[doc = "The type of index that can match the wildcard pattern. Supports comma-separated values. Optional. Default is `open`."]
1050    pub fn expand_wildcards(mut self, expand_wildcards: &'b [ExpandWildcards]) -> Self {
1051        self.expand_wildcards = Some(expand_wildcards);
1052        self
1053    }
1054    #[doc = "A comma-separated list of filters used to reduce the response."]
1055    pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
1056        self.filter_path = Some(filter_path);
1057        self
1058    }
1059    #[doc = "Adds a HTTP header"]
1060    pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
1061        self.headers.insert(key, value);
1062        self
1063    }
1064    #[doc = "Return human readable values for statistics."]
1065    pub fn human(mut self, human: bool) -> Self {
1066        self.human = Some(human);
1067        self
1068    }
1069    #[doc = "Whether specified concrete indices should be ignored when unavailable (missing or closed)"]
1070    pub fn ignore_unavailable(mut self, ignore_unavailable: bool) -> Self {
1071        self.ignore_unavailable = Some(ignore_unavailable);
1072        self
1073    }
1074    #[doc = "Specify the keep alive for point in time"]
1075    pub fn keep_alive(mut self, keep_alive: &'b str) -> Self {
1076        self.keep_alive = Some(keep_alive);
1077        self
1078    }
1079    #[doc = "Specify the node or shard the operation should be performed on (default: random)"]
1080    pub fn preference(mut self, preference: &'b str) -> Self {
1081        self.preference = Some(preference);
1082        self
1083    }
1084    #[doc = "Pretty format the returned JSON response."]
1085    pub fn pretty(mut self, pretty: bool) -> Self {
1086        self.pretty = Some(pretty);
1087        self
1088    }
1089    #[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."]
1090    pub fn request_timeout(mut self, timeout: Duration) -> Self {
1091        self.request_timeout = Some(timeout);
1092        self
1093    }
1094    #[doc = "A comma-separated list of specific routing values"]
1095    pub fn routing(mut self, routing: &'b [&'b str]) -> Self {
1096        self.routing = Some(routing);
1097        self
1098    }
1099    #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
1100    pub fn source(mut self, source: &'b str) -> Self {
1101        self.source = Some(source);
1102        self
1103    }
1104    #[doc = "Creates an asynchronous call to the Create Pit API that can be awaited"]
1105    pub async fn send(self) -> Result<Response, Error> {
1106        let path = self.parts.url();
1107        let method = Method::Post;
1108        let headers = self.headers;
1109        let timeout = self.request_timeout;
1110        let query_string = {
1111            #[serde_with::skip_serializing_none]
1112            #[derive(Serialize)]
1113            struct QueryParams<'b> {
1114                allow_partial_pit_creation: Option<bool>,
1115                error_trace: Option<bool>,
1116                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
1117                expand_wildcards: Option<&'b [ExpandWildcards]>,
1118                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
1119                filter_path: Option<&'b [&'b str]>,
1120                human: Option<bool>,
1121                ignore_unavailable: Option<bool>,
1122                keep_alive: Option<&'b str>,
1123                preference: Option<&'b str>,
1124                pretty: Option<bool>,
1125                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
1126                routing: Option<&'b [&'b str]>,
1127                source: Option<&'b str>,
1128            }
1129            let query_params = QueryParams {
1130                allow_partial_pit_creation: self.allow_partial_pit_creation,
1131                error_trace: self.error_trace,
1132                expand_wildcards: self.expand_wildcards,
1133                filter_path: self.filter_path,
1134                human: self.human,
1135                ignore_unavailable: self.ignore_unavailable,
1136                keep_alive: self.keep_alive,
1137                preference: self.preference,
1138                pretty: self.pretty,
1139                routing: self.routing,
1140                source: self.source,
1141            };
1142            Some(query_params)
1143        };
1144        let body = self.body;
1145        let response = self
1146            .transport
1147            .send(method, &path, headers, query_string.as_ref(), body, timeout)
1148            .await?;
1149        Ok(response)
1150    }
1151}
1152#[derive(Debug, Clone, PartialEq, Eq)]
1153#[doc = "API parts for the Delete API"]
1154pub enum DeleteParts<'b> {
1155    #[doc = "Index and Id"]
1156    IndexId(&'b str, &'b str),
1157}
1158impl<'b> DeleteParts<'b> {
1159    #[doc = "Builds a relative URL path to the Delete API"]
1160    pub fn url(self) -> Cow<'static, str> {
1161        match self {
1162            DeleteParts::IndexId(index, id) => {
1163                let encoded_index: Cow<str> =
1164                    percent_encode(index.as_bytes(), PARTS_ENCODED).into();
1165                let encoded_id: Cow<str> = percent_encode(id.as_bytes(), PARTS_ENCODED).into();
1166                let mut p = String::with_capacity(7usize + encoded_index.len() + encoded_id.len());
1167                p.push('/');
1168                p.push_str(encoded_index.as_ref());
1169                p.push_str("/_doc/");
1170                p.push_str(encoded_id.as_ref());
1171                p.into()
1172            }
1173        }
1174    }
1175}
1176#[doc = "Builder for the [Delete API](https://opensearch.org/docs/)\n\nRemoves a document from the index."]
1177#[derive(Clone, Debug)]
1178pub struct Delete<'a, 'b> {
1179    transport: &'a Transport,
1180    parts: DeleteParts<'b>,
1181    error_trace: Option<bool>,
1182    filter_path: Option<&'b [&'b str]>,
1183    headers: HeaderMap,
1184    human: Option<bool>,
1185    if_primary_term: Option<i64>,
1186    if_seq_no: Option<i64>,
1187    pretty: Option<bool>,
1188    refresh: Option<Refresh>,
1189    request_timeout: Option<Duration>,
1190    routing: Option<&'b str>,
1191    source: Option<&'b str>,
1192    timeout: Option<&'b str>,
1193    version: Option<i64>,
1194    version_type: Option<VersionType>,
1195    wait_for_active_shards: Option<&'b str>,
1196}
1197impl<'a, 'b> Delete<'a, 'b> {
1198    #[doc = "Creates a new instance of [Delete] with the specified API parts"]
1199    pub fn new(transport: &'a Transport, parts: DeleteParts<'b>) -> Self {
1200        let headers = HeaderMap::new();
1201        Delete {
1202            transport,
1203            parts,
1204            headers,
1205            error_trace: None,
1206            filter_path: None,
1207            human: None,
1208            if_primary_term: None,
1209            if_seq_no: None,
1210            pretty: None,
1211            refresh: None,
1212            request_timeout: None,
1213            routing: None,
1214            source: None,
1215            timeout: None,
1216            version: None,
1217            version_type: None,
1218            wait_for_active_shards: None,
1219        }
1220    }
1221    #[doc = "Include the stack trace of returned errors."]
1222    pub fn error_trace(mut self, error_trace: bool) -> Self {
1223        self.error_trace = Some(error_trace);
1224        self
1225    }
1226    #[doc = "A comma-separated list of filters used to reduce the response."]
1227    pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
1228        self.filter_path = Some(filter_path);
1229        self
1230    }
1231    #[doc = "Adds a HTTP header"]
1232    pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
1233        self.headers.insert(key, value);
1234        self
1235    }
1236    #[doc = "Return human readable values for statistics."]
1237    pub fn human(mut self, human: bool) -> Self {
1238        self.human = Some(human);
1239        self
1240    }
1241    #[doc = "only perform the delete operation if the last operation that has changed the document has the specified primary term"]
1242    pub fn if_primary_term(mut self, if_primary_term: i64) -> Self {
1243        self.if_primary_term = Some(if_primary_term);
1244        self
1245    }
1246    #[doc = "only perform the delete operation if the last operation that has changed the document has the specified sequence number"]
1247    pub fn if_seq_no(mut self, if_seq_no: i64) -> Self {
1248        self.if_seq_no = Some(if_seq_no);
1249        self
1250    }
1251    #[doc = "Pretty format the returned JSON response."]
1252    pub fn pretty(mut self, pretty: bool) -> Self {
1253        self.pretty = Some(pretty);
1254        self
1255    }
1256    #[doc = "If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes."]
1257    pub fn refresh(mut self, refresh: Refresh) -> Self {
1258        self.refresh = Some(refresh);
1259        self
1260    }
1261    #[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."]
1262    pub fn request_timeout(mut self, timeout: Duration) -> Self {
1263        self.request_timeout = Some(timeout);
1264        self
1265    }
1266    #[doc = "Specific routing value"]
1267    pub fn routing(mut self, routing: &'b str) -> Self {
1268        self.routing = Some(routing);
1269        self
1270    }
1271    #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
1272    pub fn source(mut self, source: &'b str) -> Self {
1273        self.source = Some(source);
1274        self
1275    }
1276    #[doc = "Explicit operation timeout"]
1277    pub fn timeout(mut self, timeout: &'b str) -> Self {
1278        self.timeout = Some(timeout);
1279        self
1280    }
1281    #[doc = "Explicit version number for concurrency control"]
1282    pub fn version(mut self, version: i64) -> Self {
1283        self.version = Some(version);
1284        self
1285    }
1286    #[doc = "Specific version type"]
1287    pub fn version_type(mut self, version_type: VersionType) -> Self {
1288        self.version_type = Some(version_type);
1289        self
1290    }
1291    #[doc = "Sets the number of shard copies that must be active before proceeding with the delete operation. Defaults to 1, meaning the primary shard only. 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)"]
1292    pub fn wait_for_active_shards(mut self, wait_for_active_shards: &'b str) -> Self {
1293        self.wait_for_active_shards = Some(wait_for_active_shards);
1294        self
1295    }
1296    #[doc = "Creates an asynchronous call to the Delete API that can be awaited"]
1297    pub async fn send(self) -> Result<Response, Error> {
1298        let path = self.parts.url();
1299        let method = Method::Delete;
1300        let headers = self.headers;
1301        let timeout = self.request_timeout;
1302        let query_string = {
1303            #[serde_with::skip_serializing_none]
1304            #[derive(Serialize)]
1305            struct QueryParams<'b> {
1306                error_trace: Option<bool>,
1307                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
1308                filter_path: Option<&'b [&'b str]>,
1309                human: Option<bool>,
1310                if_primary_term: Option<i64>,
1311                if_seq_no: Option<i64>,
1312                pretty: Option<bool>,
1313                refresh: Option<Refresh>,
1314                routing: Option<&'b str>,
1315                source: Option<&'b str>,
1316                timeout: Option<&'b str>,
1317                version: Option<i64>,
1318                version_type: Option<VersionType>,
1319                wait_for_active_shards: Option<&'b str>,
1320            }
1321            let query_params = QueryParams {
1322                error_trace: self.error_trace,
1323                filter_path: self.filter_path,
1324                human: self.human,
1325                if_primary_term: self.if_primary_term,
1326                if_seq_no: self.if_seq_no,
1327                pretty: self.pretty,
1328                refresh: self.refresh,
1329                routing: self.routing,
1330                source: self.source,
1331                timeout: self.timeout,
1332                version: self.version,
1333                version_type: self.version_type,
1334                wait_for_active_shards: self.wait_for_active_shards,
1335            };
1336            Some(query_params)
1337        };
1338        let body = Option::<()>::None;
1339        let response = self
1340            .transport
1341            .send(method, &path, headers, query_string.as_ref(), body, timeout)
1342            .await?;
1343        Ok(response)
1344    }
1345}
1346#[derive(Debug, Clone, PartialEq, Eq)]
1347#[doc = "API parts for the Delete All Pits API"]
1348pub enum DeleteAllPitsParts {
1349    #[doc = "No parts"]
1350    None,
1351}
1352impl DeleteAllPitsParts {
1353    #[doc = "Builds a relative URL path to the Delete All Pits API"]
1354    pub fn url(self) -> Cow<'static, str> {
1355        match self {
1356            DeleteAllPitsParts::None => "/_search/point_in_time/_all".into(),
1357        }
1358    }
1359}
1360#[doc = "Builder for the [Delete All Pits API](https://opensearch.org/docs/latest/opensearch/rest-api/point_in_time/)\n\nDeletes all active point in time searches."]
1361#[derive(Clone, Debug)]
1362pub struct DeleteAllPits<'a, 'b> {
1363    transport: &'a Transport,
1364    parts: DeleteAllPitsParts,
1365    error_trace: Option<bool>,
1366    filter_path: Option<&'b [&'b str]>,
1367    headers: HeaderMap,
1368    human: Option<bool>,
1369    pretty: Option<bool>,
1370    request_timeout: Option<Duration>,
1371    source: Option<&'b str>,
1372}
1373impl<'a, 'b> DeleteAllPits<'a, 'b> {
1374    #[doc = "Creates a new instance of [DeleteAllPits]"]
1375    pub fn new(transport: &'a Transport) -> Self {
1376        let headers = HeaderMap::new();
1377        DeleteAllPits {
1378            transport,
1379            parts: DeleteAllPitsParts::None,
1380            headers,
1381            error_trace: None,
1382            filter_path: None,
1383            human: None,
1384            pretty: None,
1385            request_timeout: None,
1386            source: None,
1387        }
1388    }
1389    #[doc = "Include the stack trace of returned errors."]
1390    pub fn error_trace(mut self, error_trace: bool) -> Self {
1391        self.error_trace = Some(error_trace);
1392        self
1393    }
1394    #[doc = "A comma-separated list of filters used to reduce the response."]
1395    pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
1396        self.filter_path = Some(filter_path);
1397        self
1398    }
1399    #[doc = "Adds a HTTP header"]
1400    pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
1401        self.headers.insert(key, value);
1402        self
1403    }
1404    #[doc = "Return human readable values for statistics."]
1405    pub fn human(mut self, human: bool) -> Self {
1406        self.human = Some(human);
1407        self
1408    }
1409    #[doc = "Pretty format the returned JSON response."]
1410    pub fn pretty(mut self, pretty: bool) -> Self {
1411        self.pretty = Some(pretty);
1412        self
1413    }
1414    #[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."]
1415    pub fn request_timeout(mut self, timeout: Duration) -> Self {
1416        self.request_timeout = Some(timeout);
1417        self
1418    }
1419    #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
1420    pub fn source(mut self, source: &'b str) -> Self {
1421        self.source = Some(source);
1422        self
1423    }
1424    #[doc = "Creates an asynchronous call to the Delete All Pits API that can be awaited"]
1425    pub async fn send(self) -> Result<Response, Error> {
1426        let path = self.parts.url();
1427        let method = Method::Delete;
1428        let headers = self.headers;
1429        let timeout = self.request_timeout;
1430        let query_string = {
1431            #[serde_with::skip_serializing_none]
1432            #[derive(Serialize)]
1433            struct QueryParams<'b> {
1434                error_trace: Option<bool>,
1435                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
1436                filter_path: Option<&'b [&'b str]>,
1437                human: Option<bool>,
1438                pretty: Option<bool>,
1439                source: Option<&'b str>,
1440            }
1441            let query_params = QueryParams {
1442                error_trace: self.error_trace,
1443                filter_path: self.filter_path,
1444                human: self.human,
1445                pretty: self.pretty,
1446                source: self.source,
1447            };
1448            Some(query_params)
1449        };
1450        let body = Option::<()>::None;
1451        let response = self
1452            .transport
1453            .send(method, &path, headers, query_string.as_ref(), body, timeout)
1454            .await?;
1455        Ok(response)
1456    }
1457}
1458#[derive(Debug, Clone, PartialEq, Eq)]
1459#[doc = "API parts for the Delete By Query API"]
1460pub enum DeleteByQueryParts<'b> {
1461    #[doc = "Index"]
1462    Index(&'b [&'b str]),
1463}
1464impl<'b> DeleteByQueryParts<'b> {
1465    #[doc = "Builds a relative URL path to the Delete By Query API"]
1466    pub fn url(self) -> Cow<'static, str> {
1467        match self {
1468            DeleteByQueryParts::Index(index) => {
1469                let index_str = index.join(",");
1470                let encoded_index: Cow<str> =
1471                    percent_encode(index_str.as_bytes(), PARTS_ENCODED).into();
1472                let mut p = String::with_capacity(18usize + encoded_index.len());
1473                p.push('/');
1474                p.push_str(encoded_index.as_ref());
1475                p.push_str("/_delete_by_query");
1476                p.into()
1477            }
1478        }
1479    }
1480}
1481#[doc = "Builder for the [Delete By Query API](https://opensearch.org/docs/)\n\nDeletes documents matching the provided query."]
1482#[derive(Clone, Debug)]
1483pub struct DeleteByQuery<'a, 'b, B> {
1484    transport: &'a Transport,
1485    parts: DeleteByQueryParts<'b>,
1486    _source: Option<&'b [&'b str]>,
1487    _source_excludes: Option<&'b [&'b str]>,
1488    _source_includes: Option<&'b [&'b str]>,
1489    allow_no_indices: Option<bool>,
1490    analyze_wildcard: Option<bool>,
1491    analyzer: Option<&'b str>,
1492    body: Option<B>,
1493    conflicts: Option<Conflicts>,
1494    default_operator: Option<DefaultOperator>,
1495    df: Option<&'b str>,
1496    error_trace: Option<bool>,
1497    expand_wildcards: Option<&'b [ExpandWildcards]>,
1498    filter_path: Option<&'b [&'b str]>,
1499    from: Option<i64>,
1500    headers: HeaderMap,
1501    human: Option<bool>,
1502    ignore_unavailable: Option<bool>,
1503    lenient: Option<bool>,
1504    max_docs: Option<i64>,
1505    preference: Option<&'b str>,
1506    pretty: Option<bool>,
1507    q: Option<&'b str>,
1508    refresh: Option<bool>,
1509    request_cache: Option<bool>,
1510    request_timeout: Option<Duration>,
1511    requests_per_second: Option<i64>,
1512    routing: Option<&'b [&'b str]>,
1513    scroll: Option<&'b str>,
1514    scroll_size: Option<i64>,
1515    search_timeout: Option<&'b str>,
1516    search_type: Option<SearchType>,
1517    size: Option<i64>,
1518    slices: Option<Slices>,
1519    sort: Option<&'b [&'b str]>,
1520    source: Option<&'b str>,
1521    stats: Option<&'b [&'b str]>,
1522    terminate_after: Option<i64>,
1523    timeout: Option<&'b str>,
1524    version: Option<bool>,
1525    wait_for_active_shards: Option<&'b str>,
1526    wait_for_completion: Option<bool>,
1527}
1528impl<'a, 'b, B> DeleteByQuery<'a, 'b, B>
1529where
1530    B: Body,
1531{
1532    #[doc = "Creates a new instance of [DeleteByQuery] with the specified API parts"]
1533    pub fn new(transport: &'a Transport, parts: DeleteByQueryParts<'b>) -> Self {
1534        let headers = HeaderMap::new();
1535        DeleteByQuery {
1536            transport,
1537            parts,
1538            headers,
1539            _source: None,
1540            _source_excludes: None,
1541            _source_includes: None,
1542            allow_no_indices: None,
1543            analyze_wildcard: None,
1544            analyzer: None,
1545            body: None,
1546            conflicts: None,
1547            default_operator: None,
1548            df: None,
1549            error_trace: None,
1550            expand_wildcards: None,
1551            filter_path: None,
1552            from: None,
1553            human: None,
1554            ignore_unavailable: None,
1555            lenient: None,
1556            max_docs: None,
1557            preference: None,
1558            pretty: None,
1559            q: None,
1560            refresh: None,
1561            request_cache: None,
1562            request_timeout: None,
1563            requests_per_second: None,
1564            routing: None,
1565            scroll: None,
1566            scroll_size: None,
1567            search_timeout: None,
1568            search_type: None,
1569            size: None,
1570            slices: None,
1571            sort: None,
1572            source: None,
1573            stats: None,
1574            terminate_after: None,
1575            timeout: None,
1576            version: None,
1577            wait_for_active_shards: None,
1578            wait_for_completion: None,
1579        }
1580    }
1581    #[doc = "True or false to return the _source field or not, or a list of fields to return"]
1582    pub fn _source(mut self, _source: &'b [&'b str]) -> Self {
1583        self._source = Some(_source);
1584        self
1585    }
1586    #[doc = "A list of fields to exclude from the returned _source field"]
1587    pub fn _source_excludes(mut self, _source_excludes: &'b [&'b str]) -> Self {
1588        self._source_excludes = Some(_source_excludes);
1589        self
1590    }
1591    #[doc = "A list of fields to extract and return from the _source field"]
1592    pub fn _source_includes(mut self, _source_includes: &'b [&'b str]) -> Self {
1593        self._source_includes = Some(_source_includes);
1594        self
1595    }
1596    #[doc = "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)"]
1597    pub fn allow_no_indices(mut self, allow_no_indices: bool) -> Self {
1598        self.allow_no_indices = Some(allow_no_indices);
1599        self
1600    }
1601    #[doc = "Specify whether wildcard and prefix queries should be analyzed (default: false)"]
1602    pub fn analyze_wildcard(mut self, analyze_wildcard: bool) -> Self {
1603        self.analyze_wildcard = Some(analyze_wildcard);
1604        self
1605    }
1606    #[doc = "The analyzer to use for the query string"]
1607    pub fn analyzer(mut self, analyzer: &'b str) -> Self {
1608        self.analyzer = Some(analyzer);
1609        self
1610    }
1611    #[doc = "The body for the API call"]
1612    pub fn body<T>(self, body: T) -> DeleteByQuery<'a, 'b, JsonBody<T>>
1613    where
1614        T: Serialize,
1615    {
1616        DeleteByQuery {
1617            transport: self.transport,
1618            parts: self.parts,
1619            body: Some(body.into()),
1620            _source: self._source,
1621            _source_excludes: self._source_excludes,
1622            _source_includes: self._source_includes,
1623            allow_no_indices: self.allow_no_indices,
1624            analyze_wildcard: self.analyze_wildcard,
1625            analyzer: self.analyzer,
1626            conflicts: self.conflicts,
1627            default_operator: self.default_operator,
1628            df: self.df,
1629            error_trace: self.error_trace,
1630            expand_wildcards: self.expand_wildcards,
1631            filter_path: self.filter_path,
1632            from: self.from,
1633            headers: self.headers,
1634            human: self.human,
1635            ignore_unavailable: self.ignore_unavailable,
1636            lenient: self.lenient,
1637            max_docs: self.max_docs,
1638            preference: self.preference,
1639            pretty: self.pretty,
1640            q: self.q,
1641            refresh: self.refresh,
1642            request_cache: self.request_cache,
1643            request_timeout: self.request_timeout,
1644            requests_per_second: self.requests_per_second,
1645            routing: self.routing,
1646            scroll: self.scroll,
1647            scroll_size: self.scroll_size,
1648            search_timeout: self.search_timeout,
1649            search_type: self.search_type,
1650            size: self.size,
1651            slices: self.slices,
1652            sort: self.sort,
1653            source: self.source,
1654            stats: self.stats,
1655            terminate_after: self.terminate_after,
1656            timeout: self.timeout,
1657            version: self.version,
1658            wait_for_active_shards: self.wait_for_active_shards,
1659            wait_for_completion: self.wait_for_completion,
1660        }
1661    }
1662    #[doc = "What to do when the delete by query hits version conflicts?"]
1663    pub fn conflicts(mut self, conflicts: Conflicts) -> Self {
1664        self.conflicts = Some(conflicts);
1665        self
1666    }
1667    #[doc = "The default operator for query string query (AND or OR)"]
1668    pub fn default_operator(mut self, default_operator: DefaultOperator) -> Self {
1669        self.default_operator = Some(default_operator);
1670        self
1671    }
1672    #[doc = "The field to use as default where no field prefix is given in the query string"]
1673    pub fn df(mut self, df: &'b str) -> Self {
1674        self.df = Some(df);
1675        self
1676    }
1677    #[doc = "Include the stack trace of returned errors."]
1678    pub fn error_trace(mut self, error_trace: bool) -> Self {
1679        self.error_trace = Some(error_trace);
1680        self
1681    }
1682    #[doc = "Whether to expand wildcard expression to concrete indices that are open, closed or both."]
1683    pub fn expand_wildcards(mut self, expand_wildcards: &'b [ExpandWildcards]) -> Self {
1684        self.expand_wildcards = Some(expand_wildcards);
1685        self
1686    }
1687    #[doc = "A comma-separated list of filters used to reduce the response."]
1688    pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
1689        self.filter_path = Some(filter_path);
1690        self
1691    }
1692    #[doc = "Starting offset (default: 0)"]
1693    pub fn from(mut self, from: i64) -> Self {
1694        self.from = Some(from);
1695        self
1696    }
1697    #[doc = "Adds a HTTP header"]
1698    pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
1699        self.headers.insert(key, value);
1700        self
1701    }
1702    #[doc = "Return human readable values for statistics."]
1703    pub fn human(mut self, human: bool) -> Self {
1704        self.human = Some(human);
1705        self
1706    }
1707    #[doc = "Whether specified concrete indices should be ignored when unavailable (missing or closed)"]
1708    pub fn ignore_unavailable(mut self, ignore_unavailable: bool) -> Self {
1709        self.ignore_unavailable = Some(ignore_unavailable);
1710        self
1711    }
1712    #[doc = "Specify whether format-based query failures (such as providing text to a numeric field) should be ignored"]
1713    pub fn lenient(mut self, lenient: bool) -> Self {
1714        self.lenient = Some(lenient);
1715        self
1716    }
1717    #[doc = "Maximum number of documents to process (default: all documents)"]
1718    pub fn max_docs(mut self, max_docs: i64) -> Self {
1719        self.max_docs = Some(max_docs);
1720        self
1721    }
1722    #[doc = "Specify the node or shard the operation should be performed on (default: random)"]
1723    pub fn preference(mut self, preference: &'b str) -> Self {
1724        self.preference = Some(preference);
1725        self
1726    }
1727    #[doc = "Pretty format the returned JSON response."]
1728    pub fn pretty(mut self, pretty: bool) -> Self {
1729        self.pretty = Some(pretty);
1730        self
1731    }
1732    #[doc = "Query in the Lucene query string syntax"]
1733    pub fn q(mut self, q: &'b str) -> Self {
1734        self.q = Some(q);
1735        self
1736    }
1737    #[doc = "Should the effected indexes be refreshed?"]
1738    pub fn refresh(mut self, refresh: bool) -> Self {
1739        self.refresh = Some(refresh);
1740        self
1741    }
1742    #[doc = "Specify if request cache should be used for this request or not, defaults to index level setting"]
1743    pub fn request_cache(mut self, request_cache: bool) -> Self {
1744        self.request_cache = Some(request_cache);
1745        self
1746    }
1747    #[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."]
1748    pub fn request_timeout(mut self, timeout: Duration) -> Self {
1749        self.request_timeout = Some(timeout);
1750        self
1751    }
1752    #[doc = "The throttle for this request in sub-requests per second. -1 means no throttle."]
1753    pub fn requests_per_second(mut self, requests_per_second: i64) -> Self {
1754        self.requests_per_second = Some(requests_per_second);
1755        self
1756    }
1757    #[doc = "A comma-separated list of specific routing values"]
1758    pub fn routing(mut self, routing: &'b [&'b str]) -> Self {
1759        self.routing = Some(routing);
1760        self
1761    }
1762    #[doc = "Specify how long a consistent view of the index should be maintained for scrolled search"]
1763    pub fn scroll(mut self, scroll: &'b str) -> Self {
1764        self.scroll = Some(scroll);
1765        self
1766    }
1767    #[doc = "Size on the scroll request powering the delete by query"]
1768    pub fn scroll_size(mut self, scroll_size: i64) -> Self {
1769        self.scroll_size = Some(scroll_size);
1770        self
1771    }
1772    #[doc = "Explicit timeout for each search request. Defaults to no timeout."]
1773    pub fn search_timeout(mut self, search_timeout: &'b str) -> Self {
1774        self.search_timeout = Some(search_timeout);
1775        self
1776    }
1777    #[doc = "Search operation type"]
1778    pub fn search_type(mut self, search_type: SearchType) -> Self {
1779        self.search_type = Some(search_type);
1780        self
1781    }
1782    #[doc = "Deprecated, please use `max_docs` instead"]
1783    pub fn size(mut self, size: i64) -> Self {
1784        self.size = Some(size);
1785        self
1786    }
1787    #[doc = "The number of slices this task should be divided into. Defaults to 1, meaning the task isn't sliced into subtasks. Can be set to `auto`."]
1788    pub fn slices(mut self, slices: Slices) -> Self {
1789        self.slices = Some(slices);
1790        self
1791    }
1792    #[doc = "A comma-separated list of &lt;field&gt;:&lt;direction&gt; pairs"]
1793    pub fn sort(mut self, sort: &'b [&'b str]) -> Self {
1794        self.sort = Some(sort);
1795        self
1796    }
1797    #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
1798    pub fn source(mut self, source: &'b str) -> Self {
1799        self.source = Some(source);
1800        self
1801    }
1802    #[doc = "Specific 'tag' of the request for logging and statistical purposes"]
1803    pub fn stats(mut self, stats: &'b [&'b str]) -> Self {
1804        self.stats = Some(stats);
1805        self
1806    }
1807    #[doc = "The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early."]
1808    pub fn terminate_after(mut self, terminate_after: i64) -> Self {
1809        self.terminate_after = Some(terminate_after);
1810        self
1811    }
1812    #[doc = "Time each individual bulk request should wait for shards that are unavailable."]
1813    pub fn timeout(mut self, timeout: &'b str) -> Self {
1814        self.timeout = Some(timeout);
1815        self
1816    }
1817    #[doc = "Specify whether to return document version as part of a hit"]
1818    pub fn version(mut self, version: bool) -> Self {
1819        self.version = Some(version);
1820        self
1821    }
1822    #[doc = "Sets the number of shard copies that must be active before proceeding with the delete by query operation. Defaults to 1, meaning the primary shard only. 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)"]
1823    pub fn wait_for_active_shards(mut self, wait_for_active_shards: &'b str) -> Self {
1824        self.wait_for_active_shards = Some(wait_for_active_shards);
1825        self
1826    }
1827    #[doc = "Should the request should block until the delete by query is complete."]
1828    pub fn wait_for_completion(mut self, wait_for_completion: bool) -> Self {
1829        self.wait_for_completion = Some(wait_for_completion);
1830        self
1831    }
1832    #[doc = "Creates an asynchronous call to the Delete By Query API that can be awaited"]
1833    pub async fn send(self) -> Result<Response, Error> {
1834        let path = self.parts.url();
1835        let method = Method::Post;
1836        let headers = self.headers;
1837        let timeout = self.request_timeout;
1838        let query_string = {
1839            #[serde_with::skip_serializing_none]
1840            #[derive(Serialize)]
1841            struct QueryParams<'b> {
1842                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
1843                _source: Option<&'b [&'b str]>,
1844                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
1845                _source_excludes: Option<&'b [&'b str]>,
1846                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
1847                _source_includes: Option<&'b [&'b str]>,
1848                allow_no_indices: Option<bool>,
1849                analyze_wildcard: Option<bool>,
1850                analyzer: Option<&'b str>,
1851                conflicts: Option<Conflicts>,
1852                default_operator: Option<DefaultOperator>,
1853                df: Option<&'b str>,
1854                error_trace: Option<bool>,
1855                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
1856                expand_wildcards: Option<&'b [ExpandWildcards]>,
1857                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
1858                filter_path: Option<&'b [&'b str]>,
1859                from: Option<i64>,
1860                human: Option<bool>,
1861                ignore_unavailable: Option<bool>,
1862                lenient: Option<bool>,
1863                max_docs: Option<i64>,
1864                preference: Option<&'b str>,
1865                pretty: Option<bool>,
1866                q: Option<&'b str>,
1867                refresh: Option<bool>,
1868                request_cache: Option<bool>,
1869                requests_per_second: Option<i64>,
1870                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
1871                routing: Option<&'b [&'b str]>,
1872                scroll: Option<&'b str>,
1873                scroll_size: Option<i64>,
1874                search_timeout: Option<&'b str>,
1875                search_type: Option<SearchType>,
1876                size: Option<i64>,
1877                slices: Option<Slices>,
1878                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
1879                sort: Option<&'b [&'b str]>,
1880                source: Option<&'b str>,
1881                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
1882                stats: Option<&'b [&'b str]>,
1883                terminate_after: Option<i64>,
1884                timeout: Option<&'b str>,
1885                version: Option<bool>,
1886                wait_for_active_shards: Option<&'b str>,
1887                wait_for_completion: Option<bool>,
1888            }
1889            let query_params = QueryParams {
1890                _source: self._source,
1891                _source_excludes: self._source_excludes,
1892                _source_includes: self._source_includes,
1893                allow_no_indices: self.allow_no_indices,
1894                analyze_wildcard: self.analyze_wildcard,
1895                analyzer: self.analyzer,
1896                conflicts: self.conflicts,
1897                default_operator: self.default_operator,
1898                df: self.df,
1899                error_trace: self.error_trace,
1900                expand_wildcards: self.expand_wildcards,
1901                filter_path: self.filter_path,
1902                from: self.from,
1903                human: self.human,
1904                ignore_unavailable: self.ignore_unavailable,
1905                lenient: self.lenient,
1906                max_docs: self.max_docs,
1907                preference: self.preference,
1908                pretty: self.pretty,
1909                q: self.q,
1910                refresh: self.refresh,
1911                request_cache: self.request_cache,
1912                requests_per_second: self.requests_per_second,
1913                routing: self.routing,
1914                scroll: self.scroll,
1915                scroll_size: self.scroll_size,
1916                search_timeout: self.search_timeout,
1917                search_type: self.search_type,
1918                size: self.size,
1919                slices: self.slices,
1920                sort: self.sort,
1921                source: self.source,
1922                stats: self.stats,
1923                terminate_after: self.terminate_after,
1924                timeout: self.timeout,
1925                version: self.version,
1926                wait_for_active_shards: self.wait_for_active_shards,
1927                wait_for_completion: self.wait_for_completion,
1928            };
1929            Some(query_params)
1930        };
1931        let body = self.body;
1932        let response = self
1933            .transport
1934            .send(method, &path, headers, query_string.as_ref(), body, timeout)
1935            .await?;
1936        Ok(response)
1937    }
1938}
1939#[derive(Debug, Clone, PartialEq, Eq)]
1940#[doc = "API parts for the Delete By Query Rethrottle API"]
1941pub enum DeleteByQueryRethrottleParts<'b> {
1942    #[doc = "TaskId"]
1943    TaskId(&'b str),
1944}
1945impl<'b> DeleteByQueryRethrottleParts<'b> {
1946    #[doc = "Builds a relative URL path to the Delete By Query Rethrottle API"]
1947    pub fn url(self) -> Cow<'static, str> {
1948        match self {
1949            DeleteByQueryRethrottleParts::TaskId(task_id) => {
1950                let encoded_task_id: Cow<str> =
1951                    percent_encode(task_id.as_bytes(), PARTS_ENCODED).into();
1952                let mut p = String::with_capacity(30usize + encoded_task_id.len());
1953                p.push_str("/_delete_by_query/");
1954                p.push_str(encoded_task_id.as_ref());
1955                p.push_str("/_rethrottle");
1956                p.into()
1957            }
1958        }
1959    }
1960}
1961#[doc = "Builder for the [Delete By Query Rethrottle API](https://opensearch.org/docs/)\n\nChanges the number of requests per second for a particular Delete By Query operation."]
1962#[derive(Clone, Debug)]
1963pub struct DeleteByQueryRethrottle<'a, 'b, B> {
1964    transport: &'a Transport,
1965    parts: DeleteByQueryRethrottleParts<'b>,
1966    body: Option<B>,
1967    error_trace: Option<bool>,
1968    filter_path: Option<&'b [&'b str]>,
1969    headers: HeaderMap,
1970    human: Option<bool>,
1971    pretty: Option<bool>,
1972    request_timeout: Option<Duration>,
1973    requests_per_second: Option<i64>,
1974    source: Option<&'b str>,
1975}
1976impl<'a, 'b, B> DeleteByQueryRethrottle<'a, 'b, B>
1977where
1978    B: Body,
1979{
1980    #[doc = "Creates a new instance of [DeleteByQueryRethrottle] with the specified API parts"]
1981    pub fn new(transport: &'a Transport, parts: DeleteByQueryRethrottleParts<'b>) -> Self {
1982        let headers = HeaderMap::new();
1983        DeleteByQueryRethrottle {
1984            transport,
1985            parts,
1986            headers,
1987            body: None,
1988            error_trace: None,
1989            filter_path: None,
1990            human: None,
1991            pretty: None,
1992            request_timeout: None,
1993            requests_per_second: None,
1994            source: None,
1995        }
1996    }
1997    #[doc = "The body for the API call"]
1998    pub fn body<T>(self, body: T) -> DeleteByQueryRethrottle<'a, 'b, JsonBody<T>>
1999    where
2000        T: Serialize,
2001    {
2002        DeleteByQueryRethrottle {
2003            transport: self.transport,
2004            parts: self.parts,
2005            body: Some(body.into()),
2006            error_trace: self.error_trace,
2007            filter_path: self.filter_path,
2008            headers: self.headers,
2009            human: self.human,
2010            pretty: self.pretty,
2011            request_timeout: self.request_timeout,
2012            requests_per_second: self.requests_per_second,
2013            source: self.source,
2014        }
2015    }
2016    #[doc = "Include the stack trace of returned errors."]
2017    pub fn error_trace(mut self, error_trace: bool) -> Self {
2018        self.error_trace = Some(error_trace);
2019        self
2020    }
2021    #[doc = "A comma-separated list of filters used to reduce the response."]
2022    pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
2023        self.filter_path = Some(filter_path);
2024        self
2025    }
2026    #[doc = "Adds a HTTP header"]
2027    pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
2028        self.headers.insert(key, value);
2029        self
2030    }
2031    #[doc = "Return human readable values for statistics."]
2032    pub fn human(mut self, human: bool) -> Self {
2033        self.human = Some(human);
2034        self
2035    }
2036    #[doc = "Pretty format the returned JSON response."]
2037    pub fn pretty(mut self, pretty: bool) -> Self {
2038        self.pretty = Some(pretty);
2039        self
2040    }
2041    #[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."]
2042    pub fn request_timeout(mut self, timeout: Duration) -> Self {
2043        self.request_timeout = Some(timeout);
2044        self
2045    }
2046    #[doc = "The throttle to set on this request in floating sub-requests per second. -1 means set no throttle."]
2047    pub fn requests_per_second(mut self, requests_per_second: i64) -> Self {
2048        self.requests_per_second = Some(requests_per_second);
2049        self
2050    }
2051    #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
2052    pub fn source(mut self, source: &'b str) -> Self {
2053        self.source = Some(source);
2054        self
2055    }
2056    #[doc = "Creates an asynchronous call to the Delete By Query Rethrottle API that can be awaited"]
2057    pub async fn send(self) -> Result<Response, Error> {
2058        let path = self.parts.url();
2059        let method = Method::Post;
2060        let headers = self.headers;
2061        let timeout = self.request_timeout;
2062        let query_string = {
2063            #[serde_with::skip_serializing_none]
2064            #[derive(Serialize)]
2065            struct QueryParams<'b> {
2066                error_trace: Option<bool>,
2067                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
2068                filter_path: Option<&'b [&'b str]>,
2069                human: Option<bool>,
2070                pretty: Option<bool>,
2071                requests_per_second: Option<i64>,
2072                source: Option<&'b str>,
2073            }
2074            let query_params = QueryParams {
2075                error_trace: self.error_trace,
2076                filter_path: self.filter_path,
2077                human: self.human,
2078                pretty: self.pretty,
2079                requests_per_second: self.requests_per_second,
2080                source: self.source,
2081            };
2082            Some(query_params)
2083        };
2084        let body = self.body;
2085        let response = self
2086            .transport
2087            .send(method, &path, headers, query_string.as_ref(), body, timeout)
2088            .await?;
2089        Ok(response)
2090    }
2091}
2092#[derive(Debug, Clone, PartialEq, Eq)]
2093#[doc = "API parts for the Delete Pit API"]
2094pub enum DeletePitParts {
2095    #[doc = "No parts"]
2096    None,
2097}
2098impl DeletePitParts {
2099    #[doc = "Builds a relative URL path to the Delete Pit API"]
2100    pub fn url(self) -> Cow<'static, str> {
2101        match self {
2102            DeletePitParts::None => "/_search/point_in_time".into(),
2103        }
2104    }
2105}
2106#[doc = "Builder for the [Delete Pit API](https://opensearch.org/docs/latest/opensearch/rest-api/point_in_time/)\n\nDeletes one or more point in time searches based on the IDs passed."]
2107#[derive(Clone, Debug)]
2108pub struct DeletePit<'a, 'b, B> {
2109    transport: &'a Transport,
2110    parts: DeletePitParts,
2111    body: Option<B>,
2112    error_trace: Option<bool>,
2113    filter_path: Option<&'b [&'b str]>,
2114    headers: HeaderMap,
2115    human: Option<bool>,
2116    pretty: Option<bool>,
2117    request_timeout: Option<Duration>,
2118    source: Option<&'b str>,
2119}
2120impl<'a, 'b, B> DeletePit<'a, 'b, B>
2121where
2122    B: Body,
2123{
2124    #[doc = "Creates a new instance of [DeletePit]"]
2125    pub fn new(transport: &'a Transport) -> Self {
2126        let headers = HeaderMap::new();
2127        DeletePit {
2128            transport,
2129            parts: DeletePitParts::None,
2130            headers,
2131            body: None,
2132            error_trace: None,
2133            filter_path: None,
2134            human: None,
2135            pretty: None,
2136            request_timeout: None,
2137            source: None,
2138        }
2139    }
2140    #[doc = "The body for the API call"]
2141    pub fn body<T>(self, body: T) -> DeletePit<'a, 'b, JsonBody<T>>
2142    where
2143        T: Serialize,
2144    {
2145        DeletePit {
2146            transport: self.transport,
2147            parts: self.parts,
2148            body: Some(body.into()),
2149            error_trace: self.error_trace,
2150            filter_path: self.filter_path,
2151            headers: self.headers,
2152            human: self.human,
2153            pretty: self.pretty,
2154            request_timeout: self.request_timeout,
2155            source: self.source,
2156        }
2157    }
2158    #[doc = "Include the stack trace of returned errors."]
2159    pub fn error_trace(mut self, error_trace: bool) -> Self {
2160        self.error_trace = Some(error_trace);
2161        self
2162    }
2163    #[doc = "A comma-separated list of filters used to reduce the response."]
2164    pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
2165        self.filter_path = Some(filter_path);
2166        self
2167    }
2168    #[doc = "Adds a HTTP header"]
2169    pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
2170        self.headers.insert(key, value);
2171        self
2172    }
2173    #[doc = "Return human readable values for statistics."]
2174    pub fn human(mut self, human: bool) -> Self {
2175        self.human = Some(human);
2176        self
2177    }
2178    #[doc = "Pretty format the returned JSON response."]
2179    pub fn pretty(mut self, pretty: bool) -> Self {
2180        self.pretty = Some(pretty);
2181        self
2182    }
2183    #[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."]
2184    pub fn request_timeout(mut self, timeout: Duration) -> Self {
2185        self.request_timeout = Some(timeout);
2186        self
2187    }
2188    #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
2189    pub fn source(mut self, source: &'b str) -> Self {
2190        self.source = Some(source);
2191        self
2192    }
2193    #[doc = "Creates an asynchronous call to the Delete Pit API that can be awaited"]
2194    pub async fn send(self) -> Result<Response, Error> {
2195        let path = self.parts.url();
2196        let method = Method::Delete;
2197        let headers = self.headers;
2198        let timeout = self.request_timeout;
2199        let query_string = {
2200            #[serde_with::skip_serializing_none]
2201            #[derive(Serialize)]
2202            struct QueryParams<'b> {
2203                error_trace: Option<bool>,
2204                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
2205                filter_path: Option<&'b [&'b str]>,
2206                human: Option<bool>,
2207                pretty: Option<bool>,
2208                source: Option<&'b str>,
2209            }
2210            let query_params = QueryParams {
2211                error_trace: self.error_trace,
2212                filter_path: self.filter_path,
2213                human: self.human,
2214                pretty: self.pretty,
2215                source: self.source,
2216            };
2217            Some(query_params)
2218        };
2219        let body = self.body;
2220        let response = self
2221            .transport
2222            .send(method, &path, headers, query_string.as_ref(), body, timeout)
2223            .await?;
2224        Ok(response)
2225    }
2226}
2227#[derive(Debug, Clone, PartialEq, Eq)]
2228#[doc = "API parts for the Delete Script API"]
2229pub enum DeleteScriptParts<'b> {
2230    #[doc = "Id"]
2231    Id(&'b str),
2232}
2233impl<'b> DeleteScriptParts<'b> {
2234    #[doc = "Builds a relative URL path to the Delete Script API"]
2235    pub fn url(self) -> Cow<'static, str> {
2236        match self {
2237            DeleteScriptParts::Id(id) => {
2238                let encoded_id: Cow<str> = percent_encode(id.as_bytes(), PARTS_ENCODED).into();
2239                let mut p = String::with_capacity(10usize + encoded_id.len());
2240                p.push_str("/_scripts/");
2241                p.push_str(encoded_id.as_ref());
2242                p.into()
2243            }
2244        }
2245    }
2246}
2247#[doc = "Builder for the [Delete Script API](https://opensearch.org/docs/)\n\nDeletes a script."]
2248#[derive(Clone, Debug)]
2249pub struct DeleteScript<'a, 'b> {
2250    transport: &'a Transport,
2251    parts: DeleteScriptParts<'b>,
2252    cluster_manager_timeout: Option<&'b str>,
2253    error_trace: Option<bool>,
2254    filter_path: Option<&'b [&'b str]>,
2255    headers: HeaderMap,
2256    human: Option<bool>,
2257    master_timeout: Option<&'b str>,
2258    pretty: Option<bool>,
2259    request_timeout: Option<Duration>,
2260    source: Option<&'b str>,
2261    timeout: Option<&'b str>,
2262}
2263impl<'a, 'b> DeleteScript<'a, 'b> {
2264    #[doc = "Creates a new instance of [DeleteScript] with the specified API parts"]
2265    pub fn new(transport: &'a Transport, parts: DeleteScriptParts<'b>) -> Self {
2266        let headers = HeaderMap::new();
2267        DeleteScript {
2268            transport,
2269            parts,
2270            headers,
2271            cluster_manager_timeout: None,
2272            error_trace: None,
2273            filter_path: None,
2274            human: None,
2275            master_timeout: None,
2276            pretty: None,
2277            request_timeout: None,
2278            source: None,
2279            timeout: None,
2280        }
2281    }
2282    #[doc = "Specify timeout for connection to cluster-manager node"]
2283    pub fn cluster_manager_timeout(mut self, cluster_manager_timeout: &'b str) -> Self {
2284        self.cluster_manager_timeout = Some(cluster_manager_timeout);
2285        self
2286    }
2287    #[doc = "Include the stack trace of returned errors."]
2288    pub fn error_trace(mut self, error_trace: bool) -> Self {
2289        self.error_trace = Some(error_trace);
2290        self
2291    }
2292    #[doc = "A comma-separated list of filters used to reduce the response."]
2293    pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
2294        self.filter_path = Some(filter_path);
2295        self
2296    }
2297    #[doc = "Adds a HTTP header"]
2298    pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
2299        self.headers.insert(key, value);
2300        self
2301    }
2302    #[doc = "Return human readable values for statistics."]
2303    pub fn human(mut self, human: bool) -> Self {
2304        self.human = Some(human);
2305        self
2306    }
2307    #[doc = "Specify timeout for connection to cluster-manager node"]
2308    #[deprecated = "To support inclusive language, use 'cluster_manager_timeout' instead."]
2309    pub fn master_timeout(mut self, master_timeout: &'b str) -> Self {
2310        self.master_timeout = Some(master_timeout);
2311        self
2312    }
2313    #[doc = "Pretty format the returned JSON response."]
2314    pub fn pretty(mut self, pretty: bool) -> Self {
2315        self.pretty = Some(pretty);
2316        self
2317    }
2318    #[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."]
2319    pub fn request_timeout(mut self, timeout: Duration) -> Self {
2320        self.request_timeout = Some(timeout);
2321        self
2322    }
2323    #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
2324    pub fn source(mut self, source: &'b str) -> Self {
2325        self.source = Some(source);
2326        self
2327    }
2328    #[doc = "Explicit operation timeout"]
2329    pub fn timeout(mut self, timeout: &'b str) -> Self {
2330        self.timeout = Some(timeout);
2331        self
2332    }
2333    #[doc = "Creates an asynchronous call to the Delete Script API that can be awaited"]
2334    pub async fn send(self) -> Result<Response, Error> {
2335        let path = self.parts.url();
2336        let method = Method::Delete;
2337        let headers = self.headers;
2338        let timeout = self.request_timeout;
2339        let query_string = {
2340            #[serde_with::skip_serializing_none]
2341            #[derive(Serialize)]
2342            struct QueryParams<'b> {
2343                cluster_manager_timeout: Option<&'b str>,
2344                error_trace: Option<bool>,
2345                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
2346                filter_path: Option<&'b [&'b str]>,
2347                human: Option<bool>,
2348                master_timeout: Option<&'b str>,
2349                pretty: Option<bool>,
2350                source: Option<&'b str>,
2351                timeout: Option<&'b str>,
2352            }
2353            let query_params = QueryParams {
2354                cluster_manager_timeout: self.cluster_manager_timeout,
2355                error_trace: self.error_trace,
2356                filter_path: self.filter_path,
2357                human: self.human,
2358                master_timeout: self.master_timeout,
2359                pretty: self.pretty,
2360                source: self.source,
2361                timeout: self.timeout,
2362            };
2363            Some(query_params)
2364        };
2365        let body = Option::<()>::None;
2366        let response = self
2367            .transport
2368            .send(method, &path, headers, query_string.as_ref(), body, timeout)
2369            .await?;
2370        Ok(response)
2371    }
2372}
2373#[derive(Debug, Clone, PartialEq, Eq)]
2374#[doc = "API parts for the Exists API"]
2375pub enum ExistsParts<'b> {
2376    #[doc = "Index and Id"]
2377    IndexId(&'b str, &'b str),
2378}
2379impl<'b> ExistsParts<'b> {
2380    #[doc = "Builds a relative URL path to the Exists API"]
2381    pub fn url(self) -> Cow<'static, str> {
2382        match self {
2383            ExistsParts::IndexId(index, id) => {
2384                let encoded_index: Cow<str> =
2385                    percent_encode(index.as_bytes(), PARTS_ENCODED).into();
2386                let encoded_id: Cow<str> = percent_encode(id.as_bytes(), PARTS_ENCODED).into();
2387                let mut p = String::with_capacity(7usize + encoded_index.len() + encoded_id.len());
2388                p.push('/');
2389                p.push_str(encoded_index.as_ref());
2390                p.push_str("/_doc/");
2391                p.push_str(encoded_id.as_ref());
2392                p.into()
2393            }
2394        }
2395    }
2396}
2397#[doc = "Builder for the [Exists API](https://opensearch.org/docs/)\n\nReturns information about whether a document exists in an index."]
2398#[derive(Clone, Debug)]
2399pub struct Exists<'a, 'b> {
2400    transport: &'a Transport,
2401    parts: ExistsParts<'b>,
2402    _source: Option<&'b [&'b str]>,
2403    _source_excludes: Option<&'b [&'b str]>,
2404    _source_includes: Option<&'b [&'b str]>,
2405    error_trace: Option<bool>,
2406    filter_path: Option<&'b [&'b str]>,
2407    headers: HeaderMap,
2408    human: Option<bool>,
2409    preference: Option<&'b str>,
2410    pretty: Option<bool>,
2411    realtime: Option<bool>,
2412    refresh: Option<bool>,
2413    request_timeout: Option<Duration>,
2414    routing: Option<&'b str>,
2415    source: Option<&'b str>,
2416    stored_fields: Option<&'b [&'b str]>,
2417    version: Option<i64>,
2418    version_type: Option<VersionType>,
2419}
2420impl<'a, 'b> Exists<'a, 'b> {
2421    #[doc = "Creates a new instance of [Exists] with the specified API parts"]
2422    pub fn new(transport: &'a Transport, parts: ExistsParts<'b>) -> Self {
2423        let headers = HeaderMap::new();
2424        Exists {
2425            transport,
2426            parts,
2427            headers,
2428            _source: None,
2429            _source_excludes: None,
2430            _source_includes: None,
2431            error_trace: None,
2432            filter_path: None,
2433            human: None,
2434            preference: None,
2435            pretty: None,
2436            realtime: None,
2437            refresh: None,
2438            request_timeout: None,
2439            routing: None,
2440            source: None,
2441            stored_fields: None,
2442            version: None,
2443            version_type: None,
2444        }
2445    }
2446    #[doc = "True or false to return the _source field or not, or a list of fields to return"]
2447    pub fn _source(mut self, _source: &'b [&'b str]) -> Self {
2448        self._source = Some(_source);
2449        self
2450    }
2451    #[doc = "A list of fields to exclude from the returned _source field"]
2452    pub fn _source_excludes(mut self, _source_excludes: &'b [&'b str]) -> Self {
2453        self._source_excludes = Some(_source_excludes);
2454        self
2455    }
2456    #[doc = "A list of fields to extract and return from the _source field"]
2457    pub fn _source_includes(mut self, _source_includes: &'b [&'b str]) -> Self {
2458        self._source_includes = Some(_source_includes);
2459        self
2460    }
2461    #[doc = "Include the stack trace of returned errors."]
2462    pub fn error_trace(mut self, error_trace: bool) -> Self {
2463        self.error_trace = Some(error_trace);
2464        self
2465    }
2466    #[doc = "A comma-separated list of filters used to reduce the response."]
2467    pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
2468        self.filter_path = Some(filter_path);
2469        self
2470    }
2471    #[doc = "Adds a HTTP header"]
2472    pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
2473        self.headers.insert(key, value);
2474        self
2475    }
2476    #[doc = "Return human readable values for statistics."]
2477    pub fn human(mut self, human: bool) -> Self {
2478        self.human = Some(human);
2479        self
2480    }
2481    #[doc = "Specify the node or shard the operation should be performed on (default: random)"]
2482    pub fn preference(mut self, preference: &'b str) -> Self {
2483        self.preference = Some(preference);
2484        self
2485    }
2486    #[doc = "Pretty format the returned JSON response."]
2487    pub fn pretty(mut self, pretty: bool) -> Self {
2488        self.pretty = Some(pretty);
2489        self
2490    }
2491    #[doc = "Specify whether to perform the operation in realtime or search mode"]
2492    pub fn realtime(mut self, realtime: bool) -> Self {
2493        self.realtime = Some(realtime);
2494        self
2495    }
2496    #[doc = "Refresh the shard containing the document before performing the operation"]
2497    pub fn refresh(mut self, refresh: bool) -> Self {
2498        self.refresh = Some(refresh);
2499        self
2500    }
2501    #[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."]
2502    pub fn request_timeout(mut self, timeout: Duration) -> Self {
2503        self.request_timeout = Some(timeout);
2504        self
2505    }
2506    #[doc = "Specific routing value"]
2507    pub fn routing(mut self, routing: &'b str) -> Self {
2508        self.routing = Some(routing);
2509        self
2510    }
2511    #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
2512    pub fn source(mut self, source: &'b str) -> Self {
2513        self.source = Some(source);
2514        self
2515    }
2516    #[doc = "A comma-separated list of stored fields to return in the response"]
2517    pub fn stored_fields(mut self, stored_fields: &'b [&'b str]) -> Self {
2518        self.stored_fields = Some(stored_fields);
2519        self
2520    }
2521    #[doc = "Explicit version number for concurrency control"]
2522    pub fn version(mut self, version: i64) -> Self {
2523        self.version = Some(version);
2524        self
2525    }
2526    #[doc = "Specific version type"]
2527    pub fn version_type(mut self, version_type: VersionType) -> Self {
2528        self.version_type = Some(version_type);
2529        self
2530    }
2531    #[doc = "Creates an asynchronous call to the Exists API that can be awaited"]
2532    pub async fn send(self) -> Result<Response, Error> {
2533        let path = self.parts.url();
2534        let method = Method::Head;
2535        let headers = self.headers;
2536        let timeout = self.request_timeout;
2537        let query_string = {
2538            #[serde_with::skip_serializing_none]
2539            #[derive(Serialize)]
2540            struct QueryParams<'b> {
2541                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
2542                _source: Option<&'b [&'b str]>,
2543                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
2544                _source_excludes: Option<&'b [&'b str]>,
2545                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
2546                _source_includes: Option<&'b [&'b str]>,
2547                error_trace: Option<bool>,
2548                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
2549                filter_path: Option<&'b [&'b str]>,
2550                human: Option<bool>,
2551                preference: Option<&'b str>,
2552                pretty: Option<bool>,
2553                realtime: Option<bool>,
2554                refresh: Option<bool>,
2555                routing: Option<&'b str>,
2556                source: Option<&'b str>,
2557                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
2558                stored_fields: Option<&'b [&'b str]>,
2559                version: Option<i64>,
2560                version_type: Option<VersionType>,
2561            }
2562            let query_params = QueryParams {
2563                _source: self._source,
2564                _source_excludes: self._source_excludes,
2565                _source_includes: self._source_includes,
2566                error_trace: self.error_trace,
2567                filter_path: self.filter_path,
2568                human: self.human,
2569                preference: self.preference,
2570                pretty: self.pretty,
2571                realtime: self.realtime,
2572                refresh: self.refresh,
2573                routing: self.routing,
2574                source: self.source,
2575                stored_fields: self.stored_fields,
2576                version: self.version,
2577                version_type: self.version_type,
2578            };
2579            Some(query_params)
2580        };
2581        let body = Option::<()>::None;
2582        let response = self
2583            .transport
2584            .send(method, &path, headers, query_string.as_ref(), body, timeout)
2585            .await?;
2586        Ok(response)
2587    }
2588}
2589#[derive(Debug, Clone, PartialEq, Eq)]
2590#[doc = "API parts for the Exists Source API"]
2591pub enum ExistsSourceParts<'b> {
2592    #[doc = "Index and Id"]
2593    IndexId(&'b str, &'b str),
2594}
2595impl<'b> ExistsSourceParts<'b> {
2596    #[doc = "Builds a relative URL path to the Exists Source API"]
2597    pub fn url(self) -> Cow<'static, str> {
2598        match self {
2599            ExistsSourceParts::IndexId(index, id) => {
2600                let encoded_index: Cow<str> =
2601                    percent_encode(index.as_bytes(), PARTS_ENCODED).into();
2602                let encoded_id: Cow<str> = percent_encode(id.as_bytes(), PARTS_ENCODED).into();
2603                let mut p = String::with_capacity(10usize + encoded_index.len() + encoded_id.len());
2604                p.push('/');
2605                p.push_str(encoded_index.as_ref());
2606                p.push_str("/_source/");
2607                p.push_str(encoded_id.as_ref());
2608                p.into()
2609            }
2610        }
2611    }
2612}
2613#[doc = "Builder for the [Exists Source API](https://opensearch.org/docs/)\n\nReturns information about whether a document source exists in an index."]
2614#[derive(Clone, Debug)]
2615pub struct ExistsSource<'a, 'b> {
2616    transport: &'a Transport,
2617    parts: ExistsSourceParts<'b>,
2618    _source: Option<&'b [&'b str]>,
2619    _source_excludes: Option<&'b [&'b str]>,
2620    _source_includes: Option<&'b [&'b str]>,
2621    error_trace: Option<bool>,
2622    filter_path: Option<&'b [&'b str]>,
2623    headers: HeaderMap,
2624    human: Option<bool>,
2625    preference: Option<&'b str>,
2626    pretty: Option<bool>,
2627    realtime: Option<bool>,
2628    refresh: Option<bool>,
2629    request_timeout: Option<Duration>,
2630    routing: Option<&'b str>,
2631    source: Option<&'b str>,
2632    version: Option<i64>,
2633    version_type: Option<VersionType>,
2634}
2635impl<'a, 'b> ExistsSource<'a, 'b> {
2636    #[doc = "Creates a new instance of [ExistsSource] with the specified API parts"]
2637    pub fn new(transport: &'a Transport, parts: ExistsSourceParts<'b>) -> Self {
2638        let headers = HeaderMap::new();
2639        ExistsSource {
2640            transport,
2641            parts,
2642            headers,
2643            _source: None,
2644            _source_excludes: None,
2645            _source_includes: None,
2646            error_trace: None,
2647            filter_path: None,
2648            human: None,
2649            preference: None,
2650            pretty: None,
2651            realtime: None,
2652            refresh: None,
2653            request_timeout: None,
2654            routing: None,
2655            source: None,
2656            version: None,
2657            version_type: None,
2658        }
2659    }
2660    #[doc = "True or false to return the _source field or not, or a list of fields to return"]
2661    pub fn _source(mut self, _source: &'b [&'b str]) -> Self {
2662        self._source = Some(_source);
2663        self
2664    }
2665    #[doc = "A list of fields to exclude from the returned _source field"]
2666    pub fn _source_excludes(mut self, _source_excludes: &'b [&'b str]) -> Self {
2667        self._source_excludes = Some(_source_excludes);
2668        self
2669    }
2670    #[doc = "A list of fields to extract and return from the _source field"]
2671    pub fn _source_includes(mut self, _source_includes: &'b [&'b str]) -> Self {
2672        self._source_includes = Some(_source_includes);
2673        self
2674    }
2675    #[doc = "Include the stack trace of returned errors."]
2676    pub fn error_trace(mut self, error_trace: bool) -> Self {
2677        self.error_trace = Some(error_trace);
2678        self
2679    }
2680    #[doc = "A comma-separated list of filters used to reduce the response."]
2681    pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
2682        self.filter_path = Some(filter_path);
2683        self
2684    }
2685    #[doc = "Adds a HTTP header"]
2686    pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
2687        self.headers.insert(key, value);
2688        self
2689    }
2690    #[doc = "Return human readable values for statistics."]
2691    pub fn human(mut self, human: bool) -> Self {
2692        self.human = Some(human);
2693        self
2694    }
2695    #[doc = "Specify the node or shard the operation should be performed on (default: random)"]
2696    pub fn preference(mut self, preference: &'b str) -> Self {
2697        self.preference = Some(preference);
2698        self
2699    }
2700    #[doc = "Pretty format the returned JSON response."]
2701    pub fn pretty(mut self, pretty: bool) -> Self {
2702        self.pretty = Some(pretty);
2703        self
2704    }
2705    #[doc = "Specify whether to perform the operation in realtime or search mode"]
2706    pub fn realtime(mut self, realtime: bool) -> Self {
2707        self.realtime = Some(realtime);
2708        self
2709    }
2710    #[doc = "Refresh the shard containing the document before performing the operation"]
2711    pub fn refresh(mut self, refresh: bool) -> Self {
2712        self.refresh = Some(refresh);
2713        self
2714    }
2715    #[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."]
2716    pub fn request_timeout(mut self, timeout: Duration) -> Self {
2717        self.request_timeout = Some(timeout);
2718        self
2719    }
2720    #[doc = "Specific routing value"]
2721    pub fn routing(mut self, routing: &'b str) -> Self {
2722        self.routing = Some(routing);
2723        self
2724    }
2725    #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
2726    pub fn source(mut self, source: &'b str) -> Self {
2727        self.source = Some(source);
2728        self
2729    }
2730    #[doc = "Explicit version number for concurrency control"]
2731    pub fn version(mut self, version: i64) -> Self {
2732        self.version = Some(version);
2733        self
2734    }
2735    #[doc = "Specific version type"]
2736    pub fn version_type(mut self, version_type: VersionType) -> Self {
2737        self.version_type = Some(version_type);
2738        self
2739    }
2740    #[doc = "Creates an asynchronous call to the Exists Source API that can be awaited"]
2741    pub async fn send(self) -> Result<Response, Error> {
2742        let path = self.parts.url();
2743        let method = Method::Head;
2744        let headers = self.headers;
2745        let timeout = self.request_timeout;
2746        let query_string = {
2747            #[serde_with::skip_serializing_none]
2748            #[derive(Serialize)]
2749            struct QueryParams<'b> {
2750                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
2751                _source: Option<&'b [&'b str]>,
2752                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
2753                _source_excludes: Option<&'b [&'b str]>,
2754                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
2755                _source_includes: Option<&'b [&'b str]>,
2756                error_trace: Option<bool>,
2757                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
2758                filter_path: Option<&'b [&'b str]>,
2759                human: Option<bool>,
2760                preference: Option<&'b str>,
2761                pretty: Option<bool>,
2762                realtime: Option<bool>,
2763                refresh: Option<bool>,
2764                routing: Option<&'b str>,
2765                source: Option<&'b str>,
2766                version: Option<i64>,
2767                version_type: Option<VersionType>,
2768            }
2769            let query_params = QueryParams {
2770                _source: self._source,
2771                _source_excludes: self._source_excludes,
2772                _source_includes: self._source_includes,
2773                error_trace: self.error_trace,
2774                filter_path: self.filter_path,
2775                human: self.human,
2776                preference: self.preference,
2777                pretty: self.pretty,
2778                realtime: self.realtime,
2779                refresh: self.refresh,
2780                routing: self.routing,
2781                source: self.source,
2782                version: self.version,
2783                version_type: self.version_type,
2784            };
2785            Some(query_params)
2786        };
2787        let body = Option::<()>::None;
2788        let response = self
2789            .transport
2790            .send(method, &path, headers, query_string.as_ref(), body, timeout)
2791            .await?;
2792        Ok(response)
2793    }
2794}
2795#[derive(Debug, Clone, PartialEq, Eq)]
2796#[doc = "API parts for the Explain API"]
2797pub enum ExplainParts<'b> {
2798    #[doc = "Index and Id"]
2799    IndexId(&'b str, &'b str),
2800}
2801impl<'b> ExplainParts<'b> {
2802    #[doc = "Builds a relative URL path to the Explain API"]
2803    pub fn url(self) -> Cow<'static, str> {
2804        match self {
2805            ExplainParts::IndexId(index, id) => {
2806                let encoded_index: Cow<str> =
2807                    percent_encode(index.as_bytes(), PARTS_ENCODED).into();
2808                let encoded_id: Cow<str> = percent_encode(id.as_bytes(), PARTS_ENCODED).into();
2809                let mut p = String::with_capacity(11usize + encoded_index.len() + encoded_id.len());
2810                p.push('/');
2811                p.push_str(encoded_index.as_ref());
2812                p.push_str("/_explain/");
2813                p.push_str(encoded_id.as_ref());
2814                p.into()
2815            }
2816        }
2817    }
2818}
2819#[doc = "Builder for the [Explain API](https://opensearch.org/docs/)\n\nReturns information about why a specific matches (or doesn't match) a query."]
2820#[derive(Clone, Debug)]
2821pub struct Explain<'a, 'b, B> {
2822    transport: &'a Transport,
2823    parts: ExplainParts<'b>,
2824    _source: Option<&'b [&'b str]>,
2825    _source_excludes: Option<&'b [&'b str]>,
2826    _source_includes: Option<&'b [&'b str]>,
2827    analyze_wildcard: Option<bool>,
2828    analyzer: Option<&'b str>,
2829    body: Option<B>,
2830    default_operator: Option<DefaultOperator>,
2831    df: Option<&'b str>,
2832    error_trace: Option<bool>,
2833    filter_path: Option<&'b [&'b str]>,
2834    headers: HeaderMap,
2835    human: Option<bool>,
2836    lenient: Option<bool>,
2837    preference: Option<&'b str>,
2838    pretty: Option<bool>,
2839    q: Option<&'b str>,
2840    request_timeout: Option<Duration>,
2841    routing: Option<&'b str>,
2842    source: Option<&'b str>,
2843    stored_fields: Option<&'b [&'b str]>,
2844}
2845impl<'a, 'b, B> Explain<'a, 'b, B>
2846where
2847    B: Body,
2848{
2849    #[doc = "Creates a new instance of [Explain] with the specified API parts"]
2850    pub fn new(transport: &'a Transport, parts: ExplainParts<'b>) -> Self {
2851        let headers = HeaderMap::new();
2852        Explain {
2853            transport,
2854            parts,
2855            headers,
2856            _source: None,
2857            _source_excludes: None,
2858            _source_includes: None,
2859            analyze_wildcard: None,
2860            analyzer: None,
2861            body: None,
2862            default_operator: None,
2863            df: None,
2864            error_trace: None,
2865            filter_path: None,
2866            human: None,
2867            lenient: None,
2868            preference: None,
2869            pretty: None,
2870            q: None,
2871            request_timeout: None,
2872            routing: None,
2873            source: None,
2874            stored_fields: None,
2875        }
2876    }
2877    #[doc = "True or false to return the _source field or not, or a list of fields to return"]
2878    pub fn _source(mut self, _source: &'b [&'b str]) -> Self {
2879        self._source = Some(_source);
2880        self
2881    }
2882    #[doc = "A list of fields to exclude from the returned _source field"]
2883    pub fn _source_excludes(mut self, _source_excludes: &'b [&'b str]) -> Self {
2884        self._source_excludes = Some(_source_excludes);
2885        self
2886    }
2887    #[doc = "A list of fields to extract and return from the _source field"]
2888    pub fn _source_includes(mut self, _source_includes: &'b [&'b str]) -> Self {
2889        self._source_includes = Some(_source_includes);
2890        self
2891    }
2892    #[doc = "Specify whether wildcards and prefix queries in the query string query should be analyzed (default: false)"]
2893    pub fn analyze_wildcard(mut self, analyze_wildcard: bool) -> Self {
2894        self.analyze_wildcard = Some(analyze_wildcard);
2895        self
2896    }
2897    #[doc = "The analyzer for the query string query"]
2898    pub fn analyzer(mut self, analyzer: &'b str) -> Self {
2899        self.analyzer = Some(analyzer);
2900        self
2901    }
2902    #[doc = "The body for the API call"]
2903    pub fn body<T>(self, body: T) -> Explain<'a, 'b, JsonBody<T>>
2904    where
2905        T: Serialize,
2906    {
2907        Explain {
2908            transport: self.transport,
2909            parts: self.parts,
2910            body: Some(body.into()),
2911            _source: self._source,
2912            _source_excludes: self._source_excludes,
2913            _source_includes: self._source_includes,
2914            analyze_wildcard: self.analyze_wildcard,
2915            analyzer: self.analyzer,
2916            default_operator: self.default_operator,
2917            df: self.df,
2918            error_trace: self.error_trace,
2919            filter_path: self.filter_path,
2920            headers: self.headers,
2921            human: self.human,
2922            lenient: self.lenient,
2923            preference: self.preference,
2924            pretty: self.pretty,
2925            q: self.q,
2926            request_timeout: self.request_timeout,
2927            routing: self.routing,
2928            source: self.source,
2929            stored_fields: self.stored_fields,
2930        }
2931    }
2932    #[doc = "The default operator for query string query (AND or OR)"]
2933    pub fn default_operator(mut self, default_operator: DefaultOperator) -> Self {
2934        self.default_operator = Some(default_operator);
2935        self
2936    }
2937    #[doc = "The default field for query string query (default: _all)"]
2938    pub fn df(mut self, df: &'b str) -> Self {
2939        self.df = Some(df);
2940        self
2941    }
2942    #[doc = "Include the stack trace of returned errors."]
2943    pub fn error_trace(mut self, error_trace: bool) -> Self {
2944        self.error_trace = Some(error_trace);
2945        self
2946    }
2947    #[doc = "A comma-separated list of filters used to reduce the response."]
2948    pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
2949        self.filter_path = Some(filter_path);
2950        self
2951    }
2952    #[doc = "Adds a HTTP header"]
2953    pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
2954        self.headers.insert(key, value);
2955        self
2956    }
2957    #[doc = "Return human readable values for statistics."]
2958    pub fn human(mut self, human: bool) -> Self {
2959        self.human = Some(human);
2960        self
2961    }
2962    #[doc = "Specify whether format-based query failures (such as providing text to a numeric field) should be ignored"]
2963    pub fn lenient(mut self, lenient: bool) -> Self {
2964        self.lenient = Some(lenient);
2965        self
2966    }
2967    #[doc = "Specify the node or shard the operation should be performed on (default: random)"]
2968    pub fn preference(mut self, preference: &'b str) -> Self {
2969        self.preference = Some(preference);
2970        self
2971    }
2972    #[doc = "Pretty format the returned JSON response."]
2973    pub fn pretty(mut self, pretty: bool) -> Self {
2974        self.pretty = Some(pretty);
2975        self
2976    }
2977    #[doc = "Query in the Lucene query string syntax"]
2978    pub fn q(mut self, q: &'b str) -> Self {
2979        self.q = Some(q);
2980        self
2981    }
2982    #[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."]
2983    pub fn request_timeout(mut self, timeout: Duration) -> Self {
2984        self.request_timeout = Some(timeout);
2985        self
2986    }
2987    #[doc = "Specific routing value"]
2988    pub fn routing(mut self, routing: &'b str) -> Self {
2989        self.routing = Some(routing);
2990        self
2991    }
2992    #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
2993    pub fn source(mut self, source: &'b str) -> Self {
2994        self.source = Some(source);
2995        self
2996    }
2997    #[doc = "A comma-separated list of stored fields to return in the response"]
2998    pub fn stored_fields(mut self, stored_fields: &'b [&'b str]) -> Self {
2999        self.stored_fields = Some(stored_fields);
3000        self
3001    }
3002    #[doc = "Creates an asynchronous call to the Explain API that can be awaited"]
3003    pub async fn send(self) -> Result<Response, Error> {
3004        let path = self.parts.url();
3005        let method = match self.body {
3006            Some(_) => Method::Post,
3007            None => Method::Get,
3008        };
3009        let headers = self.headers;
3010        let timeout = self.request_timeout;
3011        let query_string = {
3012            #[serde_with::skip_serializing_none]
3013            #[derive(Serialize)]
3014            struct QueryParams<'b> {
3015                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
3016                _source: Option<&'b [&'b str]>,
3017                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
3018                _source_excludes: Option<&'b [&'b str]>,
3019                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
3020                _source_includes: Option<&'b [&'b str]>,
3021                analyze_wildcard: Option<bool>,
3022                analyzer: Option<&'b str>,
3023                default_operator: Option<DefaultOperator>,
3024                df: Option<&'b str>,
3025                error_trace: Option<bool>,
3026                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
3027                filter_path: Option<&'b [&'b str]>,
3028                human: Option<bool>,
3029                lenient: Option<bool>,
3030                preference: Option<&'b str>,
3031                pretty: Option<bool>,
3032                q: Option<&'b str>,
3033                routing: Option<&'b str>,
3034                source: Option<&'b str>,
3035                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
3036                stored_fields: Option<&'b [&'b str]>,
3037            }
3038            let query_params = QueryParams {
3039                _source: self._source,
3040                _source_excludes: self._source_excludes,
3041                _source_includes: self._source_includes,
3042                analyze_wildcard: self.analyze_wildcard,
3043                analyzer: self.analyzer,
3044                default_operator: self.default_operator,
3045                df: self.df,
3046                error_trace: self.error_trace,
3047                filter_path: self.filter_path,
3048                human: self.human,
3049                lenient: self.lenient,
3050                preference: self.preference,
3051                pretty: self.pretty,
3052                q: self.q,
3053                routing: self.routing,
3054                source: self.source,
3055                stored_fields: self.stored_fields,
3056            };
3057            Some(query_params)
3058        };
3059        let body = self.body;
3060        let response = self
3061            .transport
3062            .send(method, &path, headers, query_string.as_ref(), body, timeout)
3063            .await?;
3064        Ok(response)
3065    }
3066}
3067#[derive(Debug, Clone, PartialEq, Eq)]
3068#[doc = "API parts for the Field Caps API"]
3069pub enum FieldCapsParts<'b> {
3070    #[doc = "No parts"]
3071    None,
3072    #[doc = "Index"]
3073    Index(&'b [&'b str]),
3074}
3075impl<'b> FieldCapsParts<'b> {
3076    #[doc = "Builds a relative URL path to the Field Caps API"]
3077    pub fn url(self) -> Cow<'static, str> {
3078        match self {
3079            FieldCapsParts::None => "/_field_caps".into(),
3080            FieldCapsParts::Index(index) => {
3081                let index_str = index.join(",");
3082                let encoded_index: Cow<str> =
3083                    percent_encode(index_str.as_bytes(), PARTS_ENCODED).into();
3084                let mut p = String::with_capacity(13usize + encoded_index.len());
3085                p.push('/');
3086                p.push_str(encoded_index.as_ref());
3087                p.push_str("/_field_caps");
3088                p.into()
3089            }
3090        }
3091    }
3092}
3093#[doc = "Builder for the [Field Caps API](https://opensearch.org/docs/)\n\nReturns the information about the capabilities of fields among multiple indices."]
3094#[derive(Clone, Debug)]
3095pub struct FieldCaps<'a, 'b, B> {
3096    transport: &'a Transport,
3097    parts: FieldCapsParts<'b>,
3098    allow_no_indices: Option<bool>,
3099    body: Option<B>,
3100    error_trace: Option<bool>,
3101    expand_wildcards: Option<&'b [ExpandWildcards]>,
3102    fields: Option<&'b [&'b str]>,
3103    filter_path: Option<&'b [&'b str]>,
3104    headers: HeaderMap,
3105    human: Option<bool>,
3106    ignore_unavailable: Option<bool>,
3107    include_unmapped: Option<bool>,
3108    pretty: Option<bool>,
3109    request_timeout: Option<Duration>,
3110    source: Option<&'b str>,
3111}
3112impl<'a, 'b, B> FieldCaps<'a, 'b, B>
3113where
3114    B: Body,
3115{
3116    #[doc = "Creates a new instance of [FieldCaps] with the specified API parts"]
3117    pub fn new(transport: &'a Transport, parts: FieldCapsParts<'b>) -> Self {
3118        let headers = HeaderMap::new();
3119        FieldCaps {
3120            transport,
3121            parts,
3122            headers,
3123            allow_no_indices: None,
3124            body: None,
3125            error_trace: None,
3126            expand_wildcards: None,
3127            fields: None,
3128            filter_path: None,
3129            human: None,
3130            ignore_unavailable: None,
3131            include_unmapped: None,
3132            pretty: None,
3133            request_timeout: None,
3134            source: None,
3135        }
3136    }
3137    #[doc = "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)"]
3138    pub fn allow_no_indices(mut self, allow_no_indices: bool) -> Self {
3139        self.allow_no_indices = Some(allow_no_indices);
3140        self
3141    }
3142    #[doc = "The body for the API call"]
3143    pub fn body<T>(self, body: T) -> FieldCaps<'a, 'b, JsonBody<T>>
3144    where
3145        T: Serialize,
3146    {
3147        FieldCaps {
3148            transport: self.transport,
3149            parts: self.parts,
3150            body: Some(body.into()),
3151            allow_no_indices: self.allow_no_indices,
3152            error_trace: self.error_trace,
3153            expand_wildcards: self.expand_wildcards,
3154            fields: self.fields,
3155            filter_path: self.filter_path,
3156            headers: self.headers,
3157            human: self.human,
3158            ignore_unavailable: self.ignore_unavailable,
3159            include_unmapped: self.include_unmapped,
3160            pretty: self.pretty,
3161            request_timeout: self.request_timeout,
3162            source: self.source,
3163        }
3164    }
3165    #[doc = "Include the stack trace of returned errors."]
3166    pub fn error_trace(mut self, error_trace: bool) -> Self {
3167        self.error_trace = Some(error_trace);
3168        self
3169    }
3170    #[doc = "Whether to expand wildcard expression to concrete indices that are open, closed or both."]
3171    pub fn expand_wildcards(mut self, expand_wildcards: &'b [ExpandWildcards]) -> Self {
3172        self.expand_wildcards = Some(expand_wildcards);
3173        self
3174    }
3175    #[doc = "A comma-separated list of field names"]
3176    pub fn fields(mut self, fields: &'b [&'b str]) -> Self {
3177        self.fields = Some(fields);
3178        self
3179    }
3180    #[doc = "A comma-separated list of filters used to reduce the response."]
3181    pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
3182        self.filter_path = Some(filter_path);
3183        self
3184    }
3185    #[doc = "Adds a HTTP header"]
3186    pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
3187        self.headers.insert(key, value);
3188        self
3189    }
3190    #[doc = "Return human readable values for statistics."]
3191    pub fn human(mut self, human: bool) -> Self {
3192        self.human = Some(human);
3193        self
3194    }
3195    #[doc = "Whether specified concrete indices should be ignored when unavailable (missing or closed)"]
3196    pub fn ignore_unavailable(mut self, ignore_unavailable: bool) -> Self {
3197        self.ignore_unavailable = Some(ignore_unavailable);
3198        self
3199    }
3200    #[doc = "Indicates whether unmapped fields should be included in the response."]
3201    pub fn include_unmapped(mut self, include_unmapped: bool) -> Self {
3202        self.include_unmapped = Some(include_unmapped);
3203        self
3204    }
3205    #[doc = "Pretty format the returned JSON response."]
3206    pub fn pretty(mut self, pretty: bool) -> Self {
3207        self.pretty = Some(pretty);
3208        self
3209    }
3210    #[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."]
3211    pub fn request_timeout(mut self, timeout: Duration) -> Self {
3212        self.request_timeout = Some(timeout);
3213        self
3214    }
3215    #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
3216    pub fn source(mut self, source: &'b str) -> Self {
3217        self.source = Some(source);
3218        self
3219    }
3220    #[doc = "Creates an asynchronous call to the Field Caps API that can be awaited"]
3221    pub async fn send(self) -> Result<Response, Error> {
3222        let path = self.parts.url();
3223        let method = match self.body {
3224            Some(_) => Method::Post,
3225            None => Method::Get,
3226        };
3227        let headers = self.headers;
3228        let timeout = self.request_timeout;
3229        let query_string = {
3230            #[serde_with::skip_serializing_none]
3231            #[derive(Serialize)]
3232            struct QueryParams<'b> {
3233                allow_no_indices: Option<bool>,
3234                error_trace: Option<bool>,
3235                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
3236                expand_wildcards: Option<&'b [ExpandWildcards]>,
3237                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
3238                fields: Option<&'b [&'b str]>,
3239                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
3240                filter_path: Option<&'b [&'b str]>,
3241                human: Option<bool>,
3242                ignore_unavailable: Option<bool>,
3243                include_unmapped: Option<bool>,
3244                pretty: Option<bool>,
3245                source: Option<&'b str>,
3246            }
3247            let query_params = QueryParams {
3248                allow_no_indices: self.allow_no_indices,
3249                error_trace: self.error_trace,
3250                expand_wildcards: self.expand_wildcards,
3251                fields: self.fields,
3252                filter_path: self.filter_path,
3253                human: self.human,
3254                ignore_unavailable: self.ignore_unavailable,
3255                include_unmapped: self.include_unmapped,
3256                pretty: self.pretty,
3257                source: self.source,
3258            };
3259            Some(query_params)
3260        };
3261        let body = self.body;
3262        let response = self
3263            .transport
3264            .send(method, &path, headers, query_string.as_ref(), body, timeout)
3265            .await?;
3266        Ok(response)
3267    }
3268}
3269#[derive(Debug, Clone, PartialEq, Eq)]
3270#[doc = "API parts for the Get API"]
3271pub enum GetParts<'b> {
3272    #[doc = "Index and Id"]
3273    IndexId(&'b str, &'b str),
3274}
3275impl<'b> GetParts<'b> {
3276    #[doc = "Builds a relative URL path to the Get API"]
3277    pub fn url(self) -> Cow<'static, str> {
3278        match self {
3279            GetParts::IndexId(index, id) => {
3280                let encoded_index: Cow<str> =
3281                    percent_encode(index.as_bytes(), PARTS_ENCODED).into();
3282                let encoded_id: Cow<str> = percent_encode(id.as_bytes(), PARTS_ENCODED).into();
3283                let mut p = String::with_capacity(7usize + encoded_index.len() + encoded_id.len());
3284                p.push('/');
3285                p.push_str(encoded_index.as_ref());
3286                p.push_str("/_doc/");
3287                p.push_str(encoded_id.as_ref());
3288                p.into()
3289            }
3290        }
3291    }
3292}
3293#[doc = "Builder for the [Get API](https://opensearch.org/docs/)\n\nReturns a document."]
3294#[derive(Clone, Debug)]
3295pub struct Get<'a, 'b> {
3296    transport: &'a Transport,
3297    parts: GetParts<'b>,
3298    _source: Option<&'b [&'b str]>,
3299    _source_excludes: Option<&'b [&'b str]>,
3300    _source_includes: Option<&'b [&'b str]>,
3301    error_trace: Option<bool>,
3302    filter_path: Option<&'b [&'b str]>,
3303    headers: HeaderMap,
3304    human: Option<bool>,
3305    preference: Option<&'b str>,
3306    pretty: Option<bool>,
3307    realtime: Option<bool>,
3308    refresh: Option<bool>,
3309    request_timeout: Option<Duration>,
3310    routing: Option<&'b str>,
3311    source: Option<&'b str>,
3312    stored_fields: Option<&'b [&'b str]>,
3313    version: Option<i64>,
3314    version_type: Option<VersionType>,
3315}
3316impl<'a, 'b> Get<'a, 'b> {
3317    #[doc = "Creates a new instance of [Get] with the specified API parts"]
3318    pub fn new(transport: &'a Transport, parts: GetParts<'b>) -> Self {
3319        let headers = HeaderMap::new();
3320        Get {
3321            transport,
3322            parts,
3323            headers,
3324            _source: None,
3325            _source_excludes: None,
3326            _source_includes: None,
3327            error_trace: None,
3328            filter_path: None,
3329            human: None,
3330            preference: None,
3331            pretty: None,
3332            realtime: None,
3333            refresh: None,
3334            request_timeout: None,
3335            routing: None,
3336            source: None,
3337            stored_fields: None,
3338            version: None,
3339            version_type: None,
3340        }
3341    }
3342    #[doc = "True or false to return the _source field or not, or a list of fields to return"]
3343    pub fn _source(mut self, _source: &'b [&'b str]) -> Self {
3344        self._source = Some(_source);
3345        self
3346    }
3347    #[doc = "A list of fields to exclude from the returned _source field"]
3348    pub fn _source_excludes(mut self, _source_excludes: &'b [&'b str]) -> Self {
3349        self._source_excludes = Some(_source_excludes);
3350        self
3351    }
3352    #[doc = "A list of fields to extract and return from the _source field"]
3353    pub fn _source_includes(mut self, _source_includes: &'b [&'b str]) -> Self {
3354        self._source_includes = Some(_source_includes);
3355        self
3356    }
3357    #[doc = "Include the stack trace of returned errors."]
3358    pub fn error_trace(mut self, error_trace: bool) -> Self {
3359        self.error_trace = Some(error_trace);
3360        self
3361    }
3362    #[doc = "A comma-separated list of filters used to reduce the response."]
3363    pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
3364        self.filter_path = Some(filter_path);
3365        self
3366    }
3367    #[doc = "Adds a HTTP header"]
3368    pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
3369        self.headers.insert(key, value);
3370        self
3371    }
3372    #[doc = "Return human readable values for statistics."]
3373    pub fn human(mut self, human: bool) -> Self {
3374        self.human = Some(human);
3375        self
3376    }
3377    #[doc = "Specify the node or shard the operation should be performed on (default: random)"]
3378    pub fn preference(mut self, preference: &'b str) -> Self {
3379        self.preference = Some(preference);
3380        self
3381    }
3382    #[doc = "Pretty format the returned JSON response."]
3383    pub fn pretty(mut self, pretty: bool) -> Self {
3384        self.pretty = Some(pretty);
3385        self
3386    }
3387    #[doc = "Specify whether to perform the operation in realtime or search mode"]
3388    pub fn realtime(mut self, realtime: bool) -> Self {
3389        self.realtime = Some(realtime);
3390        self
3391    }
3392    #[doc = "Refresh the shard containing the document before performing the operation"]
3393    pub fn refresh(mut self, refresh: bool) -> Self {
3394        self.refresh = Some(refresh);
3395        self
3396    }
3397    #[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."]
3398    pub fn request_timeout(mut self, timeout: Duration) -> Self {
3399        self.request_timeout = Some(timeout);
3400        self
3401    }
3402    #[doc = "Specific routing value"]
3403    pub fn routing(mut self, routing: &'b str) -> Self {
3404        self.routing = Some(routing);
3405        self
3406    }
3407    #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
3408    pub fn source(mut self, source: &'b str) -> Self {
3409        self.source = Some(source);
3410        self
3411    }
3412    #[doc = "A comma-separated list of stored fields to return in the response"]
3413    pub fn stored_fields(mut self, stored_fields: &'b [&'b str]) -> Self {
3414        self.stored_fields = Some(stored_fields);
3415        self
3416    }
3417    #[doc = "Explicit version number for concurrency control"]
3418    pub fn version(mut self, version: i64) -> Self {
3419        self.version = Some(version);
3420        self
3421    }
3422    #[doc = "Specific version type"]
3423    pub fn version_type(mut self, version_type: VersionType) -> Self {
3424        self.version_type = Some(version_type);
3425        self
3426    }
3427    #[doc = "Creates an asynchronous call to the Get API that can be awaited"]
3428    pub async fn send(self) -> Result<Response, Error> {
3429        let path = self.parts.url();
3430        let method = Method::Get;
3431        let headers = self.headers;
3432        let timeout = self.request_timeout;
3433        let query_string = {
3434            #[serde_with::skip_serializing_none]
3435            #[derive(Serialize)]
3436            struct QueryParams<'b> {
3437                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
3438                _source: Option<&'b [&'b str]>,
3439                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
3440                _source_excludes: Option<&'b [&'b str]>,
3441                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
3442                _source_includes: Option<&'b [&'b str]>,
3443                error_trace: Option<bool>,
3444                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
3445                filter_path: Option<&'b [&'b str]>,
3446                human: Option<bool>,
3447                preference: Option<&'b str>,
3448                pretty: Option<bool>,
3449                realtime: Option<bool>,
3450                refresh: Option<bool>,
3451                routing: Option<&'b str>,
3452                source: Option<&'b str>,
3453                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
3454                stored_fields: Option<&'b [&'b str]>,
3455                version: Option<i64>,
3456                version_type: Option<VersionType>,
3457            }
3458            let query_params = QueryParams {
3459                _source: self._source,
3460                _source_excludes: self._source_excludes,
3461                _source_includes: self._source_includes,
3462                error_trace: self.error_trace,
3463                filter_path: self.filter_path,
3464                human: self.human,
3465                preference: self.preference,
3466                pretty: self.pretty,
3467                realtime: self.realtime,
3468                refresh: self.refresh,
3469                routing: self.routing,
3470                source: self.source,
3471                stored_fields: self.stored_fields,
3472                version: self.version,
3473                version_type: self.version_type,
3474            };
3475            Some(query_params)
3476        };
3477        let body = Option::<()>::None;
3478        let response = self
3479            .transport
3480            .send(method, &path, headers, query_string.as_ref(), body, timeout)
3481            .await?;
3482        Ok(response)
3483    }
3484}
3485#[derive(Debug, Clone, PartialEq, Eq)]
3486#[doc = "API parts for the Get All Pits API"]
3487pub enum GetAllPitsParts {
3488    #[doc = "No parts"]
3489    None,
3490}
3491impl GetAllPitsParts {
3492    #[doc = "Builds a relative URL path to the Get All Pits API"]
3493    pub fn url(self) -> Cow<'static, str> {
3494        match self {
3495            GetAllPitsParts::None => "/_search/point_in_time/_all".into(),
3496        }
3497    }
3498}
3499#[doc = "Builder for the [Get All Pits API](https://opensearch.org/docs/latest/opensearch/rest-api/point_in_time/)\n\nLists all active point in time searches."]
3500#[derive(Clone, Debug)]
3501pub struct GetAllPits<'a, 'b> {
3502    transport: &'a Transport,
3503    parts: GetAllPitsParts,
3504    error_trace: Option<bool>,
3505    filter_path: Option<&'b [&'b str]>,
3506    headers: HeaderMap,
3507    human: Option<bool>,
3508    pretty: Option<bool>,
3509    request_timeout: Option<Duration>,
3510    source: Option<&'b str>,
3511}
3512impl<'a, 'b> GetAllPits<'a, 'b> {
3513    #[doc = "Creates a new instance of [GetAllPits]"]
3514    pub fn new(transport: &'a Transport) -> Self {
3515        let headers = HeaderMap::new();
3516        GetAllPits {
3517            transport,
3518            parts: GetAllPitsParts::None,
3519            headers,
3520            error_trace: None,
3521            filter_path: None,
3522            human: None,
3523            pretty: None,
3524            request_timeout: None,
3525            source: None,
3526        }
3527    }
3528    #[doc = "Include the stack trace of returned errors."]
3529    pub fn error_trace(mut self, error_trace: bool) -> Self {
3530        self.error_trace = Some(error_trace);
3531        self
3532    }
3533    #[doc = "A comma-separated list of filters used to reduce the response."]
3534    pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
3535        self.filter_path = Some(filter_path);
3536        self
3537    }
3538    #[doc = "Adds a HTTP header"]
3539    pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
3540        self.headers.insert(key, value);
3541        self
3542    }
3543    #[doc = "Return human readable values for statistics."]
3544    pub fn human(mut self, human: bool) -> Self {
3545        self.human = Some(human);
3546        self
3547    }
3548    #[doc = "Pretty format the returned JSON response."]
3549    pub fn pretty(mut self, pretty: bool) -> Self {
3550        self.pretty = Some(pretty);
3551        self
3552    }
3553    #[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."]
3554    pub fn request_timeout(mut self, timeout: Duration) -> Self {
3555        self.request_timeout = Some(timeout);
3556        self
3557    }
3558    #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
3559    pub fn source(mut self, source: &'b str) -> Self {
3560        self.source = Some(source);
3561        self
3562    }
3563    #[doc = "Creates an asynchronous call to the Get All Pits API that can be awaited"]
3564    pub async fn send(self) -> Result<Response, Error> {
3565        let path = self.parts.url();
3566        let method = Method::Get;
3567        let headers = self.headers;
3568        let timeout = self.request_timeout;
3569        let query_string = {
3570            #[serde_with::skip_serializing_none]
3571            #[derive(Serialize)]
3572            struct QueryParams<'b> {
3573                error_trace: Option<bool>,
3574                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
3575                filter_path: Option<&'b [&'b str]>,
3576                human: Option<bool>,
3577                pretty: Option<bool>,
3578                source: Option<&'b str>,
3579            }
3580            let query_params = QueryParams {
3581                error_trace: self.error_trace,
3582                filter_path: self.filter_path,
3583                human: self.human,
3584                pretty: self.pretty,
3585                source: self.source,
3586            };
3587            Some(query_params)
3588        };
3589        let body = Option::<()>::None;
3590        let response = self
3591            .transport
3592            .send(method, &path, headers, query_string.as_ref(), body, timeout)
3593            .await?;
3594        Ok(response)
3595    }
3596}
3597#[derive(Debug, Clone, PartialEq, Eq)]
3598#[doc = "API parts for the Get Script API"]
3599pub enum GetScriptParts<'b> {
3600    #[doc = "Id"]
3601    Id(&'b str),
3602}
3603impl<'b> GetScriptParts<'b> {
3604    #[doc = "Builds a relative URL path to the Get Script API"]
3605    pub fn url(self) -> Cow<'static, str> {
3606        match self {
3607            GetScriptParts::Id(id) => {
3608                let encoded_id: Cow<str> = percent_encode(id.as_bytes(), PARTS_ENCODED).into();
3609                let mut p = String::with_capacity(10usize + encoded_id.len());
3610                p.push_str("/_scripts/");
3611                p.push_str(encoded_id.as_ref());
3612                p.into()
3613            }
3614        }
3615    }
3616}
3617#[doc = "Builder for the [Get Script API](https://opensearch.org/docs/)\n\nReturns a script."]
3618#[derive(Clone, Debug)]
3619pub struct GetScript<'a, 'b> {
3620    transport: &'a Transport,
3621    parts: GetScriptParts<'b>,
3622    cluster_manager_timeout: Option<&'b str>,
3623    error_trace: Option<bool>,
3624    filter_path: Option<&'b [&'b str]>,
3625    headers: HeaderMap,
3626    human: Option<bool>,
3627    master_timeout: Option<&'b str>,
3628    pretty: Option<bool>,
3629    request_timeout: Option<Duration>,
3630    source: Option<&'b str>,
3631}
3632impl<'a, 'b> GetScript<'a, 'b> {
3633    #[doc = "Creates a new instance of [GetScript] with the specified API parts"]
3634    pub fn new(transport: &'a Transport, parts: GetScriptParts<'b>) -> Self {
3635        let headers = HeaderMap::new();
3636        GetScript {
3637            transport,
3638            parts,
3639            headers,
3640            cluster_manager_timeout: None,
3641            error_trace: None,
3642            filter_path: None,
3643            human: None,
3644            master_timeout: None,
3645            pretty: None,
3646            request_timeout: None,
3647            source: None,
3648        }
3649    }
3650    #[doc = "Specify timeout for connection to cluster-manager node"]
3651    pub fn cluster_manager_timeout(mut self, cluster_manager_timeout: &'b str) -> Self {
3652        self.cluster_manager_timeout = Some(cluster_manager_timeout);
3653        self
3654    }
3655    #[doc = "Include the stack trace of returned errors."]
3656    pub fn error_trace(mut self, error_trace: bool) -> Self {
3657        self.error_trace = Some(error_trace);
3658        self
3659    }
3660    #[doc = "A comma-separated list of filters used to reduce the response."]
3661    pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
3662        self.filter_path = Some(filter_path);
3663        self
3664    }
3665    #[doc = "Adds a HTTP header"]
3666    pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
3667        self.headers.insert(key, value);
3668        self
3669    }
3670    #[doc = "Return human readable values for statistics."]
3671    pub fn human(mut self, human: bool) -> Self {
3672        self.human = Some(human);
3673        self
3674    }
3675    #[doc = "Specify timeout for connection to cluster-manager node"]
3676    #[deprecated = "To support inclusive language, use 'cluster_manager_timeout' instead."]
3677    pub fn master_timeout(mut self, master_timeout: &'b str) -> Self {
3678        self.master_timeout = Some(master_timeout);
3679        self
3680    }
3681    #[doc = "Pretty format the returned JSON response."]
3682    pub fn pretty(mut self, pretty: bool) -> Self {
3683        self.pretty = Some(pretty);
3684        self
3685    }
3686    #[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."]
3687    pub fn request_timeout(mut self, timeout: Duration) -> Self {
3688        self.request_timeout = Some(timeout);
3689        self
3690    }
3691    #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
3692    pub fn source(mut self, source: &'b str) -> Self {
3693        self.source = Some(source);
3694        self
3695    }
3696    #[doc = "Creates an asynchronous call to the Get Script API that can be awaited"]
3697    pub async fn send(self) -> Result<Response, Error> {
3698        let path = self.parts.url();
3699        let method = Method::Get;
3700        let headers = self.headers;
3701        let timeout = self.request_timeout;
3702        let query_string = {
3703            #[serde_with::skip_serializing_none]
3704            #[derive(Serialize)]
3705            struct QueryParams<'b> {
3706                cluster_manager_timeout: Option<&'b str>,
3707                error_trace: Option<bool>,
3708                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
3709                filter_path: Option<&'b [&'b str]>,
3710                human: Option<bool>,
3711                master_timeout: Option<&'b str>,
3712                pretty: Option<bool>,
3713                source: Option<&'b str>,
3714            }
3715            let query_params = QueryParams {
3716                cluster_manager_timeout: self.cluster_manager_timeout,
3717                error_trace: self.error_trace,
3718                filter_path: self.filter_path,
3719                human: self.human,
3720                master_timeout: self.master_timeout,
3721                pretty: self.pretty,
3722                source: self.source,
3723            };
3724            Some(query_params)
3725        };
3726        let body = Option::<()>::None;
3727        let response = self
3728            .transport
3729            .send(method, &path, headers, query_string.as_ref(), body, timeout)
3730            .await?;
3731        Ok(response)
3732    }
3733}
3734#[cfg(feature = "experimental-apis")]
3735#[derive(Debug, Clone, PartialEq, Eq)]
3736#[doc = "API parts for the Get Script Context API"]
3737pub enum GetScriptContextParts {
3738    #[doc = "No parts"]
3739    None,
3740}
3741#[cfg(feature = "experimental-apis")]
3742impl GetScriptContextParts {
3743    #[doc = "Builds a relative URL path to the Get Script Context API"]
3744    pub fn url(self) -> Cow<'static, str> {
3745        match self {
3746            GetScriptContextParts::None => "/_script_context".into(),
3747        }
3748    }
3749}
3750#[doc = "Builder for the [Get Script Context API](https://opensearch.org/docs/)\n\nReturns all script contexts."]
3751#[doc = "&nbsp;\n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n        "]
3752#[cfg(feature = "experimental-apis")]
3753#[derive(Clone, Debug)]
3754pub struct GetScriptContext<'a, 'b> {
3755    transport: &'a Transport,
3756    parts: GetScriptContextParts,
3757    error_trace: Option<bool>,
3758    filter_path: Option<&'b [&'b str]>,
3759    headers: HeaderMap,
3760    human: Option<bool>,
3761    pretty: Option<bool>,
3762    request_timeout: Option<Duration>,
3763    source: Option<&'b str>,
3764}
3765#[cfg(feature = "experimental-apis")]
3766impl<'a, 'b> GetScriptContext<'a, 'b> {
3767    #[doc = "Creates a new instance of [GetScriptContext]"]
3768    pub fn new(transport: &'a Transport) -> Self {
3769        let headers = HeaderMap::new();
3770        GetScriptContext {
3771            transport,
3772            parts: GetScriptContextParts::None,
3773            headers,
3774            error_trace: None,
3775            filter_path: None,
3776            human: None,
3777            pretty: None,
3778            request_timeout: None,
3779            source: None,
3780        }
3781    }
3782    #[doc = "Include the stack trace of returned errors."]
3783    pub fn error_trace(mut self, error_trace: bool) -> Self {
3784        self.error_trace = Some(error_trace);
3785        self
3786    }
3787    #[doc = "A comma-separated list of filters used to reduce the response."]
3788    pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
3789        self.filter_path = Some(filter_path);
3790        self
3791    }
3792    #[doc = "Adds a HTTP header"]
3793    pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
3794        self.headers.insert(key, value);
3795        self
3796    }
3797    #[doc = "Return human readable values for statistics."]
3798    pub fn human(mut self, human: bool) -> Self {
3799        self.human = Some(human);
3800        self
3801    }
3802    #[doc = "Pretty format the returned JSON response."]
3803    pub fn pretty(mut self, pretty: bool) -> Self {
3804        self.pretty = Some(pretty);
3805        self
3806    }
3807    #[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."]
3808    pub fn request_timeout(mut self, timeout: Duration) -> Self {
3809        self.request_timeout = Some(timeout);
3810        self
3811    }
3812    #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
3813    pub fn source(mut self, source: &'b str) -> Self {
3814        self.source = Some(source);
3815        self
3816    }
3817    #[doc = "Creates an asynchronous call to the Get Script Context API that can be awaited"]
3818    pub async fn send(self) -> Result<Response, Error> {
3819        let path = self.parts.url();
3820        let method = Method::Get;
3821        let headers = self.headers;
3822        let timeout = self.request_timeout;
3823        let query_string = {
3824            #[serde_with::skip_serializing_none]
3825            #[derive(Serialize)]
3826            struct QueryParams<'b> {
3827                error_trace: Option<bool>,
3828                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
3829                filter_path: Option<&'b [&'b str]>,
3830                human: Option<bool>,
3831                pretty: Option<bool>,
3832                source: Option<&'b str>,
3833            }
3834            let query_params = QueryParams {
3835                error_trace: self.error_trace,
3836                filter_path: self.filter_path,
3837                human: self.human,
3838                pretty: self.pretty,
3839                source: self.source,
3840            };
3841            Some(query_params)
3842        };
3843        let body = Option::<()>::None;
3844        let response = self
3845            .transport
3846            .send(method, &path, headers, query_string.as_ref(), body, timeout)
3847            .await?;
3848        Ok(response)
3849    }
3850}
3851#[cfg(feature = "experimental-apis")]
3852#[derive(Debug, Clone, PartialEq, Eq)]
3853#[doc = "API parts for the Get Script Languages API"]
3854pub enum GetScriptLanguagesParts {
3855    #[doc = "No parts"]
3856    None,
3857}
3858#[cfg(feature = "experimental-apis")]
3859impl GetScriptLanguagesParts {
3860    #[doc = "Builds a relative URL path to the Get Script Languages API"]
3861    pub fn url(self) -> Cow<'static, str> {
3862        match self {
3863            GetScriptLanguagesParts::None => "/_script_language".into(),
3864        }
3865    }
3866}
3867#[doc = "Builder for the [Get Script Languages API](https://opensearch.org/docs/)\n\nReturns available script types, languages and contexts"]
3868#[doc = "&nbsp;\n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n        "]
3869#[cfg(feature = "experimental-apis")]
3870#[derive(Clone, Debug)]
3871pub struct GetScriptLanguages<'a, 'b> {
3872    transport: &'a Transport,
3873    parts: GetScriptLanguagesParts,
3874    error_trace: Option<bool>,
3875    filter_path: Option<&'b [&'b str]>,
3876    headers: HeaderMap,
3877    human: Option<bool>,
3878    pretty: Option<bool>,
3879    request_timeout: Option<Duration>,
3880    source: Option<&'b str>,
3881}
3882#[cfg(feature = "experimental-apis")]
3883impl<'a, 'b> GetScriptLanguages<'a, 'b> {
3884    #[doc = "Creates a new instance of [GetScriptLanguages]"]
3885    pub fn new(transport: &'a Transport) -> Self {
3886        let headers = HeaderMap::new();
3887        GetScriptLanguages {
3888            transport,
3889            parts: GetScriptLanguagesParts::None,
3890            headers,
3891            error_trace: None,
3892            filter_path: None,
3893            human: None,
3894            pretty: None,
3895            request_timeout: None,
3896            source: None,
3897        }
3898    }
3899    #[doc = "Include the stack trace of returned errors."]
3900    pub fn error_trace(mut self, error_trace: bool) -> Self {
3901        self.error_trace = Some(error_trace);
3902        self
3903    }
3904    #[doc = "A comma-separated list of filters used to reduce the response."]
3905    pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
3906        self.filter_path = Some(filter_path);
3907        self
3908    }
3909    #[doc = "Adds a HTTP header"]
3910    pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
3911        self.headers.insert(key, value);
3912        self
3913    }
3914    #[doc = "Return human readable values for statistics."]
3915    pub fn human(mut self, human: bool) -> Self {
3916        self.human = Some(human);
3917        self
3918    }
3919    #[doc = "Pretty format the returned JSON response."]
3920    pub fn pretty(mut self, pretty: bool) -> Self {
3921        self.pretty = Some(pretty);
3922        self
3923    }
3924    #[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."]
3925    pub fn request_timeout(mut self, timeout: Duration) -> Self {
3926        self.request_timeout = Some(timeout);
3927        self
3928    }
3929    #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
3930    pub fn source(mut self, source: &'b str) -> Self {
3931        self.source = Some(source);
3932        self
3933    }
3934    #[doc = "Creates an asynchronous call to the Get Script Languages API that can be awaited"]
3935    pub async fn send(self) -> Result<Response, Error> {
3936        let path = self.parts.url();
3937        let method = Method::Get;
3938        let headers = self.headers;
3939        let timeout = self.request_timeout;
3940        let query_string = {
3941            #[serde_with::skip_serializing_none]
3942            #[derive(Serialize)]
3943            struct QueryParams<'b> {
3944                error_trace: Option<bool>,
3945                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
3946                filter_path: Option<&'b [&'b str]>,
3947                human: Option<bool>,
3948                pretty: Option<bool>,
3949                source: Option<&'b str>,
3950            }
3951            let query_params = QueryParams {
3952                error_trace: self.error_trace,
3953                filter_path: self.filter_path,
3954                human: self.human,
3955                pretty: self.pretty,
3956                source: self.source,
3957            };
3958            Some(query_params)
3959        };
3960        let body = Option::<()>::None;
3961        let response = self
3962            .transport
3963            .send(method, &path, headers, query_string.as_ref(), body, timeout)
3964            .await?;
3965        Ok(response)
3966    }
3967}
3968#[derive(Debug, Clone, PartialEq, Eq)]
3969#[doc = "API parts for the Get Source API"]
3970pub enum GetSourceParts<'b> {
3971    #[doc = "Index and Id"]
3972    IndexId(&'b str, &'b str),
3973}
3974impl<'b> GetSourceParts<'b> {
3975    #[doc = "Builds a relative URL path to the Get Source API"]
3976    pub fn url(self) -> Cow<'static, str> {
3977        match self {
3978            GetSourceParts::IndexId(index, id) => {
3979                let encoded_index: Cow<str> =
3980                    percent_encode(index.as_bytes(), PARTS_ENCODED).into();
3981                let encoded_id: Cow<str> = percent_encode(id.as_bytes(), PARTS_ENCODED).into();
3982                let mut p = String::with_capacity(10usize + encoded_index.len() + encoded_id.len());
3983                p.push('/');
3984                p.push_str(encoded_index.as_ref());
3985                p.push_str("/_source/");
3986                p.push_str(encoded_id.as_ref());
3987                p.into()
3988            }
3989        }
3990    }
3991}
3992#[doc = "Builder for the [Get Source API](https://opensearch.org/docs/)\n\nReturns the source of a document."]
3993#[derive(Clone, Debug)]
3994pub struct GetSource<'a, 'b> {
3995    transport: &'a Transport,
3996    parts: GetSourceParts<'b>,
3997    _source: Option<&'b [&'b str]>,
3998    _source_excludes: Option<&'b [&'b str]>,
3999    _source_includes: Option<&'b [&'b str]>,
4000    error_trace: Option<bool>,
4001    filter_path: Option<&'b [&'b str]>,
4002    headers: HeaderMap,
4003    human: Option<bool>,
4004    preference: Option<&'b str>,
4005    pretty: Option<bool>,
4006    realtime: Option<bool>,
4007    refresh: Option<bool>,
4008    request_timeout: Option<Duration>,
4009    routing: Option<&'b str>,
4010    source: Option<&'b str>,
4011    version: Option<i64>,
4012    version_type: Option<VersionType>,
4013}
4014impl<'a, 'b> GetSource<'a, 'b> {
4015    #[doc = "Creates a new instance of [GetSource] with the specified API parts"]
4016    pub fn new(transport: &'a Transport, parts: GetSourceParts<'b>) -> Self {
4017        let headers = HeaderMap::new();
4018        GetSource {
4019            transport,
4020            parts,
4021            headers,
4022            _source: None,
4023            _source_excludes: None,
4024            _source_includes: None,
4025            error_trace: None,
4026            filter_path: None,
4027            human: None,
4028            preference: None,
4029            pretty: None,
4030            realtime: None,
4031            refresh: None,
4032            request_timeout: None,
4033            routing: None,
4034            source: None,
4035            version: None,
4036            version_type: None,
4037        }
4038    }
4039    #[doc = "True or false to return the _source field or not, or a list of fields to return"]
4040    pub fn _source(mut self, _source: &'b [&'b str]) -> Self {
4041        self._source = Some(_source);
4042        self
4043    }
4044    #[doc = "A list of fields to exclude from the returned _source field"]
4045    pub fn _source_excludes(mut self, _source_excludes: &'b [&'b str]) -> Self {
4046        self._source_excludes = Some(_source_excludes);
4047        self
4048    }
4049    #[doc = "A list of fields to extract and return from the _source field"]
4050    pub fn _source_includes(mut self, _source_includes: &'b [&'b str]) -> Self {
4051        self._source_includes = Some(_source_includes);
4052        self
4053    }
4054    #[doc = "Include the stack trace of returned errors."]
4055    pub fn error_trace(mut self, error_trace: bool) -> Self {
4056        self.error_trace = Some(error_trace);
4057        self
4058    }
4059    #[doc = "A comma-separated list of filters used to reduce the response."]
4060    pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
4061        self.filter_path = Some(filter_path);
4062        self
4063    }
4064    #[doc = "Adds a HTTP header"]
4065    pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
4066        self.headers.insert(key, value);
4067        self
4068    }
4069    #[doc = "Return human readable values for statistics."]
4070    pub fn human(mut self, human: bool) -> Self {
4071        self.human = Some(human);
4072        self
4073    }
4074    #[doc = "Specify the node or shard the operation should be performed on (default: random)"]
4075    pub fn preference(mut self, preference: &'b str) -> Self {
4076        self.preference = Some(preference);
4077        self
4078    }
4079    #[doc = "Pretty format the returned JSON response."]
4080    pub fn pretty(mut self, pretty: bool) -> Self {
4081        self.pretty = Some(pretty);
4082        self
4083    }
4084    #[doc = "Specify whether to perform the operation in realtime or search mode"]
4085    pub fn realtime(mut self, realtime: bool) -> Self {
4086        self.realtime = Some(realtime);
4087        self
4088    }
4089    #[doc = "Refresh the shard containing the document before performing the operation"]
4090    pub fn refresh(mut self, refresh: bool) -> Self {
4091        self.refresh = Some(refresh);
4092        self
4093    }
4094    #[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."]
4095    pub fn request_timeout(mut self, timeout: Duration) -> Self {
4096        self.request_timeout = Some(timeout);
4097        self
4098    }
4099    #[doc = "Specific routing value"]
4100    pub fn routing(mut self, routing: &'b str) -> Self {
4101        self.routing = Some(routing);
4102        self
4103    }
4104    #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
4105    pub fn source(mut self, source: &'b str) -> Self {
4106        self.source = Some(source);
4107        self
4108    }
4109    #[doc = "Explicit version number for concurrency control"]
4110    pub fn version(mut self, version: i64) -> Self {
4111        self.version = Some(version);
4112        self
4113    }
4114    #[doc = "Specific version type"]
4115    pub fn version_type(mut self, version_type: VersionType) -> Self {
4116        self.version_type = Some(version_type);
4117        self
4118    }
4119    #[doc = "Creates an asynchronous call to the Get Source API that can be awaited"]
4120    pub async fn send(self) -> Result<Response, Error> {
4121        let path = self.parts.url();
4122        let method = Method::Get;
4123        let headers = self.headers;
4124        let timeout = self.request_timeout;
4125        let query_string = {
4126            #[serde_with::skip_serializing_none]
4127            #[derive(Serialize)]
4128            struct QueryParams<'b> {
4129                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
4130                _source: Option<&'b [&'b str]>,
4131                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
4132                _source_excludes: Option<&'b [&'b str]>,
4133                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
4134                _source_includes: Option<&'b [&'b str]>,
4135                error_trace: Option<bool>,
4136                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
4137                filter_path: Option<&'b [&'b str]>,
4138                human: Option<bool>,
4139                preference: Option<&'b str>,
4140                pretty: Option<bool>,
4141                realtime: Option<bool>,
4142                refresh: Option<bool>,
4143                routing: Option<&'b str>,
4144                source: Option<&'b str>,
4145                version: Option<i64>,
4146                version_type: Option<VersionType>,
4147            }
4148            let query_params = QueryParams {
4149                _source: self._source,
4150                _source_excludes: self._source_excludes,
4151                _source_includes: self._source_includes,
4152                error_trace: self.error_trace,
4153                filter_path: self.filter_path,
4154                human: self.human,
4155                preference: self.preference,
4156                pretty: self.pretty,
4157                realtime: self.realtime,
4158                refresh: self.refresh,
4159                routing: self.routing,
4160                source: self.source,
4161                version: self.version,
4162                version_type: self.version_type,
4163            };
4164            Some(query_params)
4165        };
4166        let body = Option::<()>::None;
4167        let response = self
4168            .transport
4169            .send(method, &path, headers, query_string.as_ref(), body, timeout)
4170            .await?;
4171        Ok(response)
4172    }
4173}
4174#[derive(Debug, Clone, PartialEq, Eq)]
4175#[doc = "API parts for the Index API"]
4176pub enum IndexParts<'b> {
4177    #[doc = "Index and Id"]
4178    IndexId(&'b str, &'b str),
4179    #[doc = "Index"]
4180    Index(&'b str),
4181}
4182impl<'b> IndexParts<'b> {
4183    #[doc = "Builds a relative URL path to the Index API"]
4184    pub fn url(self) -> Cow<'static, str> {
4185        match self {
4186            IndexParts::IndexId(index, id) => {
4187                let encoded_index: Cow<str> =
4188                    percent_encode(index.as_bytes(), PARTS_ENCODED).into();
4189                let encoded_id: Cow<str> = percent_encode(id.as_bytes(), PARTS_ENCODED).into();
4190                let mut p = String::with_capacity(7usize + encoded_index.len() + encoded_id.len());
4191                p.push('/');
4192                p.push_str(encoded_index.as_ref());
4193                p.push_str("/_doc/");
4194                p.push_str(encoded_id.as_ref());
4195                p.into()
4196            }
4197            IndexParts::Index(index) => {
4198                let encoded_index: Cow<str> =
4199                    percent_encode(index.as_bytes(), PARTS_ENCODED).into();
4200                let mut p = String::with_capacity(6usize + encoded_index.len());
4201                p.push('/');
4202                p.push_str(encoded_index.as_ref());
4203                p.push_str("/_doc");
4204                p.into()
4205            }
4206        }
4207    }
4208}
4209#[doc = "Builder for the [Index API](https://opensearch.org/docs/)\n\nCreates or updates a document in an index."]
4210#[derive(Clone, Debug)]
4211pub struct Index<'a, 'b, B> {
4212    transport: &'a Transport,
4213    parts: IndexParts<'b>,
4214    body: Option<B>,
4215    error_trace: Option<bool>,
4216    filter_path: Option<&'b [&'b str]>,
4217    headers: HeaderMap,
4218    human: Option<bool>,
4219    if_primary_term: Option<i64>,
4220    if_seq_no: Option<i64>,
4221    op_type: Option<OpType>,
4222    pipeline: Option<&'b str>,
4223    pretty: Option<bool>,
4224    refresh: Option<Refresh>,
4225    request_timeout: Option<Duration>,
4226    require_alias: Option<bool>,
4227    routing: Option<&'b str>,
4228    source: Option<&'b str>,
4229    timeout: Option<&'b str>,
4230    version: Option<i64>,
4231    version_type: Option<VersionType>,
4232    wait_for_active_shards: Option<&'b str>,
4233}
4234impl<'a, 'b, B> Index<'a, 'b, B>
4235where
4236    B: Body,
4237{
4238    #[doc = "Creates a new instance of [Index] with the specified API parts"]
4239    pub fn new(transport: &'a Transport, parts: IndexParts<'b>) -> Self {
4240        let headers = HeaderMap::new();
4241        Index {
4242            transport,
4243            parts,
4244            headers,
4245            body: None,
4246            error_trace: None,
4247            filter_path: None,
4248            human: None,
4249            if_primary_term: None,
4250            if_seq_no: None,
4251            op_type: None,
4252            pipeline: None,
4253            pretty: None,
4254            refresh: None,
4255            request_timeout: None,
4256            require_alias: None,
4257            routing: None,
4258            source: None,
4259            timeout: None,
4260            version: None,
4261            version_type: None,
4262            wait_for_active_shards: None,
4263        }
4264    }
4265    #[doc = "The body for the API call"]
4266    pub fn body<T>(self, body: T) -> Index<'a, 'b, JsonBody<T>>
4267    where
4268        T: Serialize,
4269    {
4270        Index {
4271            transport: self.transport,
4272            parts: self.parts,
4273            body: Some(body.into()),
4274            error_trace: self.error_trace,
4275            filter_path: self.filter_path,
4276            headers: self.headers,
4277            human: self.human,
4278            if_primary_term: self.if_primary_term,
4279            if_seq_no: self.if_seq_no,
4280            op_type: self.op_type,
4281            pipeline: self.pipeline,
4282            pretty: self.pretty,
4283            refresh: self.refresh,
4284            request_timeout: self.request_timeout,
4285            require_alias: self.require_alias,
4286            routing: self.routing,
4287            source: self.source,
4288            timeout: self.timeout,
4289            version: self.version,
4290            version_type: self.version_type,
4291            wait_for_active_shards: self.wait_for_active_shards,
4292        }
4293    }
4294    #[doc = "Include the stack trace of returned errors."]
4295    pub fn error_trace(mut self, error_trace: bool) -> Self {
4296        self.error_trace = Some(error_trace);
4297        self
4298    }
4299    #[doc = "A comma-separated list of filters used to reduce the response."]
4300    pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
4301        self.filter_path = Some(filter_path);
4302        self
4303    }
4304    #[doc = "Adds a HTTP header"]
4305    pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
4306        self.headers.insert(key, value);
4307        self
4308    }
4309    #[doc = "Return human readable values for statistics."]
4310    pub fn human(mut self, human: bool) -> Self {
4311        self.human = Some(human);
4312        self
4313    }
4314    #[doc = "only perform the index operation if the last operation that has changed the document has the specified primary term"]
4315    pub fn if_primary_term(mut self, if_primary_term: i64) -> Self {
4316        self.if_primary_term = Some(if_primary_term);
4317        self
4318    }
4319    #[doc = "only perform the index operation if the last operation that has changed the document has the specified sequence number"]
4320    pub fn if_seq_no(mut self, if_seq_no: i64) -> Self {
4321        self.if_seq_no = Some(if_seq_no);
4322        self
4323    }
4324    #[doc = "Explicit operation type. Defaults to `index` for requests with an explicit document ID, and to `create`for requests without an explicit document ID"]
4325    pub fn op_type(mut self, op_type: OpType) -> Self {
4326        self.op_type = Some(op_type);
4327        self
4328    }
4329    #[doc = "The pipeline id to preprocess incoming documents with"]
4330    pub fn pipeline(mut self, pipeline: &'b str) -> Self {
4331        self.pipeline = Some(pipeline);
4332        self
4333    }
4334    #[doc = "Pretty format the returned JSON response."]
4335    pub fn pretty(mut self, pretty: bool) -> Self {
4336        self.pretty = Some(pretty);
4337        self
4338    }
4339    #[doc = "If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes."]
4340    pub fn refresh(mut self, refresh: Refresh) -> Self {
4341        self.refresh = Some(refresh);
4342        self
4343    }
4344    #[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."]
4345    pub fn request_timeout(mut self, timeout: Duration) -> Self {
4346        self.request_timeout = Some(timeout);
4347        self
4348    }
4349    #[doc = "When true, requires destination to be an alias. Default is false"]
4350    pub fn require_alias(mut self, require_alias: bool) -> Self {
4351        self.require_alias = Some(require_alias);
4352        self
4353    }
4354    #[doc = "Specific routing value"]
4355    pub fn routing(mut self, routing: &'b str) -> Self {
4356        self.routing = Some(routing);
4357        self
4358    }
4359    #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
4360    pub fn source(mut self, source: &'b str) -> Self {
4361        self.source = Some(source);
4362        self
4363    }
4364    #[doc = "Explicit operation timeout"]
4365    pub fn timeout(mut self, timeout: &'b str) -> Self {
4366        self.timeout = Some(timeout);
4367        self
4368    }
4369    #[doc = "Explicit version number for concurrency control"]
4370    pub fn version(mut self, version: i64) -> Self {
4371        self.version = Some(version);
4372        self
4373    }
4374    #[doc = "Specific version type"]
4375    pub fn version_type(mut self, version_type: VersionType) -> Self {
4376        self.version_type = Some(version_type);
4377        self
4378    }
4379    #[doc = "Sets the number of shard copies that must be active before proceeding with the index operation. Defaults to 1, meaning the primary shard only. 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)"]
4380    pub fn wait_for_active_shards(mut self, wait_for_active_shards: &'b str) -> Self {
4381        self.wait_for_active_shards = Some(wait_for_active_shards);
4382        self
4383    }
4384    #[doc = "Creates an asynchronous call to the Index API that can be awaited"]
4385    pub async fn send(self) -> Result<Response, Error> {
4386        let path = self.parts.url();
4387        let method = Method::Post;
4388        let headers = self.headers;
4389        let timeout = self.request_timeout;
4390        let query_string = {
4391            #[serde_with::skip_serializing_none]
4392            #[derive(Serialize)]
4393            struct QueryParams<'b> {
4394                error_trace: Option<bool>,
4395                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
4396                filter_path: Option<&'b [&'b str]>,
4397                human: Option<bool>,
4398                if_primary_term: Option<i64>,
4399                if_seq_no: Option<i64>,
4400                op_type: Option<OpType>,
4401                pipeline: Option<&'b str>,
4402                pretty: Option<bool>,
4403                refresh: Option<Refresh>,
4404                require_alias: Option<bool>,
4405                routing: Option<&'b str>,
4406                source: Option<&'b str>,
4407                timeout: Option<&'b str>,
4408                version: Option<i64>,
4409                version_type: Option<VersionType>,
4410                wait_for_active_shards: Option<&'b str>,
4411            }
4412            let query_params = QueryParams {
4413                error_trace: self.error_trace,
4414                filter_path: self.filter_path,
4415                human: self.human,
4416                if_primary_term: self.if_primary_term,
4417                if_seq_no: self.if_seq_no,
4418                op_type: self.op_type,
4419                pipeline: self.pipeline,
4420                pretty: self.pretty,
4421                refresh: self.refresh,
4422                require_alias: self.require_alias,
4423                routing: self.routing,
4424                source: self.source,
4425                timeout: self.timeout,
4426                version: self.version,
4427                version_type: self.version_type,
4428                wait_for_active_shards: self.wait_for_active_shards,
4429            };
4430            Some(query_params)
4431        };
4432        let body = self.body;
4433        let response = self
4434            .transport
4435            .send(method, &path, headers, query_string.as_ref(), body, timeout)
4436            .await?;
4437        Ok(response)
4438    }
4439}
4440#[derive(Debug, Clone, PartialEq, Eq)]
4441#[doc = "API parts for the Info API"]
4442pub enum InfoParts {
4443    #[doc = "No parts"]
4444    None,
4445}
4446impl InfoParts {
4447    #[doc = "Builds a relative URL path to the Info API"]
4448    pub fn url(self) -> Cow<'static, str> {
4449        match self {
4450            InfoParts::None => "/".into(),
4451        }
4452    }
4453}
4454#[doc = "Builder for the [Info API](https://opensearch.org/docs/)\n\nReturns basic information about the cluster."]
4455#[derive(Clone, Debug)]
4456pub struct Info<'a, 'b> {
4457    transport: &'a Transport,
4458    parts: InfoParts,
4459    error_trace: Option<bool>,
4460    filter_path: Option<&'b [&'b str]>,
4461    headers: HeaderMap,
4462    human: Option<bool>,
4463    pretty: Option<bool>,
4464    request_timeout: Option<Duration>,
4465    source: Option<&'b str>,
4466}
4467impl<'a, 'b> Info<'a, 'b> {
4468    #[doc = "Creates a new instance of [Info]"]
4469    pub fn new(transport: &'a Transport) -> Self {
4470        let headers = HeaderMap::new();
4471        Info {
4472            transport,
4473            parts: InfoParts::None,
4474            headers,
4475            error_trace: None,
4476            filter_path: None,
4477            human: None,
4478            pretty: None,
4479            request_timeout: None,
4480            source: None,
4481        }
4482    }
4483    #[doc = "Include the stack trace of returned errors."]
4484    pub fn error_trace(mut self, error_trace: bool) -> Self {
4485        self.error_trace = Some(error_trace);
4486        self
4487    }
4488    #[doc = "A comma-separated list of filters used to reduce the response."]
4489    pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
4490        self.filter_path = Some(filter_path);
4491        self
4492    }
4493    #[doc = "Adds a HTTP header"]
4494    pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
4495        self.headers.insert(key, value);
4496        self
4497    }
4498    #[doc = "Return human readable values for statistics."]
4499    pub fn human(mut self, human: bool) -> Self {
4500        self.human = Some(human);
4501        self
4502    }
4503    #[doc = "Pretty format the returned JSON response."]
4504    pub fn pretty(mut self, pretty: bool) -> Self {
4505        self.pretty = Some(pretty);
4506        self
4507    }
4508    #[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."]
4509    pub fn request_timeout(mut self, timeout: Duration) -> Self {
4510        self.request_timeout = Some(timeout);
4511        self
4512    }
4513    #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
4514    pub fn source(mut self, source: &'b str) -> Self {
4515        self.source = Some(source);
4516        self
4517    }
4518    #[doc = "Creates an asynchronous call to the Info API that can be awaited"]
4519    pub async fn send(self) -> Result<Response, Error> {
4520        let path = self.parts.url();
4521        let method = Method::Get;
4522        let headers = self.headers;
4523        let timeout = self.request_timeout;
4524        let query_string = {
4525            #[serde_with::skip_serializing_none]
4526            #[derive(Serialize)]
4527            struct QueryParams<'b> {
4528                error_trace: Option<bool>,
4529                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
4530                filter_path: Option<&'b [&'b str]>,
4531                human: Option<bool>,
4532                pretty: Option<bool>,
4533                source: Option<&'b str>,
4534            }
4535            let query_params = QueryParams {
4536                error_trace: self.error_trace,
4537                filter_path: self.filter_path,
4538                human: self.human,
4539                pretty: self.pretty,
4540                source: self.source,
4541            };
4542            Some(query_params)
4543        };
4544        let body = Option::<()>::None;
4545        let response = self
4546            .transport
4547            .send(method, &path, headers, query_string.as_ref(), body, timeout)
4548            .await?;
4549        Ok(response)
4550    }
4551}
4552#[derive(Debug, Clone, PartialEq, Eq)]
4553#[doc = "API parts for the Mget API"]
4554pub enum MgetParts<'b> {
4555    #[doc = "No parts"]
4556    None,
4557    #[doc = "Index"]
4558    Index(&'b str),
4559}
4560impl<'b> MgetParts<'b> {
4561    #[doc = "Builds a relative URL path to the Mget API"]
4562    pub fn url(self) -> Cow<'static, str> {
4563        match self {
4564            MgetParts::None => "/_mget".into(),
4565            MgetParts::Index(index) => {
4566                let encoded_index: Cow<str> =
4567                    percent_encode(index.as_bytes(), PARTS_ENCODED).into();
4568                let mut p = String::with_capacity(7usize + encoded_index.len());
4569                p.push('/');
4570                p.push_str(encoded_index.as_ref());
4571                p.push_str("/_mget");
4572                p.into()
4573            }
4574        }
4575    }
4576}
4577#[doc = "Builder for the [Mget API](https://opensearch.org/docs/)\n\nAllows to get multiple documents in one request."]
4578#[derive(Clone, Debug)]
4579pub struct Mget<'a, 'b, B> {
4580    transport: &'a Transport,
4581    parts: MgetParts<'b>,
4582    _source: Option<&'b [&'b str]>,
4583    _source_excludes: Option<&'b [&'b str]>,
4584    _source_includes: Option<&'b [&'b str]>,
4585    body: Option<B>,
4586    error_trace: Option<bool>,
4587    filter_path: Option<&'b [&'b str]>,
4588    headers: HeaderMap,
4589    human: Option<bool>,
4590    preference: Option<&'b str>,
4591    pretty: Option<bool>,
4592    realtime: Option<bool>,
4593    refresh: Option<bool>,
4594    request_timeout: Option<Duration>,
4595    routing: Option<&'b str>,
4596    source: Option<&'b str>,
4597    stored_fields: Option<&'b [&'b str]>,
4598}
4599impl<'a, 'b, B> Mget<'a, 'b, B>
4600where
4601    B: Body,
4602{
4603    #[doc = "Creates a new instance of [Mget] with the specified API parts"]
4604    pub fn new(transport: &'a Transport, parts: MgetParts<'b>) -> Self {
4605        let headers = HeaderMap::new();
4606        Mget {
4607            transport,
4608            parts,
4609            headers,
4610            _source: None,
4611            _source_excludes: None,
4612            _source_includes: None,
4613            body: None,
4614            error_trace: None,
4615            filter_path: None,
4616            human: None,
4617            preference: None,
4618            pretty: None,
4619            realtime: None,
4620            refresh: None,
4621            request_timeout: None,
4622            routing: None,
4623            source: None,
4624            stored_fields: None,
4625        }
4626    }
4627    #[doc = "True or false to return the _source field or not, or a list of fields to return"]
4628    pub fn _source(mut self, _source: &'b [&'b str]) -> Self {
4629        self._source = Some(_source);
4630        self
4631    }
4632    #[doc = "A list of fields to exclude from the returned _source field"]
4633    pub fn _source_excludes(mut self, _source_excludes: &'b [&'b str]) -> Self {
4634        self._source_excludes = Some(_source_excludes);
4635        self
4636    }
4637    #[doc = "A list of fields to extract and return from the _source field"]
4638    pub fn _source_includes(mut self, _source_includes: &'b [&'b str]) -> Self {
4639        self._source_includes = Some(_source_includes);
4640        self
4641    }
4642    #[doc = "The body for the API call"]
4643    pub fn body<T>(self, body: T) -> Mget<'a, 'b, JsonBody<T>>
4644    where
4645        T: Serialize,
4646    {
4647        Mget {
4648            transport: self.transport,
4649            parts: self.parts,
4650            body: Some(body.into()),
4651            _source: self._source,
4652            _source_excludes: self._source_excludes,
4653            _source_includes: self._source_includes,
4654            error_trace: self.error_trace,
4655            filter_path: self.filter_path,
4656            headers: self.headers,
4657            human: self.human,
4658            preference: self.preference,
4659            pretty: self.pretty,
4660            realtime: self.realtime,
4661            refresh: self.refresh,
4662            request_timeout: self.request_timeout,
4663            routing: self.routing,
4664            source: self.source,
4665            stored_fields: self.stored_fields,
4666        }
4667    }
4668    #[doc = "Include the stack trace of returned errors."]
4669    pub fn error_trace(mut self, error_trace: bool) -> Self {
4670        self.error_trace = Some(error_trace);
4671        self
4672    }
4673    #[doc = "A comma-separated list of filters used to reduce the response."]
4674    pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
4675        self.filter_path = Some(filter_path);
4676        self
4677    }
4678    #[doc = "Adds a HTTP header"]
4679    pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
4680        self.headers.insert(key, value);
4681        self
4682    }
4683    #[doc = "Return human readable values for statistics."]
4684    pub fn human(mut self, human: bool) -> Self {
4685        self.human = Some(human);
4686        self
4687    }
4688    #[doc = "Specify the node or shard the operation should be performed on (default: random)"]
4689    pub fn preference(mut self, preference: &'b str) -> Self {
4690        self.preference = Some(preference);
4691        self
4692    }
4693    #[doc = "Pretty format the returned JSON response."]
4694    pub fn pretty(mut self, pretty: bool) -> Self {
4695        self.pretty = Some(pretty);
4696        self
4697    }
4698    #[doc = "Specify whether to perform the operation in realtime or search mode"]
4699    pub fn realtime(mut self, realtime: bool) -> Self {
4700        self.realtime = Some(realtime);
4701        self
4702    }
4703    #[doc = "Refresh the shard containing the document before performing the operation"]
4704    pub fn refresh(mut self, refresh: bool) -> Self {
4705        self.refresh = Some(refresh);
4706        self
4707    }
4708    #[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."]
4709    pub fn request_timeout(mut self, timeout: Duration) -> Self {
4710        self.request_timeout = Some(timeout);
4711        self
4712    }
4713    #[doc = "Specific routing value"]
4714    pub fn routing(mut self, routing: &'b str) -> Self {
4715        self.routing = Some(routing);
4716        self
4717    }
4718    #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
4719    pub fn source(mut self, source: &'b str) -> Self {
4720        self.source = Some(source);
4721        self
4722    }
4723    #[doc = "A comma-separated list of stored fields to return in the response"]
4724    pub fn stored_fields(mut self, stored_fields: &'b [&'b str]) -> Self {
4725        self.stored_fields = Some(stored_fields);
4726        self
4727    }
4728    #[doc = "Creates an asynchronous call to the Mget API that can be awaited"]
4729    pub async fn send(self) -> Result<Response, Error> {
4730        let path = self.parts.url();
4731        let method = match self.body {
4732            Some(_) => Method::Post,
4733            None => Method::Get,
4734        };
4735        let headers = self.headers;
4736        let timeout = self.request_timeout;
4737        let query_string = {
4738            #[serde_with::skip_serializing_none]
4739            #[derive(Serialize)]
4740            struct QueryParams<'b> {
4741                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
4742                _source: Option<&'b [&'b str]>,
4743                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
4744                _source_excludes: Option<&'b [&'b str]>,
4745                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
4746                _source_includes: Option<&'b [&'b str]>,
4747                error_trace: Option<bool>,
4748                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
4749                filter_path: Option<&'b [&'b str]>,
4750                human: Option<bool>,
4751                preference: Option<&'b str>,
4752                pretty: Option<bool>,
4753                realtime: Option<bool>,
4754                refresh: Option<bool>,
4755                routing: Option<&'b str>,
4756                source: Option<&'b str>,
4757                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
4758                stored_fields: Option<&'b [&'b str]>,
4759            }
4760            let query_params = QueryParams {
4761                _source: self._source,
4762                _source_excludes: self._source_excludes,
4763                _source_includes: self._source_includes,
4764                error_trace: self.error_trace,
4765                filter_path: self.filter_path,
4766                human: self.human,
4767                preference: self.preference,
4768                pretty: self.pretty,
4769                realtime: self.realtime,
4770                refresh: self.refresh,
4771                routing: self.routing,
4772                source: self.source,
4773                stored_fields: self.stored_fields,
4774            };
4775            Some(query_params)
4776        };
4777        let body = self.body;
4778        let response = self
4779            .transport
4780            .send(method, &path, headers, query_string.as_ref(), body, timeout)
4781            .await?;
4782        Ok(response)
4783    }
4784}
4785#[derive(Debug, Clone, PartialEq, Eq)]
4786#[doc = "API parts for the Msearch API"]
4787pub enum MsearchParts<'b> {
4788    #[doc = "No parts"]
4789    None,
4790    #[doc = "Index"]
4791    Index(&'b [&'b str]),
4792}
4793impl<'b> MsearchParts<'b> {
4794    #[doc = "Builds a relative URL path to the Msearch API"]
4795    pub fn url(self) -> Cow<'static, str> {
4796        match self {
4797            MsearchParts::None => "/_msearch".into(),
4798            MsearchParts::Index(index) => {
4799                let index_str = index.join(",");
4800                let encoded_index: Cow<str> =
4801                    percent_encode(index_str.as_bytes(), PARTS_ENCODED).into();
4802                let mut p = String::with_capacity(10usize + encoded_index.len());
4803                p.push('/');
4804                p.push_str(encoded_index.as_ref());
4805                p.push_str("/_msearch");
4806                p.into()
4807            }
4808        }
4809    }
4810}
4811#[doc = "Builder for the [Msearch API](https://opensearch.org/docs/)\n\nAllows to execute several search operations in one request."]
4812#[derive(Clone, Debug)]
4813pub struct Msearch<'a, 'b, B> {
4814    transport: &'a Transport,
4815    parts: MsearchParts<'b>,
4816    body: Option<B>,
4817    ccs_minimize_roundtrips: Option<bool>,
4818    error_trace: Option<bool>,
4819    filter_path: Option<&'b [&'b str]>,
4820    headers: HeaderMap,
4821    human: Option<bool>,
4822    max_concurrent_searches: Option<i64>,
4823    max_concurrent_shard_requests: Option<i64>,
4824    pre_filter_shard_size: Option<i64>,
4825    pretty: Option<bool>,
4826    request_timeout: Option<Duration>,
4827    rest_total_hits_as_int: Option<bool>,
4828    search_type: Option<SearchType>,
4829    source: Option<&'b str>,
4830    typed_keys: Option<bool>,
4831}
4832impl<'a, 'b, B> Msearch<'a, 'b, B>
4833where
4834    B: Body,
4835{
4836    #[doc = "Creates a new instance of [Msearch] with the specified API parts"]
4837    pub fn new(transport: &'a Transport, parts: MsearchParts<'b>) -> Self {
4838        let headers = HeaderMap::new();
4839        Msearch {
4840            transport,
4841            parts,
4842            headers,
4843            body: None,
4844            ccs_minimize_roundtrips: None,
4845            error_trace: None,
4846            filter_path: None,
4847            human: None,
4848            max_concurrent_searches: None,
4849            max_concurrent_shard_requests: None,
4850            pre_filter_shard_size: None,
4851            pretty: None,
4852            request_timeout: None,
4853            rest_total_hits_as_int: None,
4854            search_type: None,
4855            source: None,
4856            typed_keys: None,
4857        }
4858    }
4859    #[doc = "The body for the API call"]
4860    pub fn body<T>(self, body: Vec<T>) -> Msearch<'a, 'b, NdBody<T>>
4861    where
4862        T: Body,
4863    {
4864        Msearch {
4865            transport: self.transport,
4866            parts: self.parts,
4867            body: Some(NdBody(body)),
4868            ccs_minimize_roundtrips: self.ccs_minimize_roundtrips,
4869            error_trace: self.error_trace,
4870            filter_path: self.filter_path,
4871            headers: self.headers,
4872            human: self.human,
4873            max_concurrent_searches: self.max_concurrent_searches,
4874            max_concurrent_shard_requests: self.max_concurrent_shard_requests,
4875            pre_filter_shard_size: self.pre_filter_shard_size,
4876            pretty: self.pretty,
4877            request_timeout: self.request_timeout,
4878            rest_total_hits_as_int: self.rest_total_hits_as_int,
4879            search_type: self.search_type,
4880            source: self.source,
4881            typed_keys: self.typed_keys,
4882        }
4883    }
4884    #[doc = "Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution"]
4885    pub fn ccs_minimize_roundtrips(mut self, ccs_minimize_roundtrips: bool) -> Self {
4886        self.ccs_minimize_roundtrips = Some(ccs_minimize_roundtrips);
4887        self
4888    }
4889    #[doc = "Include the stack trace of returned errors."]
4890    pub fn error_trace(mut self, error_trace: bool) -> Self {
4891        self.error_trace = Some(error_trace);
4892        self
4893    }
4894    #[doc = "A comma-separated list of filters used to reduce the response."]
4895    pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
4896        self.filter_path = Some(filter_path);
4897        self
4898    }
4899    #[doc = "Adds a HTTP header"]
4900    pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
4901        self.headers.insert(key, value);
4902        self
4903    }
4904    #[doc = "Return human readable values for statistics."]
4905    pub fn human(mut self, human: bool) -> Self {
4906        self.human = Some(human);
4907        self
4908    }
4909    #[doc = "Controls the maximum number of concurrent searches the multi search api will execute"]
4910    pub fn max_concurrent_searches(mut self, max_concurrent_searches: i64) -> Self {
4911        self.max_concurrent_searches = Some(max_concurrent_searches);
4912        self
4913    }
4914    #[doc = "The number of concurrent shard requests each sub search executes concurrently per node. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests"]
4915    pub fn max_concurrent_shard_requests(mut self, max_concurrent_shard_requests: i64) -> Self {
4916        self.max_concurrent_shard_requests = Some(max_concurrent_shard_requests);
4917        self
4918    }
4919    #[doc = "A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the\u{a0}number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on its rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint."]
4920    pub fn pre_filter_shard_size(mut self, pre_filter_shard_size: i64) -> Self {
4921        self.pre_filter_shard_size = Some(pre_filter_shard_size);
4922        self
4923    }
4924    #[doc = "Pretty format the returned JSON response."]
4925    pub fn pretty(mut self, pretty: bool) -> Self {
4926        self.pretty = Some(pretty);
4927        self
4928    }
4929    #[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."]
4930    pub fn request_timeout(mut self, timeout: Duration) -> Self {
4931        self.request_timeout = Some(timeout);
4932        self
4933    }
4934    #[doc = "Indicates whether hits.total should be rendered as an integer or an object in the rest search response"]
4935    pub fn rest_total_hits_as_int(mut self, rest_total_hits_as_int: bool) -> Self {
4936        self.rest_total_hits_as_int = Some(rest_total_hits_as_int);
4937        self
4938    }
4939    #[doc = "Search operation type"]
4940    pub fn search_type(mut self, search_type: SearchType) -> Self {
4941        self.search_type = Some(search_type);
4942        self
4943    }
4944    #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
4945    pub fn source(mut self, source: &'b str) -> Self {
4946        self.source = Some(source);
4947        self
4948    }
4949    #[doc = "Specify whether aggregation and suggester names should be prefixed by their respective types in the response"]
4950    pub fn typed_keys(mut self, typed_keys: bool) -> Self {
4951        self.typed_keys = Some(typed_keys);
4952        self
4953    }
4954    #[doc = "Creates an asynchronous call to the Msearch API that can be awaited"]
4955    pub async fn send(self) -> Result<Response, Error> {
4956        let path = self.parts.url();
4957        let method = match self.body {
4958            Some(_) => Method::Post,
4959            None => Method::Get,
4960        };
4961        let headers = self.headers;
4962        let timeout = self.request_timeout;
4963        let query_string = {
4964            #[serde_with::skip_serializing_none]
4965            #[derive(Serialize)]
4966            struct QueryParams<'b> {
4967                ccs_minimize_roundtrips: Option<bool>,
4968                error_trace: Option<bool>,
4969                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
4970                filter_path: Option<&'b [&'b str]>,
4971                human: Option<bool>,
4972                max_concurrent_searches: Option<i64>,
4973                max_concurrent_shard_requests: Option<i64>,
4974                pre_filter_shard_size: Option<i64>,
4975                pretty: Option<bool>,
4976                rest_total_hits_as_int: Option<bool>,
4977                search_type: Option<SearchType>,
4978                source: Option<&'b str>,
4979                typed_keys: Option<bool>,
4980            }
4981            let query_params = QueryParams {
4982                ccs_minimize_roundtrips: self.ccs_minimize_roundtrips,
4983                error_trace: self.error_trace,
4984                filter_path: self.filter_path,
4985                human: self.human,
4986                max_concurrent_searches: self.max_concurrent_searches,
4987                max_concurrent_shard_requests: self.max_concurrent_shard_requests,
4988                pre_filter_shard_size: self.pre_filter_shard_size,
4989                pretty: self.pretty,
4990                rest_total_hits_as_int: self.rest_total_hits_as_int,
4991                search_type: self.search_type,
4992                source: self.source,
4993                typed_keys: self.typed_keys,
4994            };
4995            Some(query_params)
4996        };
4997        let body = self.body;
4998        let response = self
4999            .transport
5000            .send(method, &path, headers, query_string.as_ref(), body, timeout)
5001            .await?;
5002        Ok(response)
5003    }
5004}
5005#[derive(Debug, Clone, PartialEq, Eq)]
5006#[doc = "API parts for the Msearch Template API"]
5007pub enum MsearchTemplateParts<'b> {
5008    #[doc = "No parts"]
5009    None,
5010    #[doc = "Index"]
5011    Index(&'b [&'b str]),
5012}
5013impl<'b> MsearchTemplateParts<'b> {
5014    #[doc = "Builds a relative URL path to the Msearch Template API"]
5015    pub fn url(self) -> Cow<'static, str> {
5016        match self {
5017            MsearchTemplateParts::None => "/_msearch/template".into(),
5018            MsearchTemplateParts::Index(index) => {
5019                let index_str = index.join(",");
5020                let encoded_index: Cow<str> =
5021                    percent_encode(index_str.as_bytes(), PARTS_ENCODED).into();
5022                let mut p = String::with_capacity(19usize + encoded_index.len());
5023                p.push('/');
5024                p.push_str(encoded_index.as_ref());
5025                p.push_str("/_msearch/template");
5026                p.into()
5027            }
5028        }
5029    }
5030}
5031#[doc = "Builder for the [Msearch Template API](https://opensearch.org/docs/)\n\nAllows to execute several search template operations in one request."]
5032#[derive(Clone, Debug)]
5033pub struct MsearchTemplate<'a, 'b, B> {
5034    transport: &'a Transport,
5035    parts: MsearchTemplateParts<'b>,
5036    body: Option<B>,
5037    ccs_minimize_roundtrips: Option<bool>,
5038    error_trace: Option<bool>,
5039    filter_path: Option<&'b [&'b str]>,
5040    headers: HeaderMap,
5041    human: Option<bool>,
5042    max_concurrent_searches: Option<i64>,
5043    pretty: Option<bool>,
5044    request_timeout: Option<Duration>,
5045    rest_total_hits_as_int: Option<bool>,
5046    search_type: Option<SearchType>,
5047    source: Option<&'b str>,
5048    typed_keys: Option<bool>,
5049}
5050impl<'a, 'b, B> MsearchTemplate<'a, 'b, B>
5051where
5052    B: Body,
5053{
5054    #[doc = "Creates a new instance of [MsearchTemplate] with the specified API parts"]
5055    pub fn new(transport: &'a Transport, parts: MsearchTemplateParts<'b>) -> Self {
5056        let headers = HeaderMap::new();
5057        MsearchTemplate {
5058            transport,
5059            parts,
5060            headers,
5061            body: None,
5062            ccs_minimize_roundtrips: None,
5063            error_trace: None,
5064            filter_path: None,
5065            human: None,
5066            max_concurrent_searches: None,
5067            pretty: None,
5068            request_timeout: None,
5069            rest_total_hits_as_int: None,
5070            search_type: None,
5071            source: None,
5072            typed_keys: None,
5073        }
5074    }
5075    #[doc = "The body for the API call"]
5076    pub fn body<T>(self, body: Vec<T>) -> MsearchTemplate<'a, 'b, NdBody<T>>
5077    where
5078        T: Body,
5079    {
5080        MsearchTemplate {
5081            transport: self.transport,
5082            parts: self.parts,
5083            body: Some(NdBody(body)),
5084            ccs_minimize_roundtrips: self.ccs_minimize_roundtrips,
5085            error_trace: self.error_trace,
5086            filter_path: self.filter_path,
5087            headers: self.headers,
5088            human: self.human,
5089            max_concurrent_searches: self.max_concurrent_searches,
5090            pretty: self.pretty,
5091            request_timeout: self.request_timeout,
5092            rest_total_hits_as_int: self.rest_total_hits_as_int,
5093            search_type: self.search_type,
5094            source: self.source,
5095            typed_keys: self.typed_keys,
5096        }
5097    }
5098    #[doc = "Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution"]
5099    pub fn ccs_minimize_roundtrips(mut self, ccs_minimize_roundtrips: bool) -> Self {
5100        self.ccs_minimize_roundtrips = Some(ccs_minimize_roundtrips);
5101        self
5102    }
5103    #[doc = "Include the stack trace of returned errors."]
5104    pub fn error_trace(mut self, error_trace: bool) -> Self {
5105        self.error_trace = Some(error_trace);
5106        self
5107    }
5108    #[doc = "A comma-separated list of filters used to reduce the response."]
5109    pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
5110        self.filter_path = Some(filter_path);
5111        self
5112    }
5113    #[doc = "Adds a HTTP header"]
5114    pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
5115        self.headers.insert(key, value);
5116        self
5117    }
5118    #[doc = "Return human readable values for statistics."]
5119    pub fn human(mut self, human: bool) -> Self {
5120        self.human = Some(human);
5121        self
5122    }
5123    #[doc = "Controls the maximum number of concurrent searches the multi search api will execute"]
5124    pub fn max_concurrent_searches(mut self, max_concurrent_searches: i64) -> Self {
5125        self.max_concurrent_searches = Some(max_concurrent_searches);
5126        self
5127    }
5128    #[doc = "Pretty format the returned JSON response."]
5129    pub fn pretty(mut self, pretty: bool) -> Self {
5130        self.pretty = Some(pretty);
5131        self
5132    }
5133    #[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."]
5134    pub fn request_timeout(mut self, timeout: Duration) -> Self {
5135        self.request_timeout = Some(timeout);
5136        self
5137    }
5138    #[doc = "Indicates whether hits.total should be rendered as an integer or an object in the rest search response"]
5139    pub fn rest_total_hits_as_int(mut self, rest_total_hits_as_int: bool) -> Self {
5140        self.rest_total_hits_as_int = Some(rest_total_hits_as_int);
5141        self
5142    }
5143    #[doc = "Search operation type"]
5144    pub fn search_type(mut self, search_type: SearchType) -> Self {
5145        self.search_type = Some(search_type);
5146        self
5147    }
5148    #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
5149    pub fn source(mut self, source: &'b str) -> Self {
5150        self.source = Some(source);
5151        self
5152    }
5153    #[doc = "Specify whether aggregation and suggester names should be prefixed by their respective types in the response"]
5154    pub fn typed_keys(mut self, typed_keys: bool) -> Self {
5155        self.typed_keys = Some(typed_keys);
5156        self
5157    }
5158    #[doc = "Creates an asynchronous call to the Msearch Template API that can be awaited"]
5159    pub async fn send(self) -> Result<Response, Error> {
5160        let path = self.parts.url();
5161        let method = match self.body {
5162            Some(_) => Method::Post,
5163            None => Method::Get,
5164        };
5165        let headers = self.headers;
5166        let timeout = self.request_timeout;
5167        let query_string = {
5168            #[serde_with::skip_serializing_none]
5169            #[derive(Serialize)]
5170            struct QueryParams<'b> {
5171                ccs_minimize_roundtrips: Option<bool>,
5172                error_trace: Option<bool>,
5173                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
5174                filter_path: Option<&'b [&'b str]>,
5175                human: Option<bool>,
5176                max_concurrent_searches: Option<i64>,
5177                pretty: Option<bool>,
5178                rest_total_hits_as_int: Option<bool>,
5179                search_type: Option<SearchType>,
5180                source: Option<&'b str>,
5181                typed_keys: Option<bool>,
5182            }
5183            let query_params = QueryParams {
5184                ccs_minimize_roundtrips: self.ccs_minimize_roundtrips,
5185                error_trace: self.error_trace,
5186                filter_path: self.filter_path,
5187                human: self.human,
5188                max_concurrent_searches: self.max_concurrent_searches,
5189                pretty: self.pretty,
5190                rest_total_hits_as_int: self.rest_total_hits_as_int,
5191                search_type: self.search_type,
5192                source: self.source,
5193                typed_keys: self.typed_keys,
5194            };
5195            Some(query_params)
5196        };
5197        let body = self.body;
5198        let response = self
5199            .transport
5200            .send(method, &path, headers, query_string.as_ref(), body, timeout)
5201            .await?;
5202        Ok(response)
5203    }
5204}
5205#[derive(Debug, Clone, PartialEq, Eq)]
5206#[doc = "API parts for the Mtermvectors API"]
5207pub enum MtermvectorsParts<'b> {
5208    #[doc = "No parts"]
5209    None,
5210    #[doc = "Index"]
5211    Index(&'b str),
5212}
5213impl<'b> MtermvectorsParts<'b> {
5214    #[doc = "Builds a relative URL path to the Mtermvectors API"]
5215    pub fn url(self) -> Cow<'static, str> {
5216        match self {
5217            MtermvectorsParts::None => "/_mtermvectors".into(),
5218            MtermvectorsParts::Index(index) => {
5219                let encoded_index: Cow<str> =
5220                    percent_encode(index.as_bytes(), PARTS_ENCODED).into();
5221                let mut p = String::with_capacity(15usize + encoded_index.len());
5222                p.push('/');
5223                p.push_str(encoded_index.as_ref());
5224                p.push_str("/_mtermvectors");
5225                p.into()
5226            }
5227        }
5228    }
5229}
5230#[doc = "Builder for the [Mtermvectors API](https://opensearch.org/docs/)\n\nReturns multiple termvectors in one request."]
5231#[derive(Clone, Debug)]
5232pub struct Mtermvectors<'a, 'b, B> {
5233    transport: &'a Transport,
5234    parts: MtermvectorsParts<'b>,
5235    body: Option<B>,
5236    error_trace: Option<bool>,
5237    field_statistics: Option<bool>,
5238    fields: Option<&'b [&'b str]>,
5239    filter_path: Option<&'b [&'b str]>,
5240    headers: HeaderMap,
5241    human: Option<bool>,
5242    ids: Option<&'b [&'b str]>,
5243    offsets: Option<bool>,
5244    payloads: Option<bool>,
5245    positions: Option<bool>,
5246    preference: Option<&'b str>,
5247    pretty: Option<bool>,
5248    realtime: Option<bool>,
5249    request_timeout: Option<Duration>,
5250    routing: Option<&'b str>,
5251    source: Option<&'b str>,
5252    term_statistics: Option<bool>,
5253    version: Option<i64>,
5254    version_type: Option<VersionType>,
5255}
5256impl<'a, 'b, B> Mtermvectors<'a, 'b, B>
5257where
5258    B: Body,
5259{
5260    #[doc = "Creates a new instance of [Mtermvectors] with the specified API parts"]
5261    pub fn new(transport: &'a Transport, parts: MtermvectorsParts<'b>) -> Self {
5262        let headers = HeaderMap::new();
5263        Mtermvectors {
5264            transport,
5265            parts,
5266            headers,
5267            body: None,
5268            error_trace: None,
5269            field_statistics: None,
5270            fields: None,
5271            filter_path: None,
5272            human: None,
5273            ids: None,
5274            offsets: None,
5275            payloads: None,
5276            positions: None,
5277            preference: None,
5278            pretty: None,
5279            realtime: None,
5280            request_timeout: None,
5281            routing: None,
5282            source: None,
5283            term_statistics: None,
5284            version: None,
5285            version_type: None,
5286        }
5287    }
5288    #[doc = "The body for the API call"]
5289    pub fn body<T>(self, body: T) -> Mtermvectors<'a, 'b, JsonBody<T>>
5290    where
5291        T: Serialize,
5292    {
5293        Mtermvectors {
5294            transport: self.transport,
5295            parts: self.parts,
5296            body: Some(body.into()),
5297            error_trace: self.error_trace,
5298            field_statistics: self.field_statistics,
5299            fields: self.fields,
5300            filter_path: self.filter_path,
5301            headers: self.headers,
5302            human: self.human,
5303            ids: self.ids,
5304            offsets: self.offsets,
5305            payloads: self.payloads,
5306            positions: self.positions,
5307            preference: self.preference,
5308            pretty: self.pretty,
5309            realtime: self.realtime,
5310            request_timeout: self.request_timeout,
5311            routing: self.routing,
5312            source: self.source,
5313            term_statistics: self.term_statistics,
5314            version: self.version,
5315            version_type: self.version_type,
5316        }
5317    }
5318    #[doc = "Include the stack trace of returned errors."]
5319    pub fn error_trace(mut self, error_trace: bool) -> Self {
5320        self.error_trace = Some(error_trace);
5321        self
5322    }
5323    #[doc = "Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. Applies to all returned documents unless otherwise specified in body \"params\" or \"docs\"."]
5324    pub fn field_statistics(mut self, field_statistics: bool) -> Self {
5325        self.field_statistics = Some(field_statistics);
5326        self
5327    }
5328    #[doc = "A comma-separated list of fields to return. Applies to all returned documents unless otherwise specified in body \"params\" or \"docs\"."]
5329    pub fn fields(mut self, fields: &'b [&'b str]) -> Self {
5330        self.fields = Some(fields);
5331        self
5332    }
5333    #[doc = "A comma-separated list of filters used to reduce the response."]
5334    pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
5335        self.filter_path = Some(filter_path);
5336        self
5337    }
5338    #[doc = "Adds a HTTP header"]
5339    pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
5340        self.headers.insert(key, value);
5341        self
5342    }
5343    #[doc = "Return human readable values for statistics."]
5344    pub fn human(mut self, human: bool) -> Self {
5345        self.human = Some(human);
5346        self
5347    }
5348    #[doc = "A comma-separated list of documents ids. You must define ids as parameter or set \"ids\" or \"docs\" in the request body"]
5349    pub fn ids(mut self, ids: &'b [&'b str]) -> Self {
5350        self.ids = Some(ids);
5351        self
5352    }
5353    #[doc = "Specifies if term offsets should be returned. Applies to all returned documents unless otherwise specified in body \"params\" or \"docs\"."]
5354    pub fn offsets(mut self, offsets: bool) -> Self {
5355        self.offsets = Some(offsets);
5356        self
5357    }
5358    #[doc = "Specifies if term payloads should be returned. Applies to all returned documents unless otherwise specified in body \"params\" or \"docs\"."]
5359    pub fn payloads(mut self, payloads: bool) -> Self {
5360        self.payloads = Some(payloads);
5361        self
5362    }
5363    #[doc = "Specifies if term positions should be returned. Applies to all returned documents unless otherwise specified in body \"params\" or \"docs\"."]
5364    pub fn positions(mut self, positions: bool) -> Self {
5365        self.positions = Some(positions);
5366        self
5367    }
5368    #[doc = "Specify the node or shard the operation should be performed on (default: random) .Applies to all returned documents unless otherwise specified in body \"params\" or \"docs\"."]
5369    pub fn preference(mut self, preference: &'b str) -> Self {
5370        self.preference = Some(preference);
5371        self
5372    }
5373    #[doc = "Pretty format the returned JSON response."]
5374    pub fn pretty(mut self, pretty: bool) -> Self {
5375        self.pretty = Some(pretty);
5376        self
5377    }
5378    #[doc = "Specifies if requests are real-time as opposed to near-real-time (default: true)."]
5379    pub fn realtime(mut self, realtime: bool) -> Self {
5380        self.realtime = Some(realtime);
5381        self
5382    }
5383    #[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."]
5384    pub fn request_timeout(mut self, timeout: Duration) -> Self {
5385        self.request_timeout = Some(timeout);
5386        self
5387    }
5388    #[doc = "Specific routing value. Applies to all returned documents unless otherwise specified in body \"params\" or \"docs\"."]
5389    pub fn routing(mut self, routing: &'b str) -> Self {
5390        self.routing = Some(routing);
5391        self
5392    }
5393    #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
5394    pub fn source(mut self, source: &'b str) -> Self {
5395        self.source = Some(source);
5396        self
5397    }
5398    #[doc = "Specifies if total term frequency and document frequency should be returned. Applies to all returned documents unless otherwise specified in body \"params\" or \"docs\"."]
5399    pub fn term_statistics(mut self, term_statistics: bool) -> Self {
5400        self.term_statistics = Some(term_statistics);
5401        self
5402    }
5403    #[doc = "Explicit version number for concurrency control"]
5404    pub fn version(mut self, version: i64) -> Self {
5405        self.version = Some(version);
5406        self
5407    }
5408    #[doc = "Specific version type"]
5409    pub fn version_type(mut self, version_type: VersionType) -> Self {
5410        self.version_type = Some(version_type);
5411        self
5412    }
5413    #[doc = "Creates an asynchronous call to the Mtermvectors API that can be awaited"]
5414    pub async fn send(self) -> Result<Response, Error> {
5415        let path = self.parts.url();
5416        let method = match self.body {
5417            Some(_) => Method::Post,
5418            None => Method::Get,
5419        };
5420        let headers = self.headers;
5421        let timeout = self.request_timeout;
5422        let query_string = {
5423            #[serde_with::skip_serializing_none]
5424            #[derive(Serialize)]
5425            struct QueryParams<'b> {
5426                error_trace: Option<bool>,
5427                field_statistics: Option<bool>,
5428                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
5429                fields: Option<&'b [&'b str]>,
5430                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
5431                filter_path: Option<&'b [&'b str]>,
5432                human: Option<bool>,
5433                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
5434                ids: Option<&'b [&'b str]>,
5435                offsets: Option<bool>,
5436                payloads: Option<bool>,
5437                positions: Option<bool>,
5438                preference: Option<&'b str>,
5439                pretty: Option<bool>,
5440                realtime: Option<bool>,
5441                routing: Option<&'b str>,
5442                source: Option<&'b str>,
5443                term_statistics: Option<bool>,
5444                version: Option<i64>,
5445                version_type: Option<VersionType>,
5446            }
5447            let query_params = QueryParams {
5448                error_trace: self.error_trace,
5449                field_statistics: self.field_statistics,
5450                fields: self.fields,
5451                filter_path: self.filter_path,
5452                human: self.human,
5453                ids: self.ids,
5454                offsets: self.offsets,
5455                payloads: self.payloads,
5456                positions: self.positions,
5457                preference: self.preference,
5458                pretty: self.pretty,
5459                realtime: self.realtime,
5460                routing: self.routing,
5461                source: self.source,
5462                term_statistics: self.term_statistics,
5463                version: self.version,
5464                version_type: self.version_type,
5465            };
5466            Some(query_params)
5467        };
5468        let body = self.body;
5469        let response = self
5470            .transport
5471            .send(method, &path, headers, query_string.as_ref(), body, timeout)
5472            .await?;
5473        Ok(response)
5474    }
5475}
5476#[derive(Debug, Clone, PartialEq, Eq)]
5477#[doc = "API parts for the Ping API"]
5478pub enum PingParts {
5479    #[doc = "No parts"]
5480    None,
5481}
5482impl PingParts {
5483    #[doc = "Builds a relative URL path to the Ping API"]
5484    pub fn url(self) -> Cow<'static, str> {
5485        match self {
5486            PingParts::None => "/".into(),
5487        }
5488    }
5489}
5490#[doc = "Builder for the [Ping API](https://opensearch.org/docs/)\n\nReturns whether the cluster is running."]
5491#[derive(Clone, Debug)]
5492pub struct Ping<'a, 'b> {
5493    transport: &'a Transport,
5494    parts: PingParts,
5495    error_trace: Option<bool>,
5496    filter_path: Option<&'b [&'b str]>,
5497    headers: HeaderMap,
5498    human: Option<bool>,
5499    pretty: Option<bool>,
5500    request_timeout: Option<Duration>,
5501    source: Option<&'b str>,
5502}
5503impl<'a, 'b> Ping<'a, 'b> {
5504    #[doc = "Creates a new instance of [Ping]"]
5505    pub fn new(transport: &'a Transport) -> Self {
5506        let headers = HeaderMap::new();
5507        Ping {
5508            transport,
5509            parts: PingParts::None,
5510            headers,
5511            error_trace: None,
5512            filter_path: None,
5513            human: None,
5514            pretty: None,
5515            request_timeout: None,
5516            source: None,
5517        }
5518    }
5519    #[doc = "Include the stack trace of returned errors."]
5520    pub fn error_trace(mut self, error_trace: bool) -> Self {
5521        self.error_trace = Some(error_trace);
5522        self
5523    }
5524    #[doc = "A comma-separated list of filters used to reduce the response."]
5525    pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
5526        self.filter_path = Some(filter_path);
5527        self
5528    }
5529    #[doc = "Adds a HTTP header"]
5530    pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
5531        self.headers.insert(key, value);
5532        self
5533    }
5534    #[doc = "Return human readable values for statistics."]
5535    pub fn human(mut self, human: bool) -> Self {
5536        self.human = Some(human);
5537        self
5538    }
5539    #[doc = "Pretty format the returned JSON response."]
5540    pub fn pretty(mut self, pretty: bool) -> Self {
5541        self.pretty = Some(pretty);
5542        self
5543    }
5544    #[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."]
5545    pub fn request_timeout(mut self, timeout: Duration) -> Self {
5546        self.request_timeout = Some(timeout);
5547        self
5548    }
5549    #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
5550    pub fn source(mut self, source: &'b str) -> Self {
5551        self.source = Some(source);
5552        self
5553    }
5554    #[doc = "Creates an asynchronous call to the Ping API that can be awaited"]
5555    pub async fn send(self) -> Result<Response, Error> {
5556        let path = self.parts.url();
5557        let method = Method::Head;
5558        let headers = self.headers;
5559        let timeout = self.request_timeout;
5560        let query_string = {
5561            #[serde_with::skip_serializing_none]
5562            #[derive(Serialize)]
5563            struct QueryParams<'b> {
5564                error_trace: Option<bool>,
5565                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
5566                filter_path: Option<&'b [&'b str]>,
5567                human: Option<bool>,
5568                pretty: Option<bool>,
5569                source: Option<&'b str>,
5570            }
5571            let query_params = QueryParams {
5572                error_trace: self.error_trace,
5573                filter_path: self.filter_path,
5574                human: self.human,
5575                pretty: self.pretty,
5576                source: self.source,
5577            };
5578            Some(query_params)
5579        };
5580        let body = Option::<()>::None;
5581        let response = self
5582            .transport
5583            .send(method, &path, headers, query_string.as_ref(), body, timeout)
5584            .await?;
5585        Ok(response)
5586    }
5587}
5588#[derive(Debug, Clone, PartialEq, Eq)]
5589#[doc = "API parts for the Put Script API"]
5590pub enum PutScriptParts<'b> {
5591    #[doc = "Id"]
5592    Id(&'b str),
5593    #[doc = "Id and Context"]
5594    IdContext(&'b str, &'b str),
5595}
5596impl<'b> PutScriptParts<'b> {
5597    #[doc = "Builds a relative URL path to the Put Script API"]
5598    pub fn url(self) -> Cow<'static, str> {
5599        match self {
5600            PutScriptParts::Id(id) => {
5601                let encoded_id: Cow<str> = percent_encode(id.as_bytes(), PARTS_ENCODED).into();
5602                let mut p = String::with_capacity(10usize + encoded_id.len());
5603                p.push_str("/_scripts/");
5604                p.push_str(encoded_id.as_ref());
5605                p.into()
5606            }
5607            PutScriptParts::IdContext(id, context) => {
5608                let encoded_id: Cow<str> = percent_encode(id.as_bytes(), PARTS_ENCODED).into();
5609                let encoded_context: Cow<str> =
5610                    percent_encode(context.as_bytes(), PARTS_ENCODED).into();
5611                let mut p =
5612                    String::with_capacity(11usize + encoded_id.len() + encoded_context.len());
5613                p.push_str("/_scripts/");
5614                p.push_str(encoded_id.as_ref());
5615                p.push('/');
5616                p.push_str(encoded_context.as_ref());
5617                p.into()
5618            }
5619        }
5620    }
5621}
5622#[doc = "Builder for the [Put Script API](https://opensearch.org/docs/)\n\nCreates or updates a script."]
5623#[derive(Clone, Debug)]
5624pub struct PutScript<'a, 'b, B> {
5625    transport: &'a Transport,
5626    parts: PutScriptParts<'b>,
5627    body: Option<B>,
5628    cluster_manager_timeout: Option<&'b str>,
5629    context: Option<&'b str>,
5630    error_trace: Option<bool>,
5631    filter_path: Option<&'b [&'b str]>,
5632    headers: HeaderMap,
5633    human: Option<bool>,
5634    master_timeout: Option<&'b str>,
5635    pretty: Option<bool>,
5636    request_timeout: Option<Duration>,
5637    source: Option<&'b str>,
5638    timeout: Option<&'b str>,
5639}
5640impl<'a, 'b, B> PutScript<'a, 'b, B>
5641where
5642    B: Body,
5643{
5644    #[doc = "Creates a new instance of [PutScript] with the specified API parts"]
5645    pub fn new(transport: &'a Transport, parts: PutScriptParts<'b>) -> Self {
5646        let headers = HeaderMap::new();
5647        PutScript {
5648            transport,
5649            parts,
5650            headers,
5651            body: None,
5652            cluster_manager_timeout: None,
5653            context: None,
5654            error_trace: None,
5655            filter_path: None,
5656            human: None,
5657            master_timeout: None,
5658            pretty: None,
5659            request_timeout: None,
5660            source: None,
5661            timeout: None,
5662        }
5663    }
5664    #[doc = "The body for the API call"]
5665    pub fn body<T>(self, body: T) -> PutScript<'a, 'b, JsonBody<T>>
5666    where
5667        T: Serialize,
5668    {
5669        PutScript {
5670            transport: self.transport,
5671            parts: self.parts,
5672            body: Some(body.into()),
5673            cluster_manager_timeout: self.cluster_manager_timeout,
5674            context: self.context,
5675            error_trace: self.error_trace,
5676            filter_path: self.filter_path,
5677            headers: self.headers,
5678            human: self.human,
5679            master_timeout: self.master_timeout,
5680            pretty: self.pretty,
5681            request_timeout: self.request_timeout,
5682            source: self.source,
5683            timeout: self.timeout,
5684        }
5685    }
5686    #[doc = "Specify timeout for connection to cluster-manager node"]
5687    pub fn cluster_manager_timeout(mut self, cluster_manager_timeout: &'b str) -> Self {
5688        self.cluster_manager_timeout = Some(cluster_manager_timeout);
5689        self
5690    }
5691    #[doc = "Context name to compile script against"]
5692    pub fn context(mut self, context: &'b str) -> Self {
5693        self.context = Some(context);
5694        self
5695    }
5696    #[doc = "Include the stack trace of returned errors."]
5697    pub fn error_trace(mut self, error_trace: bool) -> Self {
5698        self.error_trace = Some(error_trace);
5699        self
5700    }
5701    #[doc = "A comma-separated list of filters used to reduce the response."]
5702    pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
5703        self.filter_path = Some(filter_path);
5704        self
5705    }
5706    #[doc = "Adds a HTTP header"]
5707    pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
5708        self.headers.insert(key, value);
5709        self
5710    }
5711    #[doc = "Return human readable values for statistics."]
5712    pub fn human(mut self, human: bool) -> Self {
5713        self.human = Some(human);
5714        self
5715    }
5716    #[doc = "Specify timeout for connection to cluster-manager node"]
5717    #[deprecated = "To support inclusive language, use 'cluster_manager_timeout' instead."]
5718    pub fn master_timeout(mut self, master_timeout: &'b str) -> Self {
5719        self.master_timeout = Some(master_timeout);
5720        self
5721    }
5722    #[doc = "Pretty format the returned JSON response."]
5723    pub fn pretty(mut self, pretty: bool) -> Self {
5724        self.pretty = Some(pretty);
5725        self
5726    }
5727    #[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."]
5728    pub fn request_timeout(mut self, timeout: Duration) -> Self {
5729        self.request_timeout = Some(timeout);
5730        self
5731    }
5732    #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
5733    pub fn source(mut self, source: &'b str) -> Self {
5734        self.source = Some(source);
5735        self
5736    }
5737    #[doc = "Explicit operation timeout"]
5738    pub fn timeout(mut self, timeout: &'b str) -> Self {
5739        self.timeout = Some(timeout);
5740        self
5741    }
5742    #[doc = "Creates an asynchronous call to the Put Script API that can be awaited"]
5743    pub async fn send(self) -> Result<Response, Error> {
5744        let path = self.parts.url();
5745        let method = Method::Put;
5746        let headers = self.headers;
5747        let timeout = self.request_timeout;
5748        let query_string = {
5749            #[serde_with::skip_serializing_none]
5750            #[derive(Serialize)]
5751            struct QueryParams<'b> {
5752                cluster_manager_timeout: Option<&'b str>,
5753                context: Option<&'b str>,
5754                error_trace: Option<bool>,
5755                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
5756                filter_path: Option<&'b [&'b str]>,
5757                human: Option<bool>,
5758                master_timeout: Option<&'b str>,
5759                pretty: Option<bool>,
5760                source: Option<&'b str>,
5761                timeout: Option<&'b str>,
5762            }
5763            let query_params = QueryParams {
5764                cluster_manager_timeout: self.cluster_manager_timeout,
5765                context: self.context,
5766                error_trace: self.error_trace,
5767                filter_path: self.filter_path,
5768                human: self.human,
5769                master_timeout: self.master_timeout,
5770                pretty: self.pretty,
5771                source: self.source,
5772                timeout: self.timeout,
5773            };
5774            Some(query_params)
5775        };
5776        let body = self.body;
5777        let response = self
5778            .transport
5779            .send(method, &path, headers, query_string.as_ref(), body, timeout)
5780            .await?;
5781        Ok(response)
5782    }
5783}
5784#[cfg(feature = "experimental-apis")]
5785#[derive(Debug, Clone, PartialEq, Eq)]
5786#[doc = "API parts for the Rank Eval API"]
5787pub enum RankEvalParts<'b> {
5788    #[doc = "No parts"]
5789    None,
5790    #[doc = "Index"]
5791    Index(&'b [&'b str]),
5792}
5793#[cfg(feature = "experimental-apis")]
5794impl<'b> RankEvalParts<'b> {
5795    #[doc = "Builds a relative URL path to the Rank Eval API"]
5796    pub fn url(self) -> Cow<'static, str> {
5797        match self {
5798            RankEvalParts::None => "/_rank_eval".into(),
5799            RankEvalParts::Index(index) => {
5800                let index_str = index.join(",");
5801                let encoded_index: Cow<str> =
5802                    percent_encode(index_str.as_bytes(), PARTS_ENCODED).into();
5803                let mut p = String::with_capacity(12usize + encoded_index.len());
5804                p.push('/');
5805                p.push_str(encoded_index.as_ref());
5806                p.push_str("/_rank_eval");
5807                p.into()
5808            }
5809        }
5810    }
5811}
5812#[doc = "Builder for the [Rank Eval API](https://opensearch.org/docs/)\n\nAllows to evaluate the quality of ranked search results over a set of typical search queries"]
5813#[doc = "&nbsp;\n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n        "]
5814#[cfg(feature = "experimental-apis")]
5815#[derive(Clone, Debug)]
5816pub struct RankEval<'a, 'b, B> {
5817    transport: &'a Transport,
5818    parts: RankEvalParts<'b>,
5819    allow_no_indices: Option<bool>,
5820    body: Option<B>,
5821    error_trace: Option<bool>,
5822    expand_wildcards: Option<&'b [ExpandWildcards]>,
5823    filter_path: Option<&'b [&'b str]>,
5824    headers: HeaderMap,
5825    human: Option<bool>,
5826    ignore_unavailable: Option<bool>,
5827    pretty: Option<bool>,
5828    request_timeout: Option<Duration>,
5829    search_type: Option<SearchType>,
5830    source: Option<&'b str>,
5831}
5832#[cfg(feature = "experimental-apis")]
5833impl<'a, 'b, B> RankEval<'a, 'b, B>
5834where
5835    B: Body,
5836{
5837    #[doc = "Creates a new instance of [RankEval] with the specified API parts"]
5838    pub fn new(transport: &'a Transport, parts: RankEvalParts<'b>) -> Self {
5839        let headers = HeaderMap::new();
5840        RankEval {
5841            transport,
5842            parts,
5843            headers,
5844            allow_no_indices: None,
5845            body: None,
5846            error_trace: None,
5847            expand_wildcards: None,
5848            filter_path: None,
5849            human: None,
5850            ignore_unavailable: None,
5851            pretty: None,
5852            request_timeout: None,
5853            search_type: None,
5854            source: None,
5855        }
5856    }
5857    #[doc = "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)"]
5858    pub fn allow_no_indices(mut self, allow_no_indices: bool) -> Self {
5859        self.allow_no_indices = Some(allow_no_indices);
5860        self
5861    }
5862    #[doc = "The body for the API call"]
5863    pub fn body<T>(self, body: T) -> RankEval<'a, 'b, JsonBody<T>>
5864    where
5865        T: Serialize,
5866    {
5867        RankEval {
5868            transport: self.transport,
5869            parts: self.parts,
5870            body: Some(body.into()),
5871            allow_no_indices: self.allow_no_indices,
5872            error_trace: self.error_trace,
5873            expand_wildcards: self.expand_wildcards,
5874            filter_path: self.filter_path,
5875            headers: self.headers,
5876            human: self.human,
5877            ignore_unavailable: self.ignore_unavailable,
5878            pretty: self.pretty,
5879            request_timeout: self.request_timeout,
5880            search_type: self.search_type,
5881            source: self.source,
5882        }
5883    }
5884    #[doc = "Include the stack trace of returned errors."]
5885    pub fn error_trace(mut self, error_trace: bool) -> Self {
5886        self.error_trace = Some(error_trace);
5887        self
5888    }
5889    #[doc = "Whether to expand wildcard expression to concrete indices that are open, closed or both."]
5890    pub fn expand_wildcards(mut self, expand_wildcards: &'b [ExpandWildcards]) -> Self {
5891        self.expand_wildcards = Some(expand_wildcards);
5892        self
5893    }
5894    #[doc = "A comma-separated list of filters used to reduce the response."]
5895    pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
5896        self.filter_path = Some(filter_path);
5897        self
5898    }
5899    #[doc = "Adds a HTTP header"]
5900    pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
5901        self.headers.insert(key, value);
5902        self
5903    }
5904    #[doc = "Return human readable values for statistics."]
5905    pub fn human(mut self, human: bool) -> Self {
5906        self.human = Some(human);
5907        self
5908    }
5909    #[doc = "Whether specified concrete indices should be ignored when unavailable (missing or closed)"]
5910    pub fn ignore_unavailable(mut self, ignore_unavailable: bool) -> Self {
5911        self.ignore_unavailable = Some(ignore_unavailable);
5912        self
5913    }
5914    #[doc = "Pretty format the returned JSON response."]
5915    pub fn pretty(mut self, pretty: bool) -> Self {
5916        self.pretty = Some(pretty);
5917        self
5918    }
5919    #[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."]
5920    pub fn request_timeout(mut self, timeout: Duration) -> Self {
5921        self.request_timeout = Some(timeout);
5922        self
5923    }
5924    #[doc = "Search operation type"]
5925    pub fn search_type(mut self, search_type: SearchType) -> Self {
5926        self.search_type = Some(search_type);
5927        self
5928    }
5929    #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
5930    pub fn source(mut self, source: &'b str) -> Self {
5931        self.source = Some(source);
5932        self
5933    }
5934    #[doc = "Creates an asynchronous call to the Rank Eval API that can be awaited"]
5935    pub async fn send(self) -> Result<Response, Error> {
5936        let path = self.parts.url();
5937        let method = match self.body {
5938            Some(_) => Method::Post,
5939            None => Method::Get,
5940        };
5941        let headers = self.headers;
5942        let timeout = self.request_timeout;
5943        let query_string = {
5944            #[serde_with::skip_serializing_none]
5945            #[derive(Serialize)]
5946            struct QueryParams<'b> {
5947                allow_no_indices: Option<bool>,
5948                error_trace: Option<bool>,
5949                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
5950                expand_wildcards: Option<&'b [ExpandWildcards]>,
5951                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
5952                filter_path: Option<&'b [&'b str]>,
5953                human: Option<bool>,
5954                ignore_unavailable: Option<bool>,
5955                pretty: Option<bool>,
5956                search_type: Option<SearchType>,
5957                source: Option<&'b str>,
5958            }
5959            let query_params = QueryParams {
5960                allow_no_indices: self.allow_no_indices,
5961                error_trace: self.error_trace,
5962                expand_wildcards: self.expand_wildcards,
5963                filter_path: self.filter_path,
5964                human: self.human,
5965                ignore_unavailable: self.ignore_unavailable,
5966                pretty: self.pretty,
5967                search_type: self.search_type,
5968                source: self.source,
5969            };
5970            Some(query_params)
5971        };
5972        let body = self.body;
5973        let response = self
5974            .transport
5975            .send(method, &path, headers, query_string.as_ref(), body, timeout)
5976            .await?;
5977        Ok(response)
5978    }
5979}
5980#[derive(Debug, Clone, PartialEq, Eq)]
5981#[doc = "API parts for the Reindex API"]
5982pub enum ReindexParts {
5983    #[doc = "No parts"]
5984    None,
5985}
5986impl ReindexParts {
5987    #[doc = "Builds a relative URL path to the Reindex API"]
5988    pub fn url(self) -> Cow<'static, str> {
5989        match self {
5990            ReindexParts::None => "/_reindex".into(),
5991        }
5992    }
5993}
5994#[doc = "Builder for the [Reindex API](https://opensearch.org/docs/)\n\nAllows to copy documents from one index to another, optionally filtering the source\ndocuments by a query, changing the destination index settings, or fetching the\ndocuments from a remote cluster."]
5995#[derive(Clone, Debug)]
5996pub struct Reindex<'a, 'b, B> {
5997    transport: &'a Transport,
5998    parts: ReindexParts,
5999    body: Option<B>,
6000    error_trace: Option<bool>,
6001    filter_path: Option<&'b [&'b str]>,
6002    headers: HeaderMap,
6003    human: Option<bool>,
6004    max_docs: Option<i64>,
6005    pretty: Option<bool>,
6006    refresh: Option<bool>,
6007    request_timeout: Option<Duration>,
6008    requests_per_second: Option<i64>,
6009    scroll: Option<&'b str>,
6010    slices: Option<Slices>,
6011    source: Option<&'b str>,
6012    timeout: Option<&'b str>,
6013    wait_for_active_shards: Option<&'b str>,
6014    wait_for_completion: Option<bool>,
6015}
6016impl<'a, 'b, B> Reindex<'a, 'b, B>
6017where
6018    B: Body,
6019{
6020    #[doc = "Creates a new instance of [Reindex]"]
6021    pub fn new(transport: &'a Transport) -> Self {
6022        let headers = HeaderMap::new();
6023        Reindex {
6024            transport,
6025            parts: ReindexParts::None,
6026            headers,
6027            body: None,
6028            error_trace: None,
6029            filter_path: None,
6030            human: None,
6031            max_docs: None,
6032            pretty: None,
6033            refresh: None,
6034            request_timeout: None,
6035            requests_per_second: None,
6036            scroll: None,
6037            slices: None,
6038            source: None,
6039            timeout: None,
6040            wait_for_active_shards: None,
6041            wait_for_completion: None,
6042        }
6043    }
6044    #[doc = "The body for the API call"]
6045    pub fn body<T>(self, body: T) -> Reindex<'a, 'b, JsonBody<T>>
6046    where
6047        T: Serialize,
6048    {
6049        Reindex {
6050            transport: self.transport,
6051            parts: self.parts,
6052            body: Some(body.into()),
6053            error_trace: self.error_trace,
6054            filter_path: self.filter_path,
6055            headers: self.headers,
6056            human: self.human,
6057            max_docs: self.max_docs,
6058            pretty: self.pretty,
6059            refresh: self.refresh,
6060            request_timeout: self.request_timeout,
6061            requests_per_second: self.requests_per_second,
6062            scroll: self.scroll,
6063            slices: self.slices,
6064            source: self.source,
6065            timeout: self.timeout,
6066            wait_for_active_shards: self.wait_for_active_shards,
6067            wait_for_completion: self.wait_for_completion,
6068        }
6069    }
6070    #[doc = "Include the stack trace of returned errors."]
6071    pub fn error_trace(mut self, error_trace: bool) -> Self {
6072        self.error_trace = Some(error_trace);
6073        self
6074    }
6075    #[doc = "A comma-separated list of filters used to reduce the response."]
6076    pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
6077        self.filter_path = Some(filter_path);
6078        self
6079    }
6080    #[doc = "Adds a HTTP header"]
6081    pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
6082        self.headers.insert(key, value);
6083        self
6084    }
6085    #[doc = "Return human readable values for statistics."]
6086    pub fn human(mut self, human: bool) -> Self {
6087        self.human = Some(human);
6088        self
6089    }
6090    #[doc = "Maximum number of documents to process (default: all documents)"]
6091    pub fn max_docs(mut self, max_docs: i64) -> Self {
6092        self.max_docs = Some(max_docs);
6093        self
6094    }
6095    #[doc = "Pretty format the returned JSON response."]
6096    pub fn pretty(mut self, pretty: bool) -> Self {
6097        self.pretty = Some(pretty);
6098        self
6099    }
6100    #[doc = "Should the affected indexes be refreshed?"]
6101    pub fn refresh(mut self, refresh: bool) -> Self {
6102        self.refresh = Some(refresh);
6103        self
6104    }
6105    #[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."]
6106    pub fn request_timeout(mut self, timeout: Duration) -> Self {
6107        self.request_timeout = Some(timeout);
6108        self
6109    }
6110    #[doc = "The throttle to set on this request in sub-requests per second. -1 means no throttle."]
6111    pub fn requests_per_second(mut self, requests_per_second: i64) -> Self {
6112        self.requests_per_second = Some(requests_per_second);
6113        self
6114    }
6115    #[doc = "Control how long to keep the search context alive"]
6116    pub fn scroll(mut self, scroll: &'b str) -> Self {
6117        self.scroll = Some(scroll);
6118        self
6119    }
6120    #[doc = "The number of slices this task should be divided into. Defaults to 1, meaning the task isn't sliced into subtasks. Can be set to `auto`."]
6121    pub fn slices(mut self, slices: Slices) -> Self {
6122        self.slices = Some(slices);
6123        self
6124    }
6125    #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
6126    pub fn source(mut self, source: &'b str) -> Self {
6127        self.source = Some(source);
6128        self
6129    }
6130    #[doc = "Time each individual bulk request should wait for shards that are unavailable."]
6131    pub fn timeout(mut self, timeout: &'b str) -> Self {
6132        self.timeout = Some(timeout);
6133        self
6134    }
6135    #[doc = "Sets the number of shard copies that must be active before proceeding with the reindex operation. Defaults to 1, meaning the primary shard only. 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)"]
6136    pub fn wait_for_active_shards(mut self, wait_for_active_shards: &'b str) -> Self {
6137        self.wait_for_active_shards = Some(wait_for_active_shards);
6138        self
6139    }
6140    #[doc = "Should the request should block until the reindex is complete."]
6141    pub fn wait_for_completion(mut self, wait_for_completion: bool) -> Self {
6142        self.wait_for_completion = Some(wait_for_completion);
6143        self
6144    }
6145    #[doc = "Creates an asynchronous call to the Reindex API that can be awaited"]
6146    pub async fn send(self) -> Result<Response, Error> {
6147        let path = self.parts.url();
6148        let method = Method::Post;
6149        let headers = self.headers;
6150        let timeout = self.request_timeout;
6151        let query_string = {
6152            #[serde_with::skip_serializing_none]
6153            #[derive(Serialize)]
6154            struct QueryParams<'b> {
6155                error_trace: Option<bool>,
6156                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
6157                filter_path: Option<&'b [&'b str]>,
6158                human: Option<bool>,
6159                max_docs: Option<i64>,
6160                pretty: Option<bool>,
6161                refresh: Option<bool>,
6162                requests_per_second: Option<i64>,
6163                scroll: Option<&'b str>,
6164                slices: Option<Slices>,
6165                source: Option<&'b str>,
6166                timeout: Option<&'b str>,
6167                wait_for_active_shards: Option<&'b str>,
6168                wait_for_completion: Option<bool>,
6169            }
6170            let query_params = QueryParams {
6171                error_trace: self.error_trace,
6172                filter_path: self.filter_path,
6173                human: self.human,
6174                max_docs: self.max_docs,
6175                pretty: self.pretty,
6176                refresh: self.refresh,
6177                requests_per_second: self.requests_per_second,
6178                scroll: self.scroll,
6179                slices: self.slices,
6180                source: self.source,
6181                timeout: self.timeout,
6182                wait_for_active_shards: self.wait_for_active_shards,
6183                wait_for_completion: self.wait_for_completion,
6184            };
6185            Some(query_params)
6186        };
6187        let body = self.body;
6188        let response = self
6189            .transport
6190            .send(method, &path, headers, query_string.as_ref(), body, timeout)
6191            .await?;
6192        Ok(response)
6193    }
6194}
6195#[derive(Debug, Clone, PartialEq, Eq)]
6196#[doc = "API parts for the Reindex Rethrottle API"]
6197pub enum ReindexRethrottleParts<'b> {
6198    #[doc = "TaskId"]
6199    TaskId(&'b str),
6200}
6201impl<'b> ReindexRethrottleParts<'b> {
6202    #[doc = "Builds a relative URL path to the Reindex Rethrottle API"]
6203    pub fn url(self) -> Cow<'static, str> {
6204        match self {
6205            ReindexRethrottleParts::TaskId(task_id) => {
6206                let encoded_task_id: Cow<str> =
6207                    percent_encode(task_id.as_bytes(), PARTS_ENCODED).into();
6208                let mut p = String::with_capacity(22usize + encoded_task_id.len());
6209                p.push_str("/_reindex/");
6210                p.push_str(encoded_task_id.as_ref());
6211                p.push_str("/_rethrottle");
6212                p.into()
6213            }
6214        }
6215    }
6216}
6217#[doc = "Builder for the [Reindex Rethrottle API](https://opensearch.org/docs/)\n\nChanges the number of requests per second for a particular Reindex operation."]
6218#[derive(Clone, Debug)]
6219pub struct ReindexRethrottle<'a, 'b, B> {
6220    transport: &'a Transport,
6221    parts: ReindexRethrottleParts<'b>,
6222    body: Option<B>,
6223    error_trace: Option<bool>,
6224    filter_path: Option<&'b [&'b str]>,
6225    headers: HeaderMap,
6226    human: Option<bool>,
6227    pretty: Option<bool>,
6228    request_timeout: Option<Duration>,
6229    requests_per_second: Option<i64>,
6230    source: Option<&'b str>,
6231}
6232impl<'a, 'b, B> ReindexRethrottle<'a, 'b, B>
6233where
6234    B: Body,
6235{
6236    #[doc = "Creates a new instance of [ReindexRethrottle] with the specified API parts"]
6237    pub fn new(transport: &'a Transport, parts: ReindexRethrottleParts<'b>) -> Self {
6238        let headers = HeaderMap::new();
6239        ReindexRethrottle {
6240            transport,
6241            parts,
6242            headers,
6243            body: None,
6244            error_trace: None,
6245            filter_path: None,
6246            human: None,
6247            pretty: None,
6248            request_timeout: None,
6249            requests_per_second: None,
6250            source: None,
6251        }
6252    }
6253    #[doc = "The body for the API call"]
6254    pub fn body<T>(self, body: T) -> ReindexRethrottle<'a, 'b, JsonBody<T>>
6255    where
6256        T: Serialize,
6257    {
6258        ReindexRethrottle {
6259            transport: self.transport,
6260            parts: self.parts,
6261            body: Some(body.into()),
6262            error_trace: self.error_trace,
6263            filter_path: self.filter_path,
6264            headers: self.headers,
6265            human: self.human,
6266            pretty: self.pretty,
6267            request_timeout: self.request_timeout,
6268            requests_per_second: self.requests_per_second,
6269            source: self.source,
6270        }
6271    }
6272    #[doc = "Include the stack trace of returned errors."]
6273    pub fn error_trace(mut self, error_trace: bool) -> Self {
6274        self.error_trace = Some(error_trace);
6275        self
6276    }
6277    #[doc = "A comma-separated list of filters used to reduce the response."]
6278    pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
6279        self.filter_path = Some(filter_path);
6280        self
6281    }
6282    #[doc = "Adds a HTTP header"]
6283    pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
6284        self.headers.insert(key, value);
6285        self
6286    }
6287    #[doc = "Return human readable values for statistics."]
6288    pub fn human(mut self, human: bool) -> Self {
6289        self.human = Some(human);
6290        self
6291    }
6292    #[doc = "Pretty format the returned JSON response."]
6293    pub fn pretty(mut self, pretty: bool) -> Self {
6294        self.pretty = Some(pretty);
6295        self
6296    }
6297    #[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."]
6298    pub fn request_timeout(mut self, timeout: Duration) -> Self {
6299        self.request_timeout = Some(timeout);
6300        self
6301    }
6302    #[doc = "The throttle to set on this request in floating sub-requests per second. -1 means set no throttle."]
6303    pub fn requests_per_second(mut self, requests_per_second: i64) -> Self {
6304        self.requests_per_second = Some(requests_per_second);
6305        self
6306    }
6307    #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
6308    pub fn source(mut self, source: &'b str) -> Self {
6309        self.source = Some(source);
6310        self
6311    }
6312    #[doc = "Creates an asynchronous call to the Reindex Rethrottle API that can be awaited"]
6313    pub async fn send(self) -> Result<Response, Error> {
6314        let path = self.parts.url();
6315        let method = Method::Post;
6316        let headers = self.headers;
6317        let timeout = self.request_timeout;
6318        let query_string = {
6319            #[serde_with::skip_serializing_none]
6320            #[derive(Serialize)]
6321            struct QueryParams<'b> {
6322                error_trace: Option<bool>,
6323                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
6324                filter_path: Option<&'b [&'b str]>,
6325                human: Option<bool>,
6326                pretty: Option<bool>,
6327                requests_per_second: Option<i64>,
6328                source: Option<&'b str>,
6329            }
6330            let query_params = QueryParams {
6331                error_trace: self.error_trace,
6332                filter_path: self.filter_path,
6333                human: self.human,
6334                pretty: self.pretty,
6335                requests_per_second: self.requests_per_second,
6336                source: self.source,
6337            };
6338            Some(query_params)
6339        };
6340        let body = self.body;
6341        let response = self
6342            .transport
6343            .send(method, &path, headers, query_string.as_ref(), body, timeout)
6344            .await?;
6345        Ok(response)
6346    }
6347}
6348#[derive(Debug, Clone, PartialEq, Eq)]
6349#[doc = "API parts for the Render Search Template API"]
6350pub enum RenderSearchTemplateParts<'b> {
6351    #[doc = "No parts"]
6352    None,
6353    #[doc = "Id"]
6354    Id(&'b str),
6355}
6356impl<'b> RenderSearchTemplateParts<'b> {
6357    #[doc = "Builds a relative URL path to the Render Search Template API"]
6358    pub fn url(self) -> Cow<'static, str> {
6359        match self {
6360            RenderSearchTemplateParts::None => "/_render/template".into(),
6361            RenderSearchTemplateParts::Id(id) => {
6362                let encoded_id: Cow<str> = percent_encode(id.as_bytes(), PARTS_ENCODED).into();
6363                let mut p = String::with_capacity(18usize + encoded_id.len());
6364                p.push_str("/_render/template/");
6365                p.push_str(encoded_id.as_ref());
6366                p.into()
6367            }
6368        }
6369    }
6370}
6371#[doc = "Builder for the [Render Search Template API](https://opensearch.org/docs/)\n\nAllows to use the Mustache language to pre-render a search definition."]
6372#[derive(Clone, Debug)]
6373pub struct RenderSearchTemplate<'a, 'b, B> {
6374    transport: &'a Transport,
6375    parts: RenderSearchTemplateParts<'b>,
6376    body: Option<B>,
6377    error_trace: Option<bool>,
6378    filter_path: Option<&'b [&'b str]>,
6379    headers: HeaderMap,
6380    human: Option<bool>,
6381    pretty: Option<bool>,
6382    request_timeout: Option<Duration>,
6383    source: Option<&'b str>,
6384}
6385impl<'a, 'b, B> RenderSearchTemplate<'a, 'b, B>
6386where
6387    B: Body,
6388{
6389    #[doc = "Creates a new instance of [RenderSearchTemplate] with the specified API parts"]
6390    pub fn new(transport: &'a Transport, parts: RenderSearchTemplateParts<'b>) -> Self {
6391        let headers = HeaderMap::new();
6392        RenderSearchTemplate {
6393            transport,
6394            parts,
6395            headers,
6396            body: None,
6397            error_trace: None,
6398            filter_path: None,
6399            human: None,
6400            pretty: None,
6401            request_timeout: None,
6402            source: None,
6403        }
6404    }
6405    #[doc = "The body for the API call"]
6406    pub fn body<T>(self, body: T) -> RenderSearchTemplate<'a, 'b, JsonBody<T>>
6407    where
6408        T: Serialize,
6409    {
6410        RenderSearchTemplate {
6411            transport: self.transport,
6412            parts: self.parts,
6413            body: Some(body.into()),
6414            error_trace: self.error_trace,
6415            filter_path: self.filter_path,
6416            headers: self.headers,
6417            human: self.human,
6418            pretty: self.pretty,
6419            request_timeout: self.request_timeout,
6420            source: self.source,
6421        }
6422    }
6423    #[doc = "Include the stack trace of returned errors."]
6424    pub fn error_trace(mut self, error_trace: bool) -> Self {
6425        self.error_trace = Some(error_trace);
6426        self
6427    }
6428    #[doc = "A comma-separated list of filters used to reduce the response."]
6429    pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
6430        self.filter_path = Some(filter_path);
6431        self
6432    }
6433    #[doc = "Adds a HTTP header"]
6434    pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
6435        self.headers.insert(key, value);
6436        self
6437    }
6438    #[doc = "Return human readable values for statistics."]
6439    pub fn human(mut self, human: bool) -> Self {
6440        self.human = Some(human);
6441        self
6442    }
6443    #[doc = "Pretty format the returned JSON response."]
6444    pub fn pretty(mut self, pretty: bool) -> Self {
6445        self.pretty = Some(pretty);
6446        self
6447    }
6448    #[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."]
6449    pub fn request_timeout(mut self, timeout: Duration) -> Self {
6450        self.request_timeout = Some(timeout);
6451        self
6452    }
6453    #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
6454    pub fn source(mut self, source: &'b str) -> Self {
6455        self.source = Some(source);
6456        self
6457    }
6458    #[doc = "Creates an asynchronous call to the Render Search Template API that can be awaited"]
6459    pub async fn send(self) -> Result<Response, Error> {
6460        let path = self.parts.url();
6461        let method = match self.body {
6462            Some(_) => Method::Post,
6463            None => Method::Get,
6464        };
6465        let headers = self.headers;
6466        let timeout = self.request_timeout;
6467        let query_string = {
6468            #[serde_with::skip_serializing_none]
6469            #[derive(Serialize)]
6470            struct QueryParams<'b> {
6471                error_trace: Option<bool>,
6472                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
6473                filter_path: Option<&'b [&'b str]>,
6474                human: Option<bool>,
6475                pretty: Option<bool>,
6476                source: Option<&'b str>,
6477            }
6478            let query_params = QueryParams {
6479                error_trace: self.error_trace,
6480                filter_path: self.filter_path,
6481                human: self.human,
6482                pretty: self.pretty,
6483                source: self.source,
6484            };
6485            Some(query_params)
6486        };
6487        let body = self.body;
6488        let response = self
6489            .transport
6490            .send(method, &path, headers, query_string.as_ref(), body, timeout)
6491            .await?;
6492        Ok(response)
6493    }
6494}
6495#[cfg(feature = "experimental-apis")]
6496#[derive(Debug, Clone, PartialEq, Eq)]
6497#[doc = "API parts for the Scripts Painless Execute API"]
6498pub enum ScriptsPainlessExecuteParts {
6499    #[doc = "No parts"]
6500    None,
6501}
6502#[cfg(feature = "experimental-apis")]
6503impl ScriptsPainlessExecuteParts {
6504    #[doc = "Builds a relative URL path to the Scripts Painless Execute API"]
6505    pub fn url(self) -> Cow<'static, str> {
6506        match self {
6507            ScriptsPainlessExecuteParts::None => "/_scripts/painless/_execute".into(),
6508        }
6509    }
6510}
6511#[doc = "Builder for the [Scripts Painless Execute API](https://opensearch.org/docs/)\n\nAllows an arbitrary script to be executed and a result to be returned"]
6512#[doc = "&nbsp;\n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n        "]
6513#[cfg(feature = "experimental-apis")]
6514#[derive(Clone, Debug)]
6515pub struct ScriptsPainlessExecute<'a, 'b, B> {
6516    transport: &'a Transport,
6517    parts: ScriptsPainlessExecuteParts,
6518    body: Option<B>,
6519    error_trace: Option<bool>,
6520    filter_path: Option<&'b [&'b str]>,
6521    headers: HeaderMap,
6522    human: Option<bool>,
6523    pretty: Option<bool>,
6524    request_timeout: Option<Duration>,
6525    source: Option<&'b str>,
6526}
6527#[cfg(feature = "experimental-apis")]
6528impl<'a, 'b, B> ScriptsPainlessExecute<'a, 'b, B>
6529where
6530    B: Body,
6531{
6532    #[doc = "Creates a new instance of [ScriptsPainlessExecute]"]
6533    pub fn new(transport: &'a Transport) -> Self {
6534        let headers = HeaderMap::new();
6535        ScriptsPainlessExecute {
6536            transport,
6537            parts: ScriptsPainlessExecuteParts::None,
6538            headers,
6539            body: None,
6540            error_trace: None,
6541            filter_path: None,
6542            human: None,
6543            pretty: None,
6544            request_timeout: None,
6545            source: None,
6546        }
6547    }
6548    #[doc = "The body for the API call"]
6549    pub fn body<T>(self, body: T) -> ScriptsPainlessExecute<'a, 'b, JsonBody<T>>
6550    where
6551        T: Serialize,
6552    {
6553        ScriptsPainlessExecute {
6554            transport: self.transport,
6555            parts: self.parts,
6556            body: Some(body.into()),
6557            error_trace: self.error_trace,
6558            filter_path: self.filter_path,
6559            headers: self.headers,
6560            human: self.human,
6561            pretty: self.pretty,
6562            request_timeout: self.request_timeout,
6563            source: self.source,
6564        }
6565    }
6566    #[doc = "Include the stack trace of returned errors."]
6567    pub fn error_trace(mut self, error_trace: bool) -> Self {
6568        self.error_trace = Some(error_trace);
6569        self
6570    }
6571    #[doc = "A comma-separated list of filters used to reduce the response."]
6572    pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
6573        self.filter_path = Some(filter_path);
6574        self
6575    }
6576    #[doc = "Adds a HTTP header"]
6577    pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
6578        self.headers.insert(key, value);
6579        self
6580    }
6581    #[doc = "Return human readable values for statistics."]
6582    pub fn human(mut self, human: bool) -> Self {
6583        self.human = Some(human);
6584        self
6585    }
6586    #[doc = "Pretty format the returned JSON response."]
6587    pub fn pretty(mut self, pretty: bool) -> Self {
6588        self.pretty = Some(pretty);
6589        self
6590    }
6591    #[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."]
6592    pub fn request_timeout(mut self, timeout: Duration) -> Self {
6593        self.request_timeout = Some(timeout);
6594        self
6595    }
6596    #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
6597    pub fn source(mut self, source: &'b str) -> Self {
6598        self.source = Some(source);
6599        self
6600    }
6601    #[doc = "Creates an asynchronous call to the Scripts Painless Execute API that can be awaited"]
6602    pub async fn send(self) -> Result<Response, Error> {
6603        let path = self.parts.url();
6604        let method = match self.body {
6605            Some(_) => Method::Post,
6606            None => Method::Get,
6607        };
6608        let headers = self.headers;
6609        let timeout = self.request_timeout;
6610        let query_string = {
6611            #[serde_with::skip_serializing_none]
6612            #[derive(Serialize)]
6613            struct QueryParams<'b> {
6614                error_trace: Option<bool>,
6615                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
6616                filter_path: Option<&'b [&'b str]>,
6617                human: Option<bool>,
6618                pretty: Option<bool>,
6619                source: Option<&'b str>,
6620            }
6621            let query_params = QueryParams {
6622                error_trace: self.error_trace,
6623                filter_path: self.filter_path,
6624                human: self.human,
6625                pretty: self.pretty,
6626                source: self.source,
6627            };
6628            Some(query_params)
6629        };
6630        let body = self.body;
6631        let response = self
6632            .transport
6633            .send(method, &path, headers, query_string.as_ref(), body, timeout)
6634            .await?;
6635        Ok(response)
6636    }
6637}
6638#[derive(Debug, Clone, PartialEq, Eq)]
6639#[doc = "API parts for the Scroll API"]
6640pub enum ScrollParts<'b> {
6641    #[doc = "No parts"]
6642    None,
6643    #[doc = "ScrollId"]
6644    ScrollId(&'b str),
6645}
6646impl<'b> ScrollParts<'b> {
6647    #[doc = "Builds a relative URL path to the Scroll API"]
6648    pub fn url(self) -> Cow<'static, str> {
6649        match self {
6650            ScrollParts::None => "/_search/scroll".into(),
6651            ScrollParts::ScrollId(scroll_id) => {
6652                let encoded_scroll_id: Cow<str> =
6653                    percent_encode(scroll_id.as_bytes(), PARTS_ENCODED).into();
6654                let mut p = String::with_capacity(16usize + encoded_scroll_id.len());
6655                p.push_str("/_search/scroll/");
6656                p.push_str(encoded_scroll_id.as_ref());
6657                p.into()
6658            }
6659        }
6660    }
6661}
6662#[doc = "Builder for the [Scroll API](https://opensearch.org/docs/)\n\nAllows to retrieve a large numbers of results from a single search request."]
6663#[derive(Clone, Debug)]
6664pub struct Scroll<'a, 'b, B> {
6665    transport: &'a Transport,
6666    parts: ScrollParts<'b>,
6667    body: Option<B>,
6668    error_trace: Option<bool>,
6669    filter_path: Option<&'b [&'b str]>,
6670    headers: HeaderMap,
6671    human: Option<bool>,
6672    pretty: Option<bool>,
6673    request_timeout: Option<Duration>,
6674    rest_total_hits_as_int: Option<bool>,
6675    scroll: Option<&'b str>,
6676    scroll_id: Option<&'b str>,
6677    source: Option<&'b str>,
6678}
6679impl<'a, 'b, B> Scroll<'a, 'b, B>
6680where
6681    B: Body,
6682{
6683    #[doc = "Creates a new instance of [Scroll] with the specified API parts"]
6684    pub fn new(transport: &'a Transport, parts: ScrollParts<'b>) -> Self {
6685        let headers = HeaderMap::new();
6686        Scroll {
6687            transport,
6688            parts,
6689            headers,
6690            body: None,
6691            error_trace: None,
6692            filter_path: None,
6693            human: None,
6694            pretty: None,
6695            request_timeout: None,
6696            rest_total_hits_as_int: None,
6697            scroll: None,
6698            scroll_id: None,
6699            source: None,
6700        }
6701    }
6702    #[doc = "The body for the API call"]
6703    pub fn body<T>(self, body: T) -> Scroll<'a, 'b, JsonBody<T>>
6704    where
6705        T: Serialize,
6706    {
6707        Scroll {
6708            transport: self.transport,
6709            parts: self.parts,
6710            body: Some(body.into()),
6711            error_trace: self.error_trace,
6712            filter_path: self.filter_path,
6713            headers: self.headers,
6714            human: self.human,
6715            pretty: self.pretty,
6716            request_timeout: self.request_timeout,
6717            rest_total_hits_as_int: self.rest_total_hits_as_int,
6718            scroll: self.scroll,
6719            scroll_id: self.scroll_id,
6720            source: self.source,
6721        }
6722    }
6723    #[doc = "Include the stack trace of returned errors."]
6724    pub fn error_trace(mut self, error_trace: bool) -> Self {
6725        self.error_trace = Some(error_trace);
6726        self
6727    }
6728    #[doc = "A comma-separated list of filters used to reduce the response."]
6729    pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
6730        self.filter_path = Some(filter_path);
6731        self
6732    }
6733    #[doc = "Adds a HTTP header"]
6734    pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
6735        self.headers.insert(key, value);
6736        self
6737    }
6738    #[doc = "Return human readable values for statistics."]
6739    pub fn human(mut self, human: bool) -> Self {
6740        self.human = Some(human);
6741        self
6742    }
6743    #[doc = "Pretty format the returned JSON response."]
6744    pub fn pretty(mut self, pretty: bool) -> Self {
6745        self.pretty = Some(pretty);
6746        self
6747    }
6748    #[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."]
6749    pub fn request_timeout(mut self, timeout: Duration) -> Self {
6750        self.request_timeout = Some(timeout);
6751        self
6752    }
6753    #[doc = "Indicates whether hits.total should be rendered as an integer or an object in the rest search response"]
6754    pub fn rest_total_hits_as_int(mut self, rest_total_hits_as_int: bool) -> Self {
6755        self.rest_total_hits_as_int = Some(rest_total_hits_as_int);
6756        self
6757    }
6758    #[doc = "Specify how long a consistent view of the index should be maintained for scrolled search"]
6759    pub fn scroll(mut self, scroll: &'b str) -> Self {
6760        self.scroll = Some(scroll);
6761        self
6762    }
6763    #[doc = "The scroll ID for scrolled search"]
6764    pub fn scroll_id(mut self, scroll_id: &'b str) -> Self {
6765        self.scroll_id = Some(scroll_id);
6766        self
6767    }
6768    #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
6769    pub fn source(mut self, source: &'b str) -> Self {
6770        self.source = Some(source);
6771        self
6772    }
6773    #[doc = "Creates an asynchronous call to the Scroll API that can be awaited"]
6774    pub async fn send(self) -> Result<Response, Error> {
6775        let path = self.parts.url();
6776        let method = match self.body {
6777            Some(_) => Method::Post,
6778            None => Method::Get,
6779        };
6780        let headers = self.headers;
6781        let timeout = self.request_timeout;
6782        let query_string = {
6783            #[serde_with::skip_serializing_none]
6784            #[derive(Serialize)]
6785            struct QueryParams<'b> {
6786                error_trace: Option<bool>,
6787                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
6788                filter_path: Option<&'b [&'b str]>,
6789                human: Option<bool>,
6790                pretty: Option<bool>,
6791                rest_total_hits_as_int: Option<bool>,
6792                scroll: Option<&'b str>,
6793                scroll_id: Option<&'b str>,
6794                source: Option<&'b str>,
6795            }
6796            let query_params = QueryParams {
6797                error_trace: self.error_trace,
6798                filter_path: self.filter_path,
6799                human: self.human,
6800                pretty: self.pretty,
6801                rest_total_hits_as_int: self.rest_total_hits_as_int,
6802                scroll: self.scroll,
6803                scroll_id: self.scroll_id,
6804                source: self.source,
6805            };
6806            Some(query_params)
6807        };
6808        let body = self.body;
6809        let response = self
6810            .transport
6811            .send(method, &path, headers, query_string.as_ref(), body, timeout)
6812            .await?;
6813        Ok(response)
6814    }
6815}
6816#[derive(Debug, Clone, PartialEq, Eq)]
6817#[doc = "API parts for the Search API"]
6818pub enum SearchParts<'b> {
6819    #[doc = "No parts"]
6820    None,
6821    #[doc = "Index"]
6822    Index(&'b [&'b str]),
6823}
6824impl<'b> SearchParts<'b> {
6825    #[doc = "Builds a relative URL path to the Search API"]
6826    pub fn url(self) -> Cow<'static, str> {
6827        match self {
6828            SearchParts::None => "/_search".into(),
6829            SearchParts::Index(index) => {
6830                let index_str = index.join(",");
6831                let encoded_index: Cow<str> =
6832                    percent_encode(index_str.as_bytes(), PARTS_ENCODED).into();
6833                let mut p = String::with_capacity(9usize + encoded_index.len());
6834                p.push('/');
6835                p.push_str(encoded_index.as_ref());
6836                p.push_str("/_search");
6837                p.into()
6838            }
6839        }
6840    }
6841}
6842#[doc = "Builder for the [Search API](https://opensearch.org/docs/)\n\nReturns results matching a query."]
6843#[derive(Clone, Debug)]
6844pub struct Search<'a, 'b, B> {
6845    transport: &'a Transport,
6846    parts: SearchParts<'b>,
6847    _source: Option<&'b [&'b str]>,
6848    _source_excludes: Option<&'b [&'b str]>,
6849    _source_includes: Option<&'b [&'b str]>,
6850    allow_no_indices: Option<bool>,
6851    allow_partial_search_results: Option<bool>,
6852    analyze_wildcard: Option<bool>,
6853    analyzer: Option<&'b str>,
6854    batched_reduce_size: Option<i64>,
6855    body: Option<B>,
6856    ccs_minimize_roundtrips: Option<bool>,
6857    default_operator: Option<DefaultOperator>,
6858    df: Option<&'b str>,
6859    docvalue_fields: Option<&'b [&'b str]>,
6860    error_trace: Option<bool>,
6861    expand_wildcards: Option<&'b [ExpandWildcards]>,
6862    explain: Option<bool>,
6863    filter_path: Option<&'b [&'b str]>,
6864    from: Option<i64>,
6865    headers: HeaderMap,
6866    human: Option<bool>,
6867    ignore_throttled: Option<bool>,
6868    ignore_unavailable: Option<bool>,
6869    lenient: Option<bool>,
6870    max_concurrent_shard_requests: Option<i64>,
6871    min_compatible_shard_node: Option<&'b str>,
6872    pre_filter_shard_size: Option<i64>,
6873    preference: Option<&'b str>,
6874    pretty: Option<bool>,
6875    q: Option<&'b str>,
6876    request_cache: Option<bool>,
6877    request_timeout: Option<Duration>,
6878    rest_total_hits_as_int: Option<bool>,
6879    routing: Option<&'b [&'b str]>,
6880    scroll: Option<&'b str>,
6881    search_type: Option<SearchType>,
6882    seq_no_primary_term: Option<bool>,
6883    size: Option<i64>,
6884    sort: Option<&'b [&'b str]>,
6885    source: Option<&'b str>,
6886    stats: Option<&'b [&'b str]>,
6887    stored_fields: Option<&'b [&'b str]>,
6888    suggest_field: Option<&'b str>,
6889    suggest_mode: Option<SuggestMode>,
6890    suggest_size: Option<i64>,
6891    suggest_text: Option<&'b str>,
6892    terminate_after: Option<i64>,
6893    timeout: Option<&'b str>,
6894    track_scores: Option<bool>,
6895    track_total_hits: Option<TrackTotalHits>,
6896    typed_keys: Option<bool>,
6897    version: Option<bool>,
6898}
6899impl<'a, 'b, B> Search<'a, 'b, B>
6900where
6901    B: Body,
6902{
6903    #[doc = "Creates a new instance of [Search] with the specified API parts"]
6904    pub fn new(transport: &'a Transport, parts: SearchParts<'b>) -> Self {
6905        let headers = HeaderMap::new();
6906        Search {
6907            transport,
6908            parts,
6909            headers,
6910            _source: None,
6911            _source_excludes: None,
6912            _source_includes: None,
6913            allow_no_indices: None,
6914            allow_partial_search_results: None,
6915            analyze_wildcard: None,
6916            analyzer: None,
6917            batched_reduce_size: None,
6918            body: None,
6919            ccs_minimize_roundtrips: None,
6920            default_operator: None,
6921            df: None,
6922            docvalue_fields: None,
6923            error_trace: None,
6924            expand_wildcards: None,
6925            explain: None,
6926            filter_path: None,
6927            from: None,
6928            human: None,
6929            ignore_throttled: None,
6930            ignore_unavailable: None,
6931            lenient: None,
6932            max_concurrent_shard_requests: None,
6933            min_compatible_shard_node: None,
6934            pre_filter_shard_size: None,
6935            preference: None,
6936            pretty: None,
6937            q: None,
6938            request_cache: None,
6939            request_timeout: None,
6940            rest_total_hits_as_int: None,
6941            routing: None,
6942            scroll: None,
6943            search_type: None,
6944            seq_no_primary_term: None,
6945            size: None,
6946            sort: None,
6947            source: None,
6948            stats: None,
6949            stored_fields: None,
6950            suggest_field: None,
6951            suggest_mode: None,
6952            suggest_size: None,
6953            suggest_text: None,
6954            terminate_after: None,
6955            timeout: None,
6956            track_scores: None,
6957            track_total_hits: None,
6958            typed_keys: None,
6959            version: None,
6960        }
6961    }
6962    #[doc = "True or false to return the _source field or not, or a list of fields to return"]
6963    pub fn _source(mut self, _source: &'b [&'b str]) -> Self {
6964        self._source = Some(_source);
6965        self
6966    }
6967    #[doc = "A list of fields to exclude from the returned _source field"]
6968    pub fn _source_excludes(mut self, _source_excludes: &'b [&'b str]) -> Self {
6969        self._source_excludes = Some(_source_excludes);
6970        self
6971    }
6972    #[doc = "A list of fields to extract and return from the _source field"]
6973    pub fn _source_includes(mut self, _source_includes: &'b [&'b str]) -> Self {
6974        self._source_includes = Some(_source_includes);
6975        self
6976    }
6977    #[doc = "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)"]
6978    pub fn allow_no_indices(mut self, allow_no_indices: bool) -> Self {
6979        self.allow_no_indices = Some(allow_no_indices);
6980        self
6981    }
6982    #[doc = "Indicate if an error should be returned if there is a partial search failure or timeout"]
6983    pub fn allow_partial_search_results(mut self, allow_partial_search_results: bool) -> Self {
6984        self.allow_partial_search_results = Some(allow_partial_search_results);
6985        self
6986    }
6987    #[doc = "Specify whether wildcard and prefix queries should be analyzed (default: false)"]
6988    pub fn analyze_wildcard(mut self, analyze_wildcard: bool) -> Self {
6989        self.analyze_wildcard = Some(analyze_wildcard);
6990        self
6991    }
6992    #[doc = "The analyzer to use for the query string"]
6993    pub fn analyzer(mut self, analyzer: &'b str) -> Self {
6994        self.analyzer = Some(analyzer);
6995        self
6996    }
6997    #[doc = "The number of shard results that should be reduced at once on the coordinating node. This value should be used as a protection mechanism to reduce the memory overhead per search request if the potential number of shards in the request can be large."]
6998    pub fn batched_reduce_size(mut self, batched_reduce_size: i64) -> Self {
6999        self.batched_reduce_size = Some(batched_reduce_size);
7000        self
7001    }
7002    #[doc = "The body for the API call"]
7003    pub fn body<T>(self, body: T) -> Search<'a, 'b, JsonBody<T>>
7004    where
7005        T: Serialize,
7006    {
7007        Search {
7008            transport: self.transport,
7009            parts: self.parts,
7010            body: Some(body.into()),
7011            _source: self._source,
7012            _source_excludes: self._source_excludes,
7013            _source_includes: self._source_includes,
7014            allow_no_indices: self.allow_no_indices,
7015            allow_partial_search_results: self.allow_partial_search_results,
7016            analyze_wildcard: self.analyze_wildcard,
7017            analyzer: self.analyzer,
7018            batched_reduce_size: self.batched_reduce_size,
7019            ccs_minimize_roundtrips: self.ccs_minimize_roundtrips,
7020            default_operator: self.default_operator,
7021            df: self.df,
7022            docvalue_fields: self.docvalue_fields,
7023            error_trace: self.error_trace,
7024            expand_wildcards: self.expand_wildcards,
7025            explain: self.explain,
7026            filter_path: self.filter_path,
7027            from: self.from,
7028            headers: self.headers,
7029            human: self.human,
7030            ignore_throttled: self.ignore_throttled,
7031            ignore_unavailable: self.ignore_unavailable,
7032            lenient: self.lenient,
7033            max_concurrent_shard_requests: self.max_concurrent_shard_requests,
7034            min_compatible_shard_node: self.min_compatible_shard_node,
7035            pre_filter_shard_size: self.pre_filter_shard_size,
7036            preference: self.preference,
7037            pretty: self.pretty,
7038            q: self.q,
7039            request_cache: self.request_cache,
7040            request_timeout: self.request_timeout,
7041            rest_total_hits_as_int: self.rest_total_hits_as_int,
7042            routing: self.routing,
7043            scroll: self.scroll,
7044            search_type: self.search_type,
7045            seq_no_primary_term: self.seq_no_primary_term,
7046            size: self.size,
7047            sort: self.sort,
7048            source: self.source,
7049            stats: self.stats,
7050            stored_fields: self.stored_fields,
7051            suggest_field: self.suggest_field,
7052            suggest_mode: self.suggest_mode,
7053            suggest_size: self.suggest_size,
7054            suggest_text: self.suggest_text,
7055            terminate_after: self.terminate_after,
7056            timeout: self.timeout,
7057            track_scores: self.track_scores,
7058            track_total_hits: self.track_total_hits,
7059            typed_keys: self.typed_keys,
7060            version: self.version,
7061        }
7062    }
7063    #[doc = "Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution"]
7064    pub fn ccs_minimize_roundtrips(mut self, ccs_minimize_roundtrips: bool) -> Self {
7065        self.ccs_minimize_roundtrips = Some(ccs_minimize_roundtrips);
7066        self
7067    }
7068    #[doc = "The default operator for query string query (AND or OR)"]
7069    pub fn default_operator(mut self, default_operator: DefaultOperator) -> Self {
7070        self.default_operator = Some(default_operator);
7071        self
7072    }
7073    #[doc = "The field to use as default where no field prefix is given in the query string"]
7074    pub fn df(mut self, df: &'b str) -> Self {
7075        self.df = Some(df);
7076        self
7077    }
7078    #[doc = "A comma-separated list of fields to return as the docvalue representation of a field for each hit"]
7079    pub fn docvalue_fields(mut self, docvalue_fields: &'b [&'b str]) -> Self {
7080        self.docvalue_fields = Some(docvalue_fields);
7081        self
7082    }
7083    #[doc = "Include the stack trace of returned errors."]
7084    pub fn error_trace(mut self, error_trace: bool) -> Self {
7085        self.error_trace = Some(error_trace);
7086        self
7087    }
7088    #[doc = "Whether to expand wildcard expression to concrete indices that are open, closed or both."]
7089    pub fn expand_wildcards(mut self, expand_wildcards: &'b [ExpandWildcards]) -> Self {
7090        self.expand_wildcards = Some(expand_wildcards);
7091        self
7092    }
7093    #[doc = "Specify whether to return detailed information about score computation as part of a hit"]
7094    pub fn explain(mut self, explain: bool) -> Self {
7095        self.explain = Some(explain);
7096        self
7097    }
7098    #[doc = "A comma-separated list of filters used to reduce the response."]
7099    pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
7100        self.filter_path = Some(filter_path);
7101        self
7102    }
7103    #[doc = "Starting offset (default: 0)"]
7104    pub fn from(mut self, from: i64) -> Self {
7105        self.from = Some(from);
7106        self
7107    }
7108    #[doc = "Adds a HTTP header"]
7109    pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
7110        self.headers.insert(key, value);
7111        self
7112    }
7113    #[doc = "Return human readable values for statistics."]
7114    pub fn human(mut self, human: bool) -> Self {
7115        self.human = Some(human);
7116        self
7117    }
7118    #[doc = "Whether specified concrete, expanded or aliased indices should be ignored when throttled"]
7119    pub fn ignore_throttled(mut self, ignore_throttled: bool) -> Self {
7120        self.ignore_throttled = Some(ignore_throttled);
7121        self
7122    }
7123    #[doc = "Whether specified concrete indices should be ignored when unavailable (missing or closed)"]
7124    pub fn ignore_unavailable(mut self, ignore_unavailable: bool) -> Self {
7125        self.ignore_unavailable = Some(ignore_unavailable);
7126        self
7127    }
7128    #[doc = "Specify whether format-based query failures (such as providing text to a numeric field) should be ignored"]
7129    pub fn lenient(mut self, lenient: bool) -> Self {
7130        self.lenient = Some(lenient);
7131        self
7132    }
7133    #[doc = "The number of concurrent shard requests per node this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests"]
7134    pub fn max_concurrent_shard_requests(mut self, max_concurrent_shard_requests: i64) -> Self {
7135        self.max_concurrent_shard_requests = Some(max_concurrent_shard_requests);
7136        self
7137    }
7138    #[doc = "The minimum compatible version that all shards involved in search should have for this request to be successful"]
7139    pub fn min_compatible_shard_node(mut self, min_compatible_shard_node: &'b str) -> Self {
7140        self.min_compatible_shard_node = Some(min_compatible_shard_node);
7141        self
7142    }
7143    #[doc = "A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the\u{a0}number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on its rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint."]
7144    pub fn pre_filter_shard_size(mut self, pre_filter_shard_size: i64) -> Self {
7145        self.pre_filter_shard_size = Some(pre_filter_shard_size);
7146        self
7147    }
7148    #[doc = "Specify the node or shard the operation should be performed on (default: random)"]
7149    pub fn preference(mut self, preference: &'b str) -> Self {
7150        self.preference = Some(preference);
7151        self
7152    }
7153    #[doc = "Pretty format the returned JSON response."]
7154    pub fn pretty(mut self, pretty: bool) -> Self {
7155        self.pretty = Some(pretty);
7156        self
7157    }
7158    #[doc = "Query in the Lucene query string syntax"]
7159    pub fn q(mut self, q: &'b str) -> Self {
7160        self.q = Some(q);
7161        self
7162    }
7163    #[doc = "Specify if request cache should be used for this request or not, defaults to index level setting"]
7164    pub fn request_cache(mut self, request_cache: bool) -> Self {
7165        self.request_cache = Some(request_cache);
7166        self
7167    }
7168    #[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."]
7169    pub fn request_timeout(mut self, timeout: Duration) -> Self {
7170        self.request_timeout = Some(timeout);
7171        self
7172    }
7173    #[doc = "Indicates whether hits.total should be rendered as an integer or an object in the rest search response"]
7174    pub fn rest_total_hits_as_int(mut self, rest_total_hits_as_int: bool) -> Self {
7175        self.rest_total_hits_as_int = Some(rest_total_hits_as_int);
7176        self
7177    }
7178    #[doc = "A comma-separated list of specific routing values"]
7179    pub fn routing(mut self, routing: &'b [&'b str]) -> Self {
7180        self.routing = Some(routing);
7181        self
7182    }
7183    #[doc = "Specify how long a consistent view of the index should be maintained for scrolled search"]
7184    pub fn scroll(mut self, scroll: &'b str) -> Self {
7185        self.scroll = Some(scroll);
7186        self
7187    }
7188    #[doc = "Search operation type"]
7189    pub fn search_type(mut self, search_type: SearchType) -> Self {
7190        self.search_type = Some(search_type);
7191        self
7192    }
7193    #[doc = "Specify whether to return sequence number and primary term of the last modification of each hit"]
7194    pub fn seq_no_primary_term(mut self, seq_no_primary_term: bool) -> Self {
7195        self.seq_no_primary_term = Some(seq_no_primary_term);
7196        self
7197    }
7198    #[doc = "Number of hits to return (default: 10)"]
7199    pub fn size(mut self, size: i64) -> Self {
7200        self.size = Some(size);
7201        self
7202    }
7203    #[doc = "A comma-separated list of &lt;field&gt;:&lt;direction&gt; pairs"]
7204    pub fn sort(mut self, sort: &'b [&'b str]) -> Self {
7205        self.sort = Some(sort);
7206        self
7207    }
7208    #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
7209    pub fn source(mut self, source: &'b str) -> Self {
7210        self.source = Some(source);
7211        self
7212    }
7213    #[doc = "Specific 'tag' of the request for logging and statistical purposes"]
7214    pub fn stats(mut self, stats: &'b [&'b str]) -> Self {
7215        self.stats = Some(stats);
7216        self
7217    }
7218    #[doc = "A comma-separated list of stored fields to return as part of a hit"]
7219    pub fn stored_fields(mut self, stored_fields: &'b [&'b str]) -> Self {
7220        self.stored_fields = Some(stored_fields);
7221        self
7222    }
7223    #[doc = "Specify which field to use for suggestions"]
7224    pub fn suggest_field(mut self, suggest_field: &'b str) -> Self {
7225        self.suggest_field = Some(suggest_field);
7226        self
7227    }
7228    #[doc = "Specify suggest mode"]
7229    pub fn suggest_mode(mut self, suggest_mode: SuggestMode) -> Self {
7230        self.suggest_mode = Some(suggest_mode);
7231        self
7232    }
7233    #[doc = "How many suggestions to return in response"]
7234    pub fn suggest_size(mut self, suggest_size: i64) -> Self {
7235        self.suggest_size = Some(suggest_size);
7236        self
7237    }
7238    #[doc = "The source text for which the suggestions should be returned"]
7239    pub fn suggest_text(mut self, suggest_text: &'b str) -> Self {
7240        self.suggest_text = Some(suggest_text);
7241        self
7242    }
7243    #[doc = "The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early."]
7244    pub fn terminate_after(mut self, terminate_after: i64) -> Self {
7245        self.terminate_after = Some(terminate_after);
7246        self
7247    }
7248    #[doc = "Explicit operation timeout"]
7249    pub fn timeout(mut self, timeout: &'b str) -> Self {
7250        self.timeout = Some(timeout);
7251        self
7252    }
7253    #[doc = "Whether to calculate and return scores even if they are not used for sorting"]
7254    pub fn track_scores(mut self, track_scores: bool) -> Self {
7255        self.track_scores = Some(track_scores);
7256        self
7257    }
7258    #[doc = "Indicate if the number of documents that match the query should be tracked"]
7259    pub fn track_total_hits<T: Into<TrackTotalHits>>(mut self, track_total_hits: T) -> Self {
7260        self.track_total_hits = Some(track_total_hits.into());
7261        self
7262    }
7263    #[doc = "Specify whether aggregation and suggester names should be prefixed by their respective types in the response"]
7264    pub fn typed_keys(mut self, typed_keys: bool) -> Self {
7265        self.typed_keys = Some(typed_keys);
7266        self
7267    }
7268    #[doc = "Specify whether to return document version as part of a hit"]
7269    pub fn version(mut self, version: bool) -> Self {
7270        self.version = Some(version);
7271        self
7272    }
7273    #[doc = "Creates an asynchronous call to the Search API that can be awaited"]
7274    pub async fn send(self) -> Result<Response, Error> {
7275        let path = self.parts.url();
7276        let method = match self.body {
7277            Some(_) => Method::Post,
7278            None => Method::Get,
7279        };
7280        let headers = self.headers;
7281        let timeout = self.request_timeout;
7282        let query_string = {
7283            #[serde_with::skip_serializing_none]
7284            #[derive(Serialize)]
7285            struct QueryParams<'b> {
7286                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
7287                _source: Option<&'b [&'b str]>,
7288                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
7289                _source_excludes: Option<&'b [&'b str]>,
7290                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
7291                _source_includes: Option<&'b [&'b str]>,
7292                allow_no_indices: Option<bool>,
7293                allow_partial_search_results: Option<bool>,
7294                analyze_wildcard: Option<bool>,
7295                analyzer: Option<&'b str>,
7296                batched_reduce_size: Option<i64>,
7297                ccs_minimize_roundtrips: Option<bool>,
7298                default_operator: Option<DefaultOperator>,
7299                df: Option<&'b str>,
7300                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
7301                docvalue_fields: Option<&'b [&'b str]>,
7302                error_trace: Option<bool>,
7303                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
7304                expand_wildcards: Option<&'b [ExpandWildcards]>,
7305                explain: Option<bool>,
7306                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
7307                filter_path: Option<&'b [&'b str]>,
7308                from: Option<i64>,
7309                human: Option<bool>,
7310                ignore_throttled: Option<bool>,
7311                ignore_unavailable: Option<bool>,
7312                lenient: Option<bool>,
7313                max_concurrent_shard_requests: Option<i64>,
7314                min_compatible_shard_node: Option<&'b str>,
7315                pre_filter_shard_size: Option<i64>,
7316                preference: Option<&'b str>,
7317                pretty: Option<bool>,
7318                q: Option<&'b str>,
7319                request_cache: Option<bool>,
7320                rest_total_hits_as_int: Option<bool>,
7321                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
7322                routing: Option<&'b [&'b str]>,
7323                scroll: Option<&'b str>,
7324                search_type: Option<SearchType>,
7325                seq_no_primary_term: Option<bool>,
7326                size: Option<i64>,
7327                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
7328                sort: Option<&'b [&'b str]>,
7329                source: Option<&'b str>,
7330                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
7331                stats: Option<&'b [&'b str]>,
7332                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
7333                stored_fields: Option<&'b [&'b str]>,
7334                suggest_field: Option<&'b str>,
7335                suggest_mode: Option<SuggestMode>,
7336                suggest_size: Option<i64>,
7337                suggest_text: Option<&'b str>,
7338                terminate_after: Option<i64>,
7339                timeout: Option<&'b str>,
7340                track_scores: Option<bool>,
7341                track_total_hits: Option<TrackTotalHits>,
7342                typed_keys: Option<bool>,
7343                version: Option<bool>,
7344            }
7345            let query_params = QueryParams {
7346                _source: self._source,
7347                _source_excludes: self._source_excludes,
7348                _source_includes: self._source_includes,
7349                allow_no_indices: self.allow_no_indices,
7350                allow_partial_search_results: self.allow_partial_search_results,
7351                analyze_wildcard: self.analyze_wildcard,
7352                analyzer: self.analyzer,
7353                batched_reduce_size: self.batched_reduce_size,
7354                ccs_minimize_roundtrips: self.ccs_minimize_roundtrips,
7355                default_operator: self.default_operator,
7356                df: self.df,
7357                docvalue_fields: self.docvalue_fields,
7358                error_trace: self.error_trace,
7359                expand_wildcards: self.expand_wildcards,
7360                explain: self.explain,
7361                filter_path: self.filter_path,
7362                from: self.from,
7363                human: self.human,
7364                ignore_throttled: self.ignore_throttled,
7365                ignore_unavailable: self.ignore_unavailable,
7366                lenient: self.lenient,
7367                max_concurrent_shard_requests: self.max_concurrent_shard_requests,
7368                min_compatible_shard_node: self.min_compatible_shard_node,
7369                pre_filter_shard_size: self.pre_filter_shard_size,
7370                preference: self.preference,
7371                pretty: self.pretty,
7372                q: self.q,
7373                request_cache: self.request_cache,
7374                rest_total_hits_as_int: self.rest_total_hits_as_int,
7375                routing: self.routing,
7376                scroll: self.scroll,
7377                search_type: self.search_type,
7378                seq_no_primary_term: self.seq_no_primary_term,
7379                size: self.size,
7380                sort: self.sort,
7381                source: self.source,
7382                stats: self.stats,
7383                stored_fields: self.stored_fields,
7384                suggest_field: self.suggest_field,
7385                suggest_mode: self.suggest_mode,
7386                suggest_size: self.suggest_size,
7387                suggest_text: self.suggest_text,
7388                terminate_after: self.terminate_after,
7389                timeout: self.timeout,
7390                track_scores: self.track_scores,
7391                track_total_hits: self.track_total_hits,
7392                typed_keys: self.typed_keys,
7393                version: self.version,
7394            };
7395            Some(query_params)
7396        };
7397        let body = self.body;
7398        let response = self
7399            .transport
7400            .send(method, &path, headers, query_string.as_ref(), body, timeout)
7401            .await?;
7402        Ok(response)
7403    }
7404}
7405#[derive(Debug, Clone, PartialEq, Eq)]
7406#[doc = "API parts for the Search Shards API"]
7407pub enum SearchShardsParts<'b> {
7408    #[doc = "No parts"]
7409    None,
7410    #[doc = "Index"]
7411    Index(&'b [&'b str]),
7412}
7413impl<'b> SearchShardsParts<'b> {
7414    #[doc = "Builds a relative URL path to the Search Shards API"]
7415    pub fn url(self) -> Cow<'static, str> {
7416        match self {
7417            SearchShardsParts::None => "/_search_shards".into(),
7418            SearchShardsParts::Index(index) => {
7419                let index_str = index.join(",");
7420                let encoded_index: Cow<str> =
7421                    percent_encode(index_str.as_bytes(), PARTS_ENCODED).into();
7422                let mut p = String::with_capacity(16usize + encoded_index.len());
7423                p.push('/');
7424                p.push_str(encoded_index.as_ref());
7425                p.push_str("/_search_shards");
7426                p.into()
7427            }
7428        }
7429    }
7430}
7431#[doc = "Builder for the [Search Shards API](https://opensearch.org/docs/)\n\nReturns information about the indices and shards that a search request would be executed against."]
7432#[derive(Clone, Debug)]
7433pub struct SearchShards<'a, 'b, B> {
7434    transport: &'a Transport,
7435    parts: SearchShardsParts<'b>,
7436    allow_no_indices: Option<bool>,
7437    body: Option<B>,
7438    error_trace: Option<bool>,
7439    expand_wildcards: Option<&'b [ExpandWildcards]>,
7440    filter_path: Option<&'b [&'b str]>,
7441    headers: HeaderMap,
7442    human: Option<bool>,
7443    ignore_unavailable: Option<bool>,
7444    local: Option<bool>,
7445    preference: Option<&'b str>,
7446    pretty: Option<bool>,
7447    request_timeout: Option<Duration>,
7448    routing: Option<&'b str>,
7449    source: Option<&'b str>,
7450}
7451impl<'a, 'b, B> SearchShards<'a, 'b, B>
7452where
7453    B: Body,
7454{
7455    #[doc = "Creates a new instance of [SearchShards] with the specified API parts"]
7456    pub fn new(transport: &'a Transport, parts: SearchShardsParts<'b>) -> Self {
7457        let headers = HeaderMap::new();
7458        SearchShards {
7459            transport,
7460            parts,
7461            headers,
7462            allow_no_indices: None,
7463            body: None,
7464            error_trace: None,
7465            expand_wildcards: None,
7466            filter_path: None,
7467            human: None,
7468            ignore_unavailable: None,
7469            local: None,
7470            preference: None,
7471            pretty: None,
7472            request_timeout: None,
7473            routing: None,
7474            source: None,
7475        }
7476    }
7477    #[doc = "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)"]
7478    pub fn allow_no_indices(mut self, allow_no_indices: bool) -> Self {
7479        self.allow_no_indices = Some(allow_no_indices);
7480        self
7481    }
7482    #[doc = "The body for the API call"]
7483    pub fn body<T>(self, body: T) -> SearchShards<'a, 'b, JsonBody<T>>
7484    where
7485        T: Serialize,
7486    {
7487        SearchShards {
7488            transport: self.transport,
7489            parts: self.parts,
7490            body: Some(body.into()),
7491            allow_no_indices: self.allow_no_indices,
7492            error_trace: self.error_trace,
7493            expand_wildcards: self.expand_wildcards,
7494            filter_path: self.filter_path,
7495            headers: self.headers,
7496            human: self.human,
7497            ignore_unavailable: self.ignore_unavailable,
7498            local: self.local,
7499            preference: self.preference,
7500            pretty: self.pretty,
7501            request_timeout: self.request_timeout,
7502            routing: self.routing,
7503            source: self.source,
7504        }
7505    }
7506    #[doc = "Include the stack trace of returned errors."]
7507    pub fn error_trace(mut self, error_trace: bool) -> Self {
7508        self.error_trace = Some(error_trace);
7509        self
7510    }
7511    #[doc = "Whether to expand wildcard expression to concrete indices that are open, closed or both."]
7512    pub fn expand_wildcards(mut self, expand_wildcards: &'b [ExpandWildcards]) -> Self {
7513        self.expand_wildcards = Some(expand_wildcards);
7514        self
7515    }
7516    #[doc = "A comma-separated list of filters used to reduce the response."]
7517    pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
7518        self.filter_path = Some(filter_path);
7519        self
7520    }
7521    #[doc = "Adds a HTTP header"]
7522    pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
7523        self.headers.insert(key, value);
7524        self
7525    }
7526    #[doc = "Return human readable values for statistics."]
7527    pub fn human(mut self, human: bool) -> Self {
7528        self.human = Some(human);
7529        self
7530    }
7531    #[doc = "Whether specified concrete indices should be ignored when unavailable (missing or closed)"]
7532    pub fn ignore_unavailable(mut self, ignore_unavailable: bool) -> Self {
7533        self.ignore_unavailable = Some(ignore_unavailable);
7534        self
7535    }
7536    #[doc = "Return local information, do not retrieve the state from cluster-manager node (default: false)"]
7537    pub fn local(mut self, local: bool) -> Self {
7538        self.local = Some(local);
7539        self
7540    }
7541    #[doc = "Specify the node or shard the operation should be performed on (default: random)"]
7542    pub fn preference(mut self, preference: &'b str) -> Self {
7543        self.preference = Some(preference);
7544        self
7545    }
7546    #[doc = "Pretty format the returned JSON response."]
7547    pub fn pretty(mut self, pretty: bool) -> Self {
7548        self.pretty = Some(pretty);
7549        self
7550    }
7551    #[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."]
7552    pub fn request_timeout(mut self, timeout: Duration) -> Self {
7553        self.request_timeout = Some(timeout);
7554        self
7555    }
7556    #[doc = "Specific routing value"]
7557    pub fn routing(mut self, routing: &'b str) -> Self {
7558        self.routing = Some(routing);
7559        self
7560    }
7561    #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
7562    pub fn source(mut self, source: &'b str) -> Self {
7563        self.source = Some(source);
7564        self
7565    }
7566    #[doc = "Creates an asynchronous call to the Search Shards API that can be awaited"]
7567    pub async fn send(self) -> Result<Response, Error> {
7568        let path = self.parts.url();
7569        let method = match self.body {
7570            Some(_) => Method::Post,
7571            None => Method::Get,
7572        };
7573        let headers = self.headers;
7574        let timeout = self.request_timeout;
7575        let query_string = {
7576            #[serde_with::skip_serializing_none]
7577            #[derive(Serialize)]
7578            struct QueryParams<'b> {
7579                allow_no_indices: Option<bool>,
7580                error_trace: Option<bool>,
7581                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
7582                expand_wildcards: Option<&'b [ExpandWildcards]>,
7583                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
7584                filter_path: Option<&'b [&'b str]>,
7585                human: Option<bool>,
7586                ignore_unavailable: Option<bool>,
7587                local: Option<bool>,
7588                preference: Option<&'b str>,
7589                pretty: Option<bool>,
7590                routing: Option<&'b str>,
7591                source: Option<&'b str>,
7592            }
7593            let query_params = QueryParams {
7594                allow_no_indices: self.allow_no_indices,
7595                error_trace: self.error_trace,
7596                expand_wildcards: self.expand_wildcards,
7597                filter_path: self.filter_path,
7598                human: self.human,
7599                ignore_unavailable: self.ignore_unavailable,
7600                local: self.local,
7601                preference: self.preference,
7602                pretty: self.pretty,
7603                routing: self.routing,
7604                source: self.source,
7605            };
7606            Some(query_params)
7607        };
7608        let body = self.body;
7609        let response = self
7610            .transport
7611            .send(method, &path, headers, query_string.as_ref(), body, timeout)
7612            .await?;
7613        Ok(response)
7614    }
7615}
7616#[derive(Debug, Clone, PartialEq, Eq)]
7617#[doc = "API parts for the Search Template API"]
7618pub enum SearchTemplateParts<'b> {
7619    #[doc = "No parts"]
7620    None,
7621    #[doc = "Index"]
7622    Index(&'b [&'b str]),
7623}
7624impl<'b> SearchTemplateParts<'b> {
7625    #[doc = "Builds a relative URL path to the Search Template API"]
7626    pub fn url(self) -> Cow<'static, str> {
7627        match self {
7628            SearchTemplateParts::None => "/_search/template".into(),
7629            SearchTemplateParts::Index(index) => {
7630                let index_str = index.join(",");
7631                let encoded_index: Cow<str> =
7632                    percent_encode(index_str.as_bytes(), PARTS_ENCODED).into();
7633                let mut p = String::with_capacity(18usize + encoded_index.len());
7634                p.push('/');
7635                p.push_str(encoded_index.as_ref());
7636                p.push_str("/_search/template");
7637                p.into()
7638            }
7639        }
7640    }
7641}
7642#[doc = "Builder for the [Search Template API](https://opensearch.org/docs/)\n\nAllows to use the Mustache language to pre-render a search definition."]
7643#[derive(Clone, Debug)]
7644pub struct SearchTemplate<'a, 'b, B> {
7645    transport: &'a Transport,
7646    parts: SearchTemplateParts<'b>,
7647    allow_no_indices: Option<bool>,
7648    body: Option<B>,
7649    ccs_minimize_roundtrips: Option<bool>,
7650    error_trace: Option<bool>,
7651    expand_wildcards: Option<&'b [ExpandWildcards]>,
7652    explain: Option<bool>,
7653    filter_path: Option<&'b [&'b str]>,
7654    headers: HeaderMap,
7655    human: Option<bool>,
7656    ignore_throttled: Option<bool>,
7657    ignore_unavailable: Option<bool>,
7658    preference: Option<&'b str>,
7659    pretty: Option<bool>,
7660    profile: Option<bool>,
7661    request_timeout: Option<Duration>,
7662    rest_total_hits_as_int: Option<bool>,
7663    routing: Option<&'b [&'b str]>,
7664    scroll: Option<&'b str>,
7665    search_type: Option<SearchType>,
7666    source: Option<&'b str>,
7667    typed_keys: Option<bool>,
7668}
7669impl<'a, 'b, B> SearchTemplate<'a, 'b, B>
7670where
7671    B: Body,
7672{
7673    #[doc = "Creates a new instance of [SearchTemplate] with the specified API parts"]
7674    pub fn new(transport: &'a Transport, parts: SearchTemplateParts<'b>) -> Self {
7675        let headers = HeaderMap::new();
7676        SearchTemplate {
7677            transport,
7678            parts,
7679            headers,
7680            allow_no_indices: None,
7681            body: None,
7682            ccs_minimize_roundtrips: None,
7683            error_trace: None,
7684            expand_wildcards: None,
7685            explain: None,
7686            filter_path: None,
7687            human: None,
7688            ignore_throttled: None,
7689            ignore_unavailable: None,
7690            preference: None,
7691            pretty: None,
7692            profile: None,
7693            request_timeout: None,
7694            rest_total_hits_as_int: None,
7695            routing: None,
7696            scroll: None,
7697            search_type: None,
7698            source: None,
7699            typed_keys: None,
7700        }
7701    }
7702    #[doc = "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)"]
7703    pub fn allow_no_indices(mut self, allow_no_indices: bool) -> Self {
7704        self.allow_no_indices = Some(allow_no_indices);
7705        self
7706    }
7707    #[doc = "The body for the API call"]
7708    pub fn body<T>(self, body: T) -> SearchTemplate<'a, 'b, JsonBody<T>>
7709    where
7710        T: Serialize,
7711    {
7712        SearchTemplate {
7713            transport: self.transport,
7714            parts: self.parts,
7715            body: Some(body.into()),
7716            allow_no_indices: self.allow_no_indices,
7717            ccs_minimize_roundtrips: self.ccs_minimize_roundtrips,
7718            error_trace: self.error_trace,
7719            expand_wildcards: self.expand_wildcards,
7720            explain: self.explain,
7721            filter_path: self.filter_path,
7722            headers: self.headers,
7723            human: self.human,
7724            ignore_throttled: self.ignore_throttled,
7725            ignore_unavailable: self.ignore_unavailable,
7726            preference: self.preference,
7727            pretty: self.pretty,
7728            profile: self.profile,
7729            request_timeout: self.request_timeout,
7730            rest_total_hits_as_int: self.rest_total_hits_as_int,
7731            routing: self.routing,
7732            scroll: self.scroll,
7733            search_type: self.search_type,
7734            source: self.source,
7735            typed_keys: self.typed_keys,
7736        }
7737    }
7738    #[doc = "Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution"]
7739    pub fn ccs_minimize_roundtrips(mut self, ccs_minimize_roundtrips: bool) -> Self {
7740        self.ccs_minimize_roundtrips = Some(ccs_minimize_roundtrips);
7741        self
7742    }
7743    #[doc = "Include the stack trace of returned errors."]
7744    pub fn error_trace(mut self, error_trace: bool) -> Self {
7745        self.error_trace = Some(error_trace);
7746        self
7747    }
7748    #[doc = "Whether to expand wildcard expression to concrete indices that are open, closed or both."]
7749    pub fn expand_wildcards(mut self, expand_wildcards: &'b [ExpandWildcards]) -> Self {
7750        self.expand_wildcards = Some(expand_wildcards);
7751        self
7752    }
7753    #[doc = "Specify whether to return detailed information about score computation as part of a hit"]
7754    pub fn explain(mut self, explain: bool) -> Self {
7755        self.explain = Some(explain);
7756        self
7757    }
7758    #[doc = "A comma-separated list of filters used to reduce the response."]
7759    pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
7760        self.filter_path = Some(filter_path);
7761        self
7762    }
7763    #[doc = "Adds a HTTP header"]
7764    pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
7765        self.headers.insert(key, value);
7766        self
7767    }
7768    #[doc = "Return human readable values for statistics."]
7769    pub fn human(mut self, human: bool) -> Self {
7770        self.human = Some(human);
7771        self
7772    }
7773    #[doc = "Whether specified concrete, expanded or aliased indices should be ignored when throttled"]
7774    pub fn ignore_throttled(mut self, ignore_throttled: bool) -> Self {
7775        self.ignore_throttled = Some(ignore_throttled);
7776        self
7777    }
7778    #[doc = "Whether specified concrete indices should be ignored when unavailable (missing or closed)"]
7779    pub fn ignore_unavailable(mut self, ignore_unavailable: bool) -> Self {
7780        self.ignore_unavailable = Some(ignore_unavailable);
7781        self
7782    }
7783    #[doc = "Specify the node or shard the operation should be performed on (default: random)"]
7784    pub fn preference(mut self, preference: &'b str) -> Self {
7785        self.preference = Some(preference);
7786        self
7787    }
7788    #[doc = "Pretty format the returned JSON response."]
7789    pub fn pretty(mut self, pretty: bool) -> Self {
7790        self.pretty = Some(pretty);
7791        self
7792    }
7793    #[doc = "Specify whether to profile the query execution"]
7794    pub fn profile(mut self, profile: bool) -> Self {
7795        self.profile = Some(profile);
7796        self
7797    }
7798    #[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."]
7799    pub fn request_timeout(mut self, timeout: Duration) -> Self {
7800        self.request_timeout = Some(timeout);
7801        self
7802    }
7803    #[doc = "Indicates whether hits.total should be rendered as an integer or an object in the rest search response"]
7804    pub fn rest_total_hits_as_int(mut self, rest_total_hits_as_int: bool) -> Self {
7805        self.rest_total_hits_as_int = Some(rest_total_hits_as_int);
7806        self
7807    }
7808    #[doc = "A comma-separated list of specific routing values"]
7809    pub fn routing(mut self, routing: &'b [&'b str]) -> Self {
7810        self.routing = Some(routing);
7811        self
7812    }
7813    #[doc = "Specify how long a consistent view of the index should be maintained for scrolled search"]
7814    pub fn scroll(mut self, scroll: &'b str) -> Self {
7815        self.scroll = Some(scroll);
7816        self
7817    }
7818    #[doc = "Search operation type"]
7819    pub fn search_type(mut self, search_type: SearchType) -> Self {
7820        self.search_type = Some(search_type);
7821        self
7822    }
7823    #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
7824    pub fn source(mut self, source: &'b str) -> Self {
7825        self.source = Some(source);
7826        self
7827    }
7828    #[doc = "Specify whether aggregation and suggester names should be prefixed by their respective types in the response"]
7829    pub fn typed_keys(mut self, typed_keys: bool) -> Self {
7830        self.typed_keys = Some(typed_keys);
7831        self
7832    }
7833    #[doc = "Creates an asynchronous call to the Search Template API that can be awaited"]
7834    pub async fn send(self) -> Result<Response, Error> {
7835        let path = self.parts.url();
7836        let method = match self.body {
7837            Some(_) => Method::Post,
7838            None => Method::Get,
7839        };
7840        let headers = self.headers;
7841        let timeout = self.request_timeout;
7842        let query_string = {
7843            #[serde_with::skip_serializing_none]
7844            #[derive(Serialize)]
7845            struct QueryParams<'b> {
7846                allow_no_indices: Option<bool>,
7847                ccs_minimize_roundtrips: Option<bool>,
7848                error_trace: Option<bool>,
7849                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
7850                expand_wildcards: Option<&'b [ExpandWildcards]>,
7851                explain: Option<bool>,
7852                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
7853                filter_path: Option<&'b [&'b str]>,
7854                human: Option<bool>,
7855                ignore_throttled: Option<bool>,
7856                ignore_unavailable: Option<bool>,
7857                preference: Option<&'b str>,
7858                pretty: Option<bool>,
7859                profile: Option<bool>,
7860                rest_total_hits_as_int: Option<bool>,
7861                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
7862                routing: Option<&'b [&'b str]>,
7863                scroll: Option<&'b str>,
7864                search_type: Option<SearchType>,
7865                source: Option<&'b str>,
7866                typed_keys: Option<bool>,
7867            }
7868            let query_params = QueryParams {
7869                allow_no_indices: self.allow_no_indices,
7870                ccs_minimize_roundtrips: self.ccs_minimize_roundtrips,
7871                error_trace: self.error_trace,
7872                expand_wildcards: self.expand_wildcards,
7873                explain: self.explain,
7874                filter_path: self.filter_path,
7875                human: self.human,
7876                ignore_throttled: self.ignore_throttled,
7877                ignore_unavailable: self.ignore_unavailable,
7878                preference: self.preference,
7879                pretty: self.pretty,
7880                profile: self.profile,
7881                rest_total_hits_as_int: self.rest_total_hits_as_int,
7882                routing: self.routing,
7883                scroll: self.scroll,
7884                search_type: self.search_type,
7885                source: self.source,
7886                typed_keys: self.typed_keys,
7887            };
7888            Some(query_params)
7889        };
7890        let body = self.body;
7891        let response = self
7892            .transport
7893            .send(method, &path, headers, query_string.as_ref(), body, timeout)
7894            .await?;
7895        Ok(response)
7896    }
7897}
7898#[derive(Debug, Clone, PartialEq, Eq)]
7899#[doc = "API parts for the Termvectors API"]
7900pub enum TermvectorsParts<'b> {
7901    #[doc = "Index and Id"]
7902    IndexId(&'b str, &'b str),
7903    #[doc = "Index"]
7904    Index(&'b str),
7905}
7906impl<'b> TermvectorsParts<'b> {
7907    #[doc = "Builds a relative URL path to the Termvectors API"]
7908    pub fn url(self) -> Cow<'static, str> {
7909        match self {
7910            TermvectorsParts::IndexId(index, id) => {
7911                let encoded_index: Cow<str> =
7912                    percent_encode(index.as_bytes(), PARTS_ENCODED).into();
7913                let encoded_id: Cow<str> = percent_encode(id.as_bytes(), PARTS_ENCODED).into();
7914                let mut p = String::with_capacity(15usize + encoded_index.len() + encoded_id.len());
7915                p.push('/');
7916                p.push_str(encoded_index.as_ref());
7917                p.push_str("/_termvectors/");
7918                p.push_str(encoded_id.as_ref());
7919                p.into()
7920            }
7921            TermvectorsParts::Index(index) => {
7922                let encoded_index: Cow<str> =
7923                    percent_encode(index.as_bytes(), PARTS_ENCODED).into();
7924                let mut p = String::with_capacity(14usize + encoded_index.len());
7925                p.push('/');
7926                p.push_str(encoded_index.as_ref());
7927                p.push_str("/_termvectors");
7928                p.into()
7929            }
7930        }
7931    }
7932}
7933#[doc = "Builder for the [Termvectors API](https://opensearch.org/docs/)\n\nReturns information and statistics about terms in the fields of a particular document."]
7934#[derive(Clone, Debug)]
7935pub struct Termvectors<'a, 'b, B> {
7936    transport: &'a Transport,
7937    parts: TermvectorsParts<'b>,
7938    body: Option<B>,
7939    error_trace: Option<bool>,
7940    field_statistics: Option<bool>,
7941    fields: Option<&'b [&'b str]>,
7942    filter_path: Option<&'b [&'b str]>,
7943    headers: HeaderMap,
7944    human: Option<bool>,
7945    offsets: Option<bool>,
7946    payloads: Option<bool>,
7947    positions: Option<bool>,
7948    preference: Option<&'b str>,
7949    pretty: Option<bool>,
7950    realtime: Option<bool>,
7951    request_timeout: Option<Duration>,
7952    routing: Option<&'b str>,
7953    source: Option<&'b str>,
7954    term_statistics: Option<bool>,
7955    version: Option<i64>,
7956    version_type: Option<VersionType>,
7957}
7958impl<'a, 'b, B> Termvectors<'a, 'b, B>
7959where
7960    B: Body,
7961{
7962    #[doc = "Creates a new instance of [Termvectors] with the specified API parts"]
7963    pub fn new(transport: &'a Transport, parts: TermvectorsParts<'b>) -> Self {
7964        let headers = HeaderMap::new();
7965        Termvectors {
7966            transport,
7967            parts,
7968            headers,
7969            body: None,
7970            error_trace: None,
7971            field_statistics: None,
7972            fields: None,
7973            filter_path: None,
7974            human: None,
7975            offsets: None,
7976            payloads: None,
7977            positions: None,
7978            preference: None,
7979            pretty: None,
7980            realtime: None,
7981            request_timeout: None,
7982            routing: None,
7983            source: None,
7984            term_statistics: None,
7985            version: None,
7986            version_type: None,
7987        }
7988    }
7989    #[doc = "The body for the API call"]
7990    pub fn body<T>(self, body: T) -> Termvectors<'a, 'b, JsonBody<T>>
7991    where
7992        T: Serialize,
7993    {
7994        Termvectors {
7995            transport: self.transport,
7996            parts: self.parts,
7997            body: Some(body.into()),
7998            error_trace: self.error_trace,
7999            field_statistics: self.field_statistics,
8000            fields: self.fields,
8001            filter_path: self.filter_path,
8002            headers: self.headers,
8003            human: self.human,
8004            offsets: self.offsets,
8005            payloads: self.payloads,
8006            positions: self.positions,
8007            preference: self.preference,
8008            pretty: self.pretty,
8009            realtime: self.realtime,
8010            request_timeout: self.request_timeout,
8011            routing: self.routing,
8012            source: self.source,
8013            term_statistics: self.term_statistics,
8014            version: self.version,
8015            version_type: self.version_type,
8016        }
8017    }
8018    #[doc = "Include the stack trace of returned errors."]
8019    pub fn error_trace(mut self, error_trace: bool) -> Self {
8020        self.error_trace = Some(error_trace);
8021        self
8022    }
8023    #[doc = "Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned."]
8024    pub fn field_statistics(mut self, field_statistics: bool) -> Self {
8025        self.field_statistics = Some(field_statistics);
8026        self
8027    }
8028    #[doc = "A comma-separated list of fields to return."]
8029    pub fn fields(mut self, fields: &'b [&'b str]) -> Self {
8030        self.fields = Some(fields);
8031        self
8032    }
8033    #[doc = "A comma-separated list of filters used to reduce the response."]
8034    pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
8035        self.filter_path = Some(filter_path);
8036        self
8037    }
8038    #[doc = "Adds a HTTP header"]
8039    pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
8040        self.headers.insert(key, value);
8041        self
8042    }
8043    #[doc = "Return human readable values for statistics."]
8044    pub fn human(mut self, human: bool) -> Self {
8045        self.human = Some(human);
8046        self
8047    }
8048    #[doc = "Specifies if term offsets should be returned."]
8049    pub fn offsets(mut self, offsets: bool) -> Self {
8050        self.offsets = Some(offsets);
8051        self
8052    }
8053    #[doc = "Specifies if term payloads should be returned."]
8054    pub fn payloads(mut self, payloads: bool) -> Self {
8055        self.payloads = Some(payloads);
8056        self
8057    }
8058    #[doc = "Specifies if term positions should be returned."]
8059    pub fn positions(mut self, positions: bool) -> Self {
8060        self.positions = Some(positions);
8061        self
8062    }
8063    #[doc = "Specify the node or shard the operation should be performed on (default: random)."]
8064    pub fn preference(mut self, preference: &'b str) -> Self {
8065        self.preference = Some(preference);
8066        self
8067    }
8068    #[doc = "Pretty format the returned JSON response."]
8069    pub fn pretty(mut self, pretty: bool) -> Self {
8070        self.pretty = Some(pretty);
8071        self
8072    }
8073    #[doc = "Specifies if request is real-time as opposed to near-real-time (default: true)."]
8074    pub fn realtime(mut self, realtime: bool) -> Self {
8075        self.realtime = Some(realtime);
8076        self
8077    }
8078    #[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."]
8079    pub fn request_timeout(mut self, timeout: Duration) -> Self {
8080        self.request_timeout = Some(timeout);
8081        self
8082    }
8083    #[doc = "Specific routing value."]
8084    pub fn routing(mut self, routing: &'b str) -> Self {
8085        self.routing = Some(routing);
8086        self
8087    }
8088    #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
8089    pub fn source(mut self, source: &'b str) -> Self {
8090        self.source = Some(source);
8091        self
8092    }
8093    #[doc = "Specifies if total term frequency and document frequency should be returned."]
8094    pub fn term_statistics(mut self, term_statistics: bool) -> Self {
8095        self.term_statistics = Some(term_statistics);
8096        self
8097    }
8098    #[doc = "Explicit version number for concurrency control"]
8099    pub fn version(mut self, version: i64) -> Self {
8100        self.version = Some(version);
8101        self
8102    }
8103    #[doc = "Specific version type"]
8104    pub fn version_type(mut self, version_type: VersionType) -> Self {
8105        self.version_type = Some(version_type);
8106        self
8107    }
8108    #[doc = "Creates an asynchronous call to the Termvectors API that can be awaited"]
8109    pub async fn send(self) -> Result<Response, Error> {
8110        let path = self.parts.url();
8111        let method = match self.body {
8112            Some(_) => Method::Post,
8113            None => Method::Get,
8114        };
8115        let headers = self.headers;
8116        let timeout = self.request_timeout;
8117        let query_string = {
8118            #[serde_with::skip_serializing_none]
8119            #[derive(Serialize)]
8120            struct QueryParams<'b> {
8121                error_trace: Option<bool>,
8122                field_statistics: Option<bool>,
8123                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
8124                fields: Option<&'b [&'b str]>,
8125                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
8126                filter_path: Option<&'b [&'b str]>,
8127                human: Option<bool>,
8128                offsets: Option<bool>,
8129                payloads: Option<bool>,
8130                positions: Option<bool>,
8131                preference: Option<&'b str>,
8132                pretty: Option<bool>,
8133                realtime: Option<bool>,
8134                routing: Option<&'b str>,
8135                source: Option<&'b str>,
8136                term_statistics: Option<bool>,
8137                version: Option<i64>,
8138                version_type: Option<VersionType>,
8139            }
8140            let query_params = QueryParams {
8141                error_trace: self.error_trace,
8142                field_statistics: self.field_statistics,
8143                fields: self.fields,
8144                filter_path: self.filter_path,
8145                human: self.human,
8146                offsets: self.offsets,
8147                payloads: self.payloads,
8148                positions: self.positions,
8149                preference: self.preference,
8150                pretty: self.pretty,
8151                realtime: self.realtime,
8152                routing: self.routing,
8153                source: self.source,
8154                term_statistics: self.term_statistics,
8155                version: self.version,
8156                version_type: self.version_type,
8157            };
8158            Some(query_params)
8159        };
8160        let body = self.body;
8161        let response = self
8162            .transport
8163            .send(method, &path, headers, query_string.as_ref(), body, timeout)
8164            .await?;
8165        Ok(response)
8166    }
8167}
8168#[derive(Debug, Clone, PartialEq, Eq)]
8169#[doc = "API parts for the Update API"]
8170pub enum UpdateParts<'b> {
8171    #[doc = "Index and Id"]
8172    IndexId(&'b str, &'b str),
8173}
8174impl<'b> UpdateParts<'b> {
8175    #[doc = "Builds a relative URL path to the Update API"]
8176    pub fn url(self) -> Cow<'static, str> {
8177        match self {
8178            UpdateParts::IndexId(index, id) => {
8179                let encoded_index: Cow<str> =
8180                    percent_encode(index.as_bytes(), PARTS_ENCODED).into();
8181                let encoded_id: Cow<str> = percent_encode(id.as_bytes(), PARTS_ENCODED).into();
8182                let mut p = String::with_capacity(10usize + encoded_index.len() + encoded_id.len());
8183                p.push('/');
8184                p.push_str(encoded_index.as_ref());
8185                p.push_str("/_update/");
8186                p.push_str(encoded_id.as_ref());
8187                p.into()
8188            }
8189        }
8190    }
8191}
8192#[doc = "Builder for the [Update API](https://opensearch.org/docs/)\n\nUpdates a document with a script or partial document."]
8193#[derive(Clone, Debug)]
8194pub struct Update<'a, 'b, B> {
8195    transport: &'a Transport,
8196    parts: UpdateParts<'b>,
8197    _source: Option<&'b [&'b str]>,
8198    _source_excludes: Option<&'b [&'b str]>,
8199    _source_includes: Option<&'b [&'b str]>,
8200    body: Option<B>,
8201    error_trace: Option<bool>,
8202    filter_path: Option<&'b [&'b str]>,
8203    headers: HeaderMap,
8204    human: Option<bool>,
8205    if_primary_term: Option<i64>,
8206    if_seq_no: Option<i64>,
8207    lang: Option<&'b str>,
8208    pretty: Option<bool>,
8209    refresh: Option<Refresh>,
8210    request_timeout: Option<Duration>,
8211    require_alias: Option<bool>,
8212    retry_on_conflict: Option<i64>,
8213    routing: Option<&'b str>,
8214    source: Option<&'b str>,
8215    timeout: Option<&'b str>,
8216    wait_for_active_shards: Option<&'b str>,
8217}
8218impl<'a, 'b, B> Update<'a, 'b, B>
8219where
8220    B: Body,
8221{
8222    #[doc = "Creates a new instance of [Update] with the specified API parts"]
8223    pub fn new(transport: &'a Transport, parts: UpdateParts<'b>) -> Self {
8224        let headers = HeaderMap::new();
8225        Update {
8226            transport,
8227            parts,
8228            headers,
8229            _source: None,
8230            _source_excludes: None,
8231            _source_includes: None,
8232            body: None,
8233            error_trace: None,
8234            filter_path: None,
8235            human: None,
8236            if_primary_term: None,
8237            if_seq_no: None,
8238            lang: None,
8239            pretty: None,
8240            refresh: None,
8241            request_timeout: None,
8242            require_alias: None,
8243            retry_on_conflict: None,
8244            routing: None,
8245            source: None,
8246            timeout: None,
8247            wait_for_active_shards: None,
8248        }
8249    }
8250    #[doc = "True or false to return the _source field or not, or a list of fields to return"]
8251    pub fn _source(mut self, _source: &'b [&'b str]) -> Self {
8252        self._source = Some(_source);
8253        self
8254    }
8255    #[doc = "A list of fields to exclude from the returned _source field"]
8256    pub fn _source_excludes(mut self, _source_excludes: &'b [&'b str]) -> Self {
8257        self._source_excludes = Some(_source_excludes);
8258        self
8259    }
8260    #[doc = "A list of fields to extract and return from the _source field"]
8261    pub fn _source_includes(mut self, _source_includes: &'b [&'b str]) -> Self {
8262        self._source_includes = Some(_source_includes);
8263        self
8264    }
8265    #[doc = "The body for the API call"]
8266    pub fn body<T>(self, body: T) -> Update<'a, 'b, JsonBody<T>>
8267    where
8268        T: Serialize,
8269    {
8270        Update {
8271            transport: self.transport,
8272            parts: self.parts,
8273            body: Some(body.into()),
8274            _source: self._source,
8275            _source_excludes: self._source_excludes,
8276            _source_includes: self._source_includes,
8277            error_trace: self.error_trace,
8278            filter_path: self.filter_path,
8279            headers: self.headers,
8280            human: self.human,
8281            if_primary_term: self.if_primary_term,
8282            if_seq_no: self.if_seq_no,
8283            lang: self.lang,
8284            pretty: self.pretty,
8285            refresh: self.refresh,
8286            request_timeout: self.request_timeout,
8287            require_alias: self.require_alias,
8288            retry_on_conflict: self.retry_on_conflict,
8289            routing: self.routing,
8290            source: self.source,
8291            timeout: self.timeout,
8292            wait_for_active_shards: self.wait_for_active_shards,
8293        }
8294    }
8295    #[doc = "Include the stack trace of returned errors."]
8296    pub fn error_trace(mut self, error_trace: bool) -> Self {
8297        self.error_trace = Some(error_trace);
8298        self
8299    }
8300    #[doc = "A comma-separated list of filters used to reduce the response."]
8301    pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
8302        self.filter_path = Some(filter_path);
8303        self
8304    }
8305    #[doc = "Adds a HTTP header"]
8306    pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
8307        self.headers.insert(key, value);
8308        self
8309    }
8310    #[doc = "Return human readable values for statistics."]
8311    pub fn human(mut self, human: bool) -> Self {
8312        self.human = Some(human);
8313        self
8314    }
8315    #[doc = "only perform the update operation if the last operation that has changed the document has the specified primary term"]
8316    pub fn if_primary_term(mut self, if_primary_term: i64) -> Self {
8317        self.if_primary_term = Some(if_primary_term);
8318        self
8319    }
8320    #[doc = "only perform the update operation if the last operation that has changed the document has the specified sequence number"]
8321    pub fn if_seq_no(mut self, if_seq_no: i64) -> Self {
8322        self.if_seq_no = Some(if_seq_no);
8323        self
8324    }
8325    #[doc = "The script language (default: painless)"]
8326    pub fn lang(mut self, lang: &'b str) -> Self {
8327        self.lang = Some(lang);
8328        self
8329    }
8330    #[doc = "Pretty format the returned JSON response."]
8331    pub fn pretty(mut self, pretty: bool) -> Self {
8332        self.pretty = Some(pretty);
8333        self
8334    }
8335    #[doc = "If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes."]
8336    pub fn refresh(mut self, refresh: Refresh) -> Self {
8337        self.refresh = Some(refresh);
8338        self
8339    }
8340    #[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."]
8341    pub fn request_timeout(mut self, timeout: Duration) -> Self {
8342        self.request_timeout = Some(timeout);
8343        self
8344    }
8345    #[doc = "When true, requires destination is an alias. Default is false"]
8346    pub fn require_alias(mut self, require_alias: bool) -> Self {
8347        self.require_alias = Some(require_alias);
8348        self
8349    }
8350    #[doc = "Specify how many times should the operation be retried when a conflict occurs (default: 0)"]
8351    pub fn retry_on_conflict(mut self, retry_on_conflict: i64) -> Self {
8352        self.retry_on_conflict = Some(retry_on_conflict);
8353        self
8354    }
8355    #[doc = "Specific routing value"]
8356    pub fn routing(mut self, routing: &'b str) -> Self {
8357        self.routing = Some(routing);
8358        self
8359    }
8360    #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
8361    pub fn source(mut self, source: &'b str) -> Self {
8362        self.source = Some(source);
8363        self
8364    }
8365    #[doc = "Explicit operation timeout"]
8366    pub fn timeout(mut self, timeout: &'b str) -> Self {
8367        self.timeout = Some(timeout);
8368        self
8369    }
8370    #[doc = "Sets the number of shard copies that must be active before proceeding with the update operation. Defaults to 1, meaning the primary shard only. 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)"]
8371    pub fn wait_for_active_shards(mut self, wait_for_active_shards: &'b str) -> Self {
8372        self.wait_for_active_shards = Some(wait_for_active_shards);
8373        self
8374    }
8375    #[doc = "Creates an asynchronous call to the Update API that can be awaited"]
8376    pub async fn send(self) -> Result<Response, Error> {
8377        let path = self.parts.url();
8378        let method = Method::Post;
8379        let headers = self.headers;
8380        let timeout = self.request_timeout;
8381        let query_string = {
8382            #[serde_with::skip_serializing_none]
8383            #[derive(Serialize)]
8384            struct QueryParams<'b> {
8385                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
8386                _source: Option<&'b [&'b str]>,
8387                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
8388                _source_excludes: Option<&'b [&'b str]>,
8389                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
8390                _source_includes: Option<&'b [&'b str]>,
8391                error_trace: Option<bool>,
8392                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
8393                filter_path: Option<&'b [&'b str]>,
8394                human: Option<bool>,
8395                if_primary_term: Option<i64>,
8396                if_seq_no: Option<i64>,
8397                lang: Option<&'b str>,
8398                pretty: Option<bool>,
8399                refresh: Option<Refresh>,
8400                require_alias: Option<bool>,
8401                retry_on_conflict: Option<i64>,
8402                routing: Option<&'b str>,
8403                source: Option<&'b str>,
8404                timeout: Option<&'b str>,
8405                wait_for_active_shards: Option<&'b str>,
8406            }
8407            let query_params = QueryParams {
8408                _source: self._source,
8409                _source_excludes: self._source_excludes,
8410                _source_includes: self._source_includes,
8411                error_trace: self.error_trace,
8412                filter_path: self.filter_path,
8413                human: self.human,
8414                if_primary_term: self.if_primary_term,
8415                if_seq_no: self.if_seq_no,
8416                lang: self.lang,
8417                pretty: self.pretty,
8418                refresh: self.refresh,
8419                require_alias: self.require_alias,
8420                retry_on_conflict: self.retry_on_conflict,
8421                routing: self.routing,
8422                source: self.source,
8423                timeout: self.timeout,
8424                wait_for_active_shards: self.wait_for_active_shards,
8425            };
8426            Some(query_params)
8427        };
8428        let body = self.body;
8429        let response = self
8430            .transport
8431            .send(method, &path, headers, query_string.as_ref(), body, timeout)
8432            .await?;
8433        Ok(response)
8434    }
8435}
8436#[derive(Debug, Clone, PartialEq, Eq)]
8437#[doc = "API parts for the Update By Query API"]
8438pub enum UpdateByQueryParts<'b> {
8439    #[doc = "Index"]
8440    Index(&'b [&'b str]),
8441}
8442impl<'b> UpdateByQueryParts<'b> {
8443    #[doc = "Builds a relative URL path to the Update By Query API"]
8444    pub fn url(self) -> Cow<'static, str> {
8445        match self {
8446            UpdateByQueryParts::Index(index) => {
8447                let index_str = index.join(",");
8448                let encoded_index: Cow<str> =
8449                    percent_encode(index_str.as_bytes(), PARTS_ENCODED).into();
8450                let mut p = String::with_capacity(18usize + encoded_index.len());
8451                p.push('/');
8452                p.push_str(encoded_index.as_ref());
8453                p.push_str("/_update_by_query");
8454                p.into()
8455            }
8456        }
8457    }
8458}
8459#[doc = "Builder for the [Update By Query API](https://opensearch.org/docs/)\n\nPerforms an update on every document in the index without changing the source,\nfor example to pick up a mapping change."]
8460#[derive(Clone, Debug)]
8461pub struct UpdateByQuery<'a, 'b, B> {
8462    transport: &'a Transport,
8463    parts: UpdateByQueryParts<'b>,
8464    _source: Option<&'b [&'b str]>,
8465    _source_excludes: Option<&'b [&'b str]>,
8466    _source_includes: Option<&'b [&'b str]>,
8467    allow_no_indices: Option<bool>,
8468    analyze_wildcard: Option<bool>,
8469    analyzer: Option<&'b str>,
8470    body: Option<B>,
8471    conflicts: Option<Conflicts>,
8472    default_operator: Option<DefaultOperator>,
8473    df: Option<&'b str>,
8474    error_trace: Option<bool>,
8475    expand_wildcards: Option<&'b [ExpandWildcards]>,
8476    filter_path: Option<&'b [&'b str]>,
8477    from: Option<i64>,
8478    headers: HeaderMap,
8479    human: Option<bool>,
8480    ignore_unavailable: Option<bool>,
8481    lenient: Option<bool>,
8482    max_docs: Option<i64>,
8483    pipeline: Option<&'b str>,
8484    preference: Option<&'b str>,
8485    pretty: Option<bool>,
8486    q: Option<&'b str>,
8487    refresh: Option<bool>,
8488    request_cache: Option<bool>,
8489    request_timeout: Option<Duration>,
8490    requests_per_second: Option<i64>,
8491    routing: Option<&'b [&'b str]>,
8492    scroll: Option<&'b str>,
8493    scroll_size: Option<i64>,
8494    search_timeout: Option<&'b str>,
8495    search_type: Option<SearchType>,
8496    size: Option<i64>,
8497    slices: Option<Slices>,
8498    sort: Option<&'b [&'b str]>,
8499    source: Option<&'b str>,
8500    stats: Option<&'b [&'b str]>,
8501    terminate_after: Option<i64>,
8502    timeout: Option<&'b str>,
8503    version: Option<bool>,
8504    version_type: Option<bool>,
8505    wait_for_active_shards: Option<&'b str>,
8506    wait_for_completion: Option<bool>,
8507}
8508impl<'a, 'b, B> UpdateByQuery<'a, 'b, B>
8509where
8510    B: Body,
8511{
8512    #[doc = "Creates a new instance of [UpdateByQuery] with the specified API parts"]
8513    pub fn new(transport: &'a Transport, parts: UpdateByQueryParts<'b>) -> Self {
8514        let headers = HeaderMap::new();
8515        UpdateByQuery {
8516            transport,
8517            parts,
8518            headers,
8519            _source: None,
8520            _source_excludes: None,
8521            _source_includes: None,
8522            allow_no_indices: None,
8523            analyze_wildcard: None,
8524            analyzer: None,
8525            body: None,
8526            conflicts: None,
8527            default_operator: None,
8528            df: None,
8529            error_trace: None,
8530            expand_wildcards: None,
8531            filter_path: None,
8532            from: None,
8533            human: None,
8534            ignore_unavailable: None,
8535            lenient: None,
8536            max_docs: None,
8537            pipeline: None,
8538            preference: None,
8539            pretty: None,
8540            q: None,
8541            refresh: None,
8542            request_cache: None,
8543            request_timeout: None,
8544            requests_per_second: None,
8545            routing: None,
8546            scroll: None,
8547            scroll_size: None,
8548            search_timeout: None,
8549            search_type: None,
8550            size: None,
8551            slices: None,
8552            sort: None,
8553            source: None,
8554            stats: None,
8555            terminate_after: None,
8556            timeout: None,
8557            version: None,
8558            version_type: None,
8559            wait_for_active_shards: None,
8560            wait_for_completion: None,
8561        }
8562    }
8563    #[doc = "True or false to return the _source field or not, or a list of fields to return"]
8564    pub fn _source(mut self, _source: &'b [&'b str]) -> Self {
8565        self._source = Some(_source);
8566        self
8567    }
8568    #[doc = "A list of fields to exclude from the returned _source field"]
8569    pub fn _source_excludes(mut self, _source_excludes: &'b [&'b str]) -> Self {
8570        self._source_excludes = Some(_source_excludes);
8571        self
8572    }
8573    #[doc = "A list of fields to extract and return from the _source field"]
8574    pub fn _source_includes(mut self, _source_includes: &'b [&'b str]) -> Self {
8575        self._source_includes = Some(_source_includes);
8576        self
8577    }
8578    #[doc = "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)"]
8579    pub fn allow_no_indices(mut self, allow_no_indices: bool) -> Self {
8580        self.allow_no_indices = Some(allow_no_indices);
8581        self
8582    }
8583    #[doc = "Specify whether wildcard and prefix queries should be analyzed (default: false)"]
8584    pub fn analyze_wildcard(mut self, analyze_wildcard: bool) -> Self {
8585        self.analyze_wildcard = Some(analyze_wildcard);
8586        self
8587    }
8588    #[doc = "The analyzer to use for the query string"]
8589    pub fn analyzer(mut self, analyzer: &'b str) -> Self {
8590        self.analyzer = Some(analyzer);
8591        self
8592    }
8593    #[doc = "The body for the API call"]
8594    pub fn body<T>(self, body: T) -> UpdateByQuery<'a, 'b, JsonBody<T>>
8595    where
8596        T: Serialize,
8597    {
8598        UpdateByQuery {
8599            transport: self.transport,
8600            parts: self.parts,
8601            body: Some(body.into()),
8602            _source: self._source,
8603            _source_excludes: self._source_excludes,
8604            _source_includes: self._source_includes,
8605            allow_no_indices: self.allow_no_indices,
8606            analyze_wildcard: self.analyze_wildcard,
8607            analyzer: self.analyzer,
8608            conflicts: self.conflicts,
8609            default_operator: self.default_operator,
8610            df: self.df,
8611            error_trace: self.error_trace,
8612            expand_wildcards: self.expand_wildcards,
8613            filter_path: self.filter_path,
8614            from: self.from,
8615            headers: self.headers,
8616            human: self.human,
8617            ignore_unavailable: self.ignore_unavailable,
8618            lenient: self.lenient,
8619            max_docs: self.max_docs,
8620            pipeline: self.pipeline,
8621            preference: self.preference,
8622            pretty: self.pretty,
8623            q: self.q,
8624            refresh: self.refresh,
8625            request_cache: self.request_cache,
8626            request_timeout: self.request_timeout,
8627            requests_per_second: self.requests_per_second,
8628            routing: self.routing,
8629            scroll: self.scroll,
8630            scroll_size: self.scroll_size,
8631            search_timeout: self.search_timeout,
8632            search_type: self.search_type,
8633            size: self.size,
8634            slices: self.slices,
8635            sort: self.sort,
8636            source: self.source,
8637            stats: self.stats,
8638            terminate_after: self.terminate_after,
8639            timeout: self.timeout,
8640            version: self.version,
8641            version_type: self.version_type,
8642            wait_for_active_shards: self.wait_for_active_shards,
8643            wait_for_completion: self.wait_for_completion,
8644        }
8645    }
8646    #[doc = "What to do when the update by query hits version conflicts?"]
8647    pub fn conflicts(mut self, conflicts: Conflicts) -> Self {
8648        self.conflicts = Some(conflicts);
8649        self
8650    }
8651    #[doc = "The default operator for query string query (AND or OR)"]
8652    pub fn default_operator(mut self, default_operator: DefaultOperator) -> Self {
8653        self.default_operator = Some(default_operator);
8654        self
8655    }
8656    #[doc = "The field to use as default where no field prefix is given in the query string"]
8657    pub fn df(mut self, df: &'b str) -> Self {
8658        self.df = Some(df);
8659        self
8660    }
8661    #[doc = "Include the stack trace of returned errors."]
8662    pub fn error_trace(mut self, error_trace: bool) -> Self {
8663        self.error_trace = Some(error_trace);
8664        self
8665    }
8666    #[doc = "Whether to expand wildcard expression to concrete indices that are open, closed or both."]
8667    pub fn expand_wildcards(mut self, expand_wildcards: &'b [ExpandWildcards]) -> Self {
8668        self.expand_wildcards = Some(expand_wildcards);
8669        self
8670    }
8671    #[doc = "A comma-separated list of filters used to reduce the response."]
8672    pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
8673        self.filter_path = Some(filter_path);
8674        self
8675    }
8676    #[doc = "Starting offset (default: 0)"]
8677    pub fn from(mut self, from: i64) -> Self {
8678        self.from = Some(from);
8679        self
8680    }
8681    #[doc = "Adds a HTTP header"]
8682    pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
8683        self.headers.insert(key, value);
8684        self
8685    }
8686    #[doc = "Return human readable values for statistics."]
8687    pub fn human(mut self, human: bool) -> Self {
8688        self.human = Some(human);
8689        self
8690    }
8691    #[doc = "Whether specified concrete indices should be ignored when unavailable (missing or closed)"]
8692    pub fn ignore_unavailable(mut self, ignore_unavailable: bool) -> Self {
8693        self.ignore_unavailable = Some(ignore_unavailable);
8694        self
8695    }
8696    #[doc = "Specify whether format-based query failures (such as providing text to a numeric field) should be ignored"]
8697    pub fn lenient(mut self, lenient: bool) -> Self {
8698        self.lenient = Some(lenient);
8699        self
8700    }
8701    #[doc = "Maximum number of documents to process (default: all documents)"]
8702    pub fn max_docs(mut self, max_docs: i64) -> Self {
8703        self.max_docs = Some(max_docs);
8704        self
8705    }
8706    #[doc = "Ingest pipeline to set on index requests made by this action. (default: none)"]
8707    pub fn pipeline(mut self, pipeline: &'b str) -> Self {
8708        self.pipeline = Some(pipeline);
8709        self
8710    }
8711    #[doc = "Specify the node or shard the operation should be performed on (default: random)"]
8712    pub fn preference(mut self, preference: &'b str) -> Self {
8713        self.preference = Some(preference);
8714        self
8715    }
8716    #[doc = "Pretty format the returned JSON response."]
8717    pub fn pretty(mut self, pretty: bool) -> Self {
8718        self.pretty = Some(pretty);
8719        self
8720    }
8721    #[doc = "Query in the Lucene query string syntax"]
8722    pub fn q(mut self, q: &'b str) -> Self {
8723        self.q = Some(q);
8724        self
8725    }
8726    #[doc = "Should the affected indexes be refreshed?"]
8727    pub fn refresh(mut self, refresh: bool) -> Self {
8728        self.refresh = Some(refresh);
8729        self
8730    }
8731    #[doc = "Specify if request cache should be used for this request or not, defaults to index level setting"]
8732    pub fn request_cache(mut self, request_cache: bool) -> Self {
8733        self.request_cache = Some(request_cache);
8734        self
8735    }
8736    #[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."]
8737    pub fn request_timeout(mut self, timeout: Duration) -> Self {
8738        self.request_timeout = Some(timeout);
8739        self
8740    }
8741    #[doc = "The throttle to set on this request in sub-requests per second. -1 means no throttle."]
8742    pub fn requests_per_second(mut self, requests_per_second: i64) -> Self {
8743        self.requests_per_second = Some(requests_per_second);
8744        self
8745    }
8746    #[doc = "A comma-separated list of specific routing values"]
8747    pub fn routing(mut self, routing: &'b [&'b str]) -> Self {
8748        self.routing = Some(routing);
8749        self
8750    }
8751    #[doc = "Specify how long a consistent view of the index should be maintained for scrolled search"]
8752    pub fn scroll(mut self, scroll: &'b str) -> Self {
8753        self.scroll = Some(scroll);
8754        self
8755    }
8756    #[doc = "Size on the scroll request powering the update by query"]
8757    pub fn scroll_size(mut self, scroll_size: i64) -> Self {
8758        self.scroll_size = Some(scroll_size);
8759        self
8760    }
8761    #[doc = "Explicit timeout for each search request. Defaults to no timeout."]
8762    pub fn search_timeout(mut self, search_timeout: &'b str) -> Self {
8763        self.search_timeout = Some(search_timeout);
8764        self
8765    }
8766    #[doc = "Search operation type"]
8767    pub fn search_type(mut self, search_type: SearchType) -> Self {
8768        self.search_type = Some(search_type);
8769        self
8770    }
8771    #[doc = "Deprecated, please use `max_docs` instead"]
8772    pub fn size(mut self, size: i64) -> Self {
8773        self.size = Some(size);
8774        self
8775    }
8776    #[doc = "The number of slices this task should be divided into. Defaults to 1, meaning the task isn't sliced into subtasks. Can be set to `auto`."]
8777    pub fn slices(mut self, slices: Slices) -> Self {
8778        self.slices = Some(slices);
8779        self
8780    }
8781    #[doc = "A comma-separated list of &lt;field&gt;:&lt;direction&gt; pairs"]
8782    pub fn sort(mut self, sort: &'b [&'b str]) -> Self {
8783        self.sort = Some(sort);
8784        self
8785    }
8786    #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
8787    pub fn source(mut self, source: &'b str) -> Self {
8788        self.source = Some(source);
8789        self
8790    }
8791    #[doc = "Specific 'tag' of the request for logging and statistical purposes"]
8792    pub fn stats(mut self, stats: &'b [&'b str]) -> Self {
8793        self.stats = Some(stats);
8794        self
8795    }
8796    #[doc = "The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early."]
8797    pub fn terminate_after(mut self, terminate_after: i64) -> Self {
8798        self.terminate_after = Some(terminate_after);
8799        self
8800    }
8801    #[doc = "Time each individual bulk request should wait for shards that are unavailable."]
8802    pub fn timeout(mut self, timeout: &'b str) -> Self {
8803        self.timeout = Some(timeout);
8804        self
8805    }
8806    #[doc = "Specify whether to return document version as part of a hit"]
8807    pub fn version(mut self, version: bool) -> Self {
8808        self.version = Some(version);
8809        self
8810    }
8811    #[doc = "Should the document increment the version number (internal) on hit or not (reindex)"]
8812    pub fn version_type(mut self, version_type: bool) -> Self {
8813        self.version_type = Some(version_type);
8814        self
8815    }
8816    #[doc = "Sets the number of shard copies that must be active before proceeding with the update by query operation. Defaults to 1, meaning the primary shard only. 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)"]
8817    pub fn wait_for_active_shards(mut self, wait_for_active_shards: &'b str) -> Self {
8818        self.wait_for_active_shards = Some(wait_for_active_shards);
8819        self
8820    }
8821    #[doc = "Should the request should block until the update by query operation is complete."]
8822    pub fn wait_for_completion(mut self, wait_for_completion: bool) -> Self {
8823        self.wait_for_completion = Some(wait_for_completion);
8824        self
8825    }
8826    #[doc = "Creates an asynchronous call to the Update By Query API that can be awaited"]
8827    pub async fn send(self) -> Result<Response, Error> {
8828        let path = self.parts.url();
8829        let method = Method::Post;
8830        let headers = self.headers;
8831        let timeout = self.request_timeout;
8832        let query_string = {
8833            #[serde_with::skip_serializing_none]
8834            #[derive(Serialize)]
8835            struct QueryParams<'b> {
8836                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
8837                _source: Option<&'b [&'b str]>,
8838                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
8839                _source_excludes: Option<&'b [&'b str]>,
8840                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
8841                _source_includes: Option<&'b [&'b str]>,
8842                allow_no_indices: Option<bool>,
8843                analyze_wildcard: Option<bool>,
8844                analyzer: Option<&'b str>,
8845                conflicts: Option<Conflicts>,
8846                default_operator: Option<DefaultOperator>,
8847                df: Option<&'b str>,
8848                error_trace: Option<bool>,
8849                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
8850                expand_wildcards: Option<&'b [ExpandWildcards]>,
8851                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
8852                filter_path: Option<&'b [&'b str]>,
8853                from: Option<i64>,
8854                human: Option<bool>,
8855                ignore_unavailable: Option<bool>,
8856                lenient: Option<bool>,
8857                max_docs: Option<i64>,
8858                pipeline: Option<&'b str>,
8859                preference: Option<&'b str>,
8860                pretty: Option<bool>,
8861                q: Option<&'b str>,
8862                refresh: Option<bool>,
8863                request_cache: Option<bool>,
8864                requests_per_second: Option<i64>,
8865                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
8866                routing: Option<&'b [&'b str]>,
8867                scroll: Option<&'b str>,
8868                scroll_size: Option<i64>,
8869                search_timeout: Option<&'b str>,
8870                search_type: Option<SearchType>,
8871                size: Option<i64>,
8872                slices: Option<Slices>,
8873                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
8874                sort: Option<&'b [&'b str]>,
8875                source: Option<&'b str>,
8876                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
8877                stats: Option<&'b [&'b str]>,
8878                terminate_after: Option<i64>,
8879                timeout: Option<&'b str>,
8880                version: Option<bool>,
8881                version_type: Option<bool>,
8882                wait_for_active_shards: Option<&'b str>,
8883                wait_for_completion: Option<bool>,
8884            }
8885            let query_params = QueryParams {
8886                _source: self._source,
8887                _source_excludes: self._source_excludes,
8888                _source_includes: self._source_includes,
8889                allow_no_indices: self.allow_no_indices,
8890                analyze_wildcard: self.analyze_wildcard,
8891                analyzer: self.analyzer,
8892                conflicts: self.conflicts,
8893                default_operator: self.default_operator,
8894                df: self.df,
8895                error_trace: self.error_trace,
8896                expand_wildcards: self.expand_wildcards,
8897                filter_path: self.filter_path,
8898                from: self.from,
8899                human: self.human,
8900                ignore_unavailable: self.ignore_unavailable,
8901                lenient: self.lenient,
8902                max_docs: self.max_docs,
8903                pipeline: self.pipeline,
8904                preference: self.preference,
8905                pretty: self.pretty,
8906                q: self.q,
8907                refresh: self.refresh,
8908                request_cache: self.request_cache,
8909                requests_per_second: self.requests_per_second,
8910                routing: self.routing,
8911                scroll: self.scroll,
8912                scroll_size: self.scroll_size,
8913                search_timeout: self.search_timeout,
8914                search_type: self.search_type,
8915                size: self.size,
8916                slices: self.slices,
8917                sort: self.sort,
8918                source: self.source,
8919                stats: self.stats,
8920                terminate_after: self.terminate_after,
8921                timeout: self.timeout,
8922                version: self.version,
8923                version_type: self.version_type,
8924                wait_for_active_shards: self.wait_for_active_shards,
8925                wait_for_completion: self.wait_for_completion,
8926            };
8927            Some(query_params)
8928        };
8929        let body = self.body;
8930        let response = self
8931            .transport
8932            .send(method, &path, headers, query_string.as_ref(), body, timeout)
8933            .await?;
8934        Ok(response)
8935    }
8936}
8937#[derive(Debug, Clone, PartialEq, Eq)]
8938#[doc = "API parts for the Update By Query Rethrottle API"]
8939pub enum UpdateByQueryRethrottleParts<'b> {
8940    #[doc = "TaskId"]
8941    TaskId(&'b str),
8942}
8943impl<'b> UpdateByQueryRethrottleParts<'b> {
8944    #[doc = "Builds a relative URL path to the Update By Query Rethrottle API"]
8945    pub fn url(self) -> Cow<'static, str> {
8946        match self {
8947            UpdateByQueryRethrottleParts::TaskId(task_id) => {
8948                let encoded_task_id: Cow<str> =
8949                    percent_encode(task_id.as_bytes(), PARTS_ENCODED).into();
8950                let mut p = String::with_capacity(30usize + encoded_task_id.len());
8951                p.push_str("/_update_by_query/");
8952                p.push_str(encoded_task_id.as_ref());
8953                p.push_str("/_rethrottle");
8954                p.into()
8955            }
8956        }
8957    }
8958}
8959#[doc = "Builder for the [Update By Query Rethrottle API](https://opensearch.org/docs/)\n\nChanges the number of requests per second for a particular Update By Query operation."]
8960#[derive(Clone, Debug)]
8961pub struct UpdateByQueryRethrottle<'a, 'b, B> {
8962    transport: &'a Transport,
8963    parts: UpdateByQueryRethrottleParts<'b>,
8964    body: Option<B>,
8965    error_trace: Option<bool>,
8966    filter_path: Option<&'b [&'b str]>,
8967    headers: HeaderMap,
8968    human: Option<bool>,
8969    pretty: Option<bool>,
8970    request_timeout: Option<Duration>,
8971    requests_per_second: Option<i64>,
8972    source: Option<&'b str>,
8973}
8974impl<'a, 'b, B> UpdateByQueryRethrottle<'a, 'b, B>
8975where
8976    B: Body,
8977{
8978    #[doc = "Creates a new instance of [UpdateByQueryRethrottle] with the specified API parts"]
8979    pub fn new(transport: &'a Transport, parts: UpdateByQueryRethrottleParts<'b>) -> Self {
8980        let headers = HeaderMap::new();
8981        UpdateByQueryRethrottle {
8982            transport,
8983            parts,
8984            headers,
8985            body: None,
8986            error_trace: None,
8987            filter_path: None,
8988            human: None,
8989            pretty: None,
8990            request_timeout: None,
8991            requests_per_second: None,
8992            source: None,
8993        }
8994    }
8995    #[doc = "The body for the API call"]
8996    pub fn body<T>(self, body: T) -> UpdateByQueryRethrottle<'a, 'b, JsonBody<T>>
8997    where
8998        T: Serialize,
8999    {
9000        UpdateByQueryRethrottle {
9001            transport: self.transport,
9002            parts: self.parts,
9003            body: Some(body.into()),
9004            error_trace: self.error_trace,
9005            filter_path: self.filter_path,
9006            headers: self.headers,
9007            human: self.human,
9008            pretty: self.pretty,
9009            request_timeout: self.request_timeout,
9010            requests_per_second: self.requests_per_second,
9011            source: self.source,
9012        }
9013    }
9014    #[doc = "Include the stack trace of returned errors."]
9015    pub fn error_trace(mut self, error_trace: bool) -> Self {
9016        self.error_trace = Some(error_trace);
9017        self
9018    }
9019    #[doc = "A comma-separated list of filters used to reduce the response."]
9020    pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
9021        self.filter_path = Some(filter_path);
9022        self
9023    }
9024    #[doc = "Adds a HTTP header"]
9025    pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
9026        self.headers.insert(key, value);
9027        self
9028    }
9029    #[doc = "Return human readable values for statistics."]
9030    pub fn human(mut self, human: bool) -> Self {
9031        self.human = Some(human);
9032        self
9033    }
9034    #[doc = "Pretty format the returned JSON response."]
9035    pub fn pretty(mut self, pretty: bool) -> Self {
9036        self.pretty = Some(pretty);
9037        self
9038    }
9039    #[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."]
9040    pub fn request_timeout(mut self, timeout: Duration) -> Self {
9041        self.request_timeout = Some(timeout);
9042        self
9043    }
9044    #[doc = "The throttle to set on this request in floating sub-requests per second. -1 means set no throttle."]
9045    pub fn requests_per_second(mut self, requests_per_second: i64) -> Self {
9046        self.requests_per_second = Some(requests_per_second);
9047        self
9048    }
9049    #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
9050    pub fn source(mut self, source: &'b str) -> Self {
9051        self.source = Some(source);
9052        self
9053    }
9054    #[doc = "Creates an asynchronous call to the Update By Query Rethrottle API that can be awaited"]
9055    pub async fn send(self) -> Result<Response, Error> {
9056        let path = self.parts.url();
9057        let method = Method::Post;
9058        let headers = self.headers;
9059        let timeout = self.request_timeout;
9060        let query_string = {
9061            #[serde_with::skip_serializing_none]
9062            #[derive(Serialize)]
9063            struct QueryParams<'b> {
9064                error_trace: Option<bool>,
9065                #[serde(serialize_with = "crate::client::serialize_coll_qs")]
9066                filter_path: Option<&'b [&'b str]>,
9067                human: Option<bool>,
9068                pretty: Option<bool>,
9069                requests_per_second: Option<i64>,
9070                source: Option<&'b str>,
9071            }
9072            let query_params = QueryParams {
9073                error_trace: self.error_trace,
9074                filter_path: self.filter_path,
9075                human: self.human,
9076                pretty: self.pretty,
9077                requests_per_second: self.requests_per_second,
9078                source: self.source,
9079            };
9080            Some(query_params)
9081        };
9082        let body = self.body;
9083        let response = self
9084            .transport
9085            .send(method, &path, headers, query_string.as_ref(), body, timeout)
9086            .await?;
9087        Ok(response)
9088    }
9089}
9090impl OpenSearch {
9091    #[doc = "[Bulk API](https://opensearch.org/docs/)\n\nAllows to perform multiple index/update/delete operations in a single request."]
9092    pub fn bulk<'a, 'b>(&'a self, parts: BulkParts<'b>) -> Bulk<'a, 'b, ()> {
9093        Bulk::new(self.transport(), parts)
9094    }
9095    #[doc = "[Clear Scroll API](https://opensearch.org/docs/)\n\nExplicitly clears the search context for a scroll."]
9096    pub fn clear_scroll<'a, 'b>(&'a self, parts: ClearScrollParts<'b>) -> ClearScroll<'a, 'b, ()> {
9097        ClearScroll::new(self.transport(), parts)
9098    }
9099    #[doc = "[Count API](https://opensearch.org/docs/)\n\nReturns number of documents matching a query."]
9100    pub fn count<'a, 'b>(&'a self, parts: CountParts<'b>) -> Count<'a, 'b, ()> {
9101        Count::new(self.transport(), parts)
9102    }
9103    #[doc = "[Create API](https://opensearch.org/docs/)\n\nCreates a new document in the index.\n\nReturns a 409 response when a document with a same ID already exists in the index."]
9104    pub fn create<'a, 'b>(&'a self, parts: CreateParts<'b>) -> Create<'a, 'b, ()> {
9105        Create::new(self.transport(), parts)
9106    }
9107    #[doc = "[Create Pit API](https://opensearch.org/docs/latest/opensearch/rest-api/point_in_time/)\n\nCreates point in time context."]
9108    pub fn create_pit<'a, 'b>(&'a self, parts: CreatePitParts<'b>) -> CreatePit<'a, 'b, ()> {
9109        CreatePit::new(self.transport(), parts)
9110    }
9111    #[doc = "[Delete API](https://opensearch.org/docs/)\n\nRemoves a document from the index."]
9112    pub fn delete<'a, 'b>(&'a self, parts: DeleteParts<'b>) -> Delete<'a, 'b> {
9113        Delete::new(self.transport(), parts)
9114    }
9115    #[doc = "[Delete All Pits API](https://opensearch.org/docs/latest/opensearch/rest-api/point_in_time/)\n\nDeletes all active point in time searches."]
9116    pub fn delete_all_pits<'a, 'b>(&'a self) -> DeleteAllPits<'a, 'b> {
9117        DeleteAllPits::new(self.transport())
9118    }
9119    #[doc = "[Delete By Query API](https://opensearch.org/docs/)\n\nDeletes documents matching the provided query."]
9120    pub fn delete_by_query<'a, 'b>(
9121        &'a self,
9122        parts: DeleteByQueryParts<'b>,
9123    ) -> DeleteByQuery<'a, 'b, ()> {
9124        DeleteByQuery::new(self.transport(), parts)
9125    }
9126    #[doc = "[Delete By Query Rethrottle API](https://opensearch.org/docs/)\n\nChanges the number of requests per second for a particular Delete By Query operation."]
9127    pub fn delete_by_query_rethrottle<'a, 'b>(
9128        &'a self,
9129        parts: DeleteByQueryRethrottleParts<'b>,
9130    ) -> DeleteByQueryRethrottle<'a, 'b, ()> {
9131        DeleteByQueryRethrottle::new(self.transport(), parts)
9132    }
9133    #[doc = "[Delete Pit API](https://opensearch.org/docs/latest/opensearch/rest-api/point_in_time/)\n\nDeletes one or more point in time searches based on the IDs passed."]
9134    pub fn delete_pit<'a, 'b>(&'a self) -> DeletePit<'a, 'b, ()> {
9135        DeletePit::new(self.transport())
9136    }
9137    #[doc = "[Delete Script API](https://opensearch.org/docs/)\n\nDeletes a script."]
9138    pub fn delete_script<'a, 'b>(&'a self, parts: DeleteScriptParts<'b>) -> DeleteScript<'a, 'b> {
9139        DeleteScript::new(self.transport(), parts)
9140    }
9141    #[doc = "[Exists API](https://opensearch.org/docs/)\n\nReturns information about whether a document exists in an index."]
9142    pub fn exists<'a, 'b>(&'a self, parts: ExistsParts<'b>) -> Exists<'a, 'b> {
9143        Exists::new(self.transport(), parts)
9144    }
9145    #[doc = "[Exists Source API](https://opensearch.org/docs/)\n\nReturns information about whether a document source exists in an index."]
9146    pub fn exists_source<'a, 'b>(&'a self, parts: ExistsSourceParts<'b>) -> ExistsSource<'a, 'b> {
9147        ExistsSource::new(self.transport(), parts)
9148    }
9149    #[doc = "[Explain API](https://opensearch.org/docs/)\n\nReturns information about why a specific matches (or doesn't match) a query."]
9150    pub fn explain<'a, 'b>(&'a self, parts: ExplainParts<'b>) -> Explain<'a, 'b, ()> {
9151        Explain::new(self.transport(), parts)
9152    }
9153    #[doc = "[Field Caps API](https://opensearch.org/docs/)\n\nReturns the information about the capabilities of fields among multiple indices."]
9154    pub fn field_caps<'a, 'b>(&'a self, parts: FieldCapsParts<'b>) -> FieldCaps<'a, 'b, ()> {
9155        FieldCaps::new(self.transport(), parts)
9156    }
9157    #[doc = "[Get API](https://opensearch.org/docs/)\n\nReturns a document."]
9158    pub fn get<'a, 'b>(&'a self, parts: GetParts<'b>) -> Get<'a, 'b> {
9159        Get::new(self.transport(), parts)
9160    }
9161    #[doc = "[Get All Pits API](https://opensearch.org/docs/latest/opensearch/rest-api/point_in_time/)\n\nLists all active point in time searches."]
9162    pub fn get_all_pits<'a, 'b>(&'a self) -> GetAllPits<'a, 'b> {
9163        GetAllPits::new(self.transport())
9164    }
9165    #[doc = "[Get Script API](https://opensearch.org/docs/)\n\nReturns a script."]
9166    pub fn get_script<'a, 'b>(&'a self, parts: GetScriptParts<'b>) -> GetScript<'a, 'b> {
9167        GetScript::new(self.transport(), parts)
9168    }
9169    #[doc = "[Get Script Context API](https://opensearch.org/docs/)\n\nReturns all script contexts."]
9170    #[doc = "&nbsp;\n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n        "]
9171    #[cfg(feature = "experimental-apis")]
9172    pub fn get_script_context<'a, 'b>(&'a self) -> GetScriptContext<'a, 'b> {
9173        GetScriptContext::new(self.transport())
9174    }
9175    #[doc = "[Get Script Languages API](https://opensearch.org/docs/)\n\nReturns available script types, languages and contexts"]
9176    #[doc = "&nbsp;\n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n        "]
9177    #[cfg(feature = "experimental-apis")]
9178    pub fn get_script_languages<'a, 'b>(&'a self) -> GetScriptLanguages<'a, 'b> {
9179        GetScriptLanguages::new(self.transport())
9180    }
9181    #[doc = "[Get Source API](https://opensearch.org/docs/)\n\nReturns the source of a document."]
9182    pub fn get_source<'a, 'b>(&'a self, parts: GetSourceParts<'b>) -> GetSource<'a, 'b> {
9183        GetSource::new(self.transport(), parts)
9184    }
9185    #[doc = "[Index API](https://opensearch.org/docs/)\n\nCreates or updates a document in an index."]
9186    pub fn index<'a, 'b>(&'a self, parts: IndexParts<'b>) -> Index<'a, 'b, ()> {
9187        Index::new(self.transport(), parts)
9188    }
9189    #[doc = "[Info API](https://opensearch.org/docs/)\n\nReturns basic information about the cluster."]
9190    pub fn info<'a, 'b>(&'a self) -> Info<'a, 'b> {
9191        Info::new(self.transport())
9192    }
9193    #[doc = "[Mget API](https://opensearch.org/docs/)\n\nAllows to get multiple documents in one request."]
9194    pub fn mget<'a, 'b>(&'a self, parts: MgetParts<'b>) -> Mget<'a, 'b, ()> {
9195        Mget::new(self.transport(), parts)
9196    }
9197    #[doc = "[Msearch API](https://opensearch.org/docs/)\n\nAllows to execute several search operations in one request."]
9198    pub fn msearch<'a, 'b>(&'a self, parts: MsearchParts<'b>) -> Msearch<'a, 'b, ()> {
9199        Msearch::new(self.transport(), parts)
9200    }
9201    #[doc = "[Msearch Template API](https://opensearch.org/docs/)\n\nAllows to execute several search template operations in one request."]
9202    pub fn msearch_template<'a, 'b>(
9203        &'a self,
9204        parts: MsearchTemplateParts<'b>,
9205    ) -> MsearchTemplate<'a, 'b, ()> {
9206        MsearchTemplate::new(self.transport(), parts)
9207    }
9208    #[doc = "[Mtermvectors API](https://opensearch.org/docs/)\n\nReturns multiple termvectors in one request."]
9209    pub fn mtermvectors<'a, 'b>(
9210        &'a self,
9211        parts: MtermvectorsParts<'b>,
9212    ) -> Mtermvectors<'a, 'b, ()> {
9213        Mtermvectors::new(self.transport(), parts)
9214    }
9215    #[doc = "[Ping API](https://opensearch.org/docs/)\n\nReturns whether the cluster is running."]
9216    pub fn ping<'a, 'b>(&'a self) -> Ping<'a, 'b> {
9217        Ping::new(self.transport())
9218    }
9219    #[doc = "[Put Script API](https://opensearch.org/docs/)\n\nCreates or updates a script."]
9220    pub fn put_script<'a, 'b>(&'a self, parts: PutScriptParts<'b>) -> PutScript<'a, 'b, ()> {
9221        PutScript::new(self.transport(), parts)
9222    }
9223    #[doc = "[Rank Eval API](https://opensearch.org/docs/)\n\nAllows to evaluate the quality of ranked search results over a set of typical search queries"]
9224    #[doc = "&nbsp;\n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n        "]
9225    #[cfg(feature = "experimental-apis")]
9226    pub fn rank_eval<'a, 'b>(&'a self, parts: RankEvalParts<'b>) -> RankEval<'a, 'b, ()> {
9227        RankEval::new(self.transport(), parts)
9228    }
9229    #[doc = "[Reindex API](https://opensearch.org/docs/)\n\nAllows to copy documents from one index to another, optionally filtering the source\ndocuments by a query, changing the destination index settings, or fetching the\ndocuments from a remote cluster."]
9230    pub fn reindex<'a, 'b>(&'a self) -> Reindex<'a, 'b, ()> {
9231        Reindex::new(self.transport())
9232    }
9233    #[doc = "[Reindex Rethrottle API](https://opensearch.org/docs/)\n\nChanges the number of requests per second for a particular Reindex operation."]
9234    pub fn reindex_rethrottle<'a, 'b>(
9235        &'a self,
9236        parts: ReindexRethrottleParts<'b>,
9237    ) -> ReindexRethrottle<'a, 'b, ()> {
9238        ReindexRethrottle::new(self.transport(), parts)
9239    }
9240    #[doc = "[Render Search Template API](https://opensearch.org/docs/)\n\nAllows to use the Mustache language to pre-render a search definition."]
9241    pub fn render_search_template<'a, 'b>(
9242        &'a self,
9243        parts: RenderSearchTemplateParts<'b>,
9244    ) -> RenderSearchTemplate<'a, 'b, ()> {
9245        RenderSearchTemplate::new(self.transport(), parts)
9246    }
9247    #[doc = "[Scripts Painless Execute API](https://opensearch.org/docs/)\n\nAllows an arbitrary script to be executed and a result to be returned"]
9248    #[doc = "&nbsp;\n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n        "]
9249    #[cfg(feature = "experimental-apis")]
9250    pub fn scripts_painless_execute<'a, 'b>(&'a self) -> ScriptsPainlessExecute<'a, 'b, ()> {
9251        ScriptsPainlessExecute::new(self.transport())
9252    }
9253    #[doc = "[Scroll API](https://opensearch.org/docs/)\n\nAllows to retrieve a large numbers of results from a single search request.\n\n# Examples\n\nTo initiate a scroll, make search API call with a specified `scroll` timeout,\nthen fetch the next set of hits using the `_scroll_id` returned in\nthe response. Once no more hits are returned, clear the scroll.\n\n```rust,no_run\n# use opensearch::{OpenSearch, Error, SearchParts, ScrollParts, ClearScrollParts};\n# use serde_json::{json, Value};\n# async fn doc() -> Result<(), Box<dyn std::error::Error>> {\nlet client = OpenSearch::default();\n\nfn print_hits(hits: &[Value]) {\n    for hit in hits {\n        println!(\n            \"id: '{}', source: '{}', score: '{}'\",\n            hit[\"_id\"].as_str().unwrap(),\n            hit[\"_source\"],\n            hit[\"_score\"].as_f64().unwrap()\n        );\n    }\n}\n\nlet scroll = \"1m\";\nlet mut response = client\n    .search(SearchParts::Index(&[\"tweets\"]))\n    .scroll(scroll)\n    .body(json!({\n        \"query\": {\n            \"match\": {\n                \"body\": {\n                    \"query\": \"OpenSearch rust\",\n                    \"operator\": \"AND\"\n                }\n            }\n        }\n    }))\n    .send()\n    .await?;\n\nlet mut response_body = response.json::<Value>().await?;\nlet mut scroll_id = response_body[\"_scroll_id\"].as_str().unwrap();\nlet mut hits = response_body[\"hits\"][\"hits\"].as_array().unwrap();\n\nprint_hits(hits);\n\nwhile hits.len() > 0 {\n    response = client\n        .scroll(ScrollParts::None)\n        .body(json!({\n            \"scroll\": scroll,\n            \"scroll_id\": scroll_id\n        }))\n        .send()\n        .await?;\n\n    response_body = response.json::<Value>().await?;\n    scroll_id = response_body[\"_scroll_id\"].as_str().unwrap();\n    hits = response_body[\"hits\"][\"hits\"].as_array().unwrap();\n    print_hits(hits);\n}\n\nresponse = client\n    .clear_scroll(ClearScrollParts::None)\n    .body(json!({\n        \"scroll_id\": scroll_id\n    }))\n    .send()\n    .await?;\n    \n# Ok(())\n# }\n```"]
9254    pub fn scroll<'a, 'b>(&'a self, parts: ScrollParts<'b>) -> Scroll<'a, 'b, ()> {
9255        Scroll::new(self.transport(), parts)
9256    }
9257    #[doc = "[Search API](https://opensearch.org/docs/)\n\nReturns results matching a query."]
9258    pub fn search<'a, 'b>(&'a self, parts: SearchParts<'b>) -> Search<'a, 'b, ()> {
9259        Search::new(self.transport(), parts)
9260    }
9261    #[doc = "[Search Shards API](https://opensearch.org/docs/)\n\nReturns information about the indices and shards that a search request would be executed against."]
9262    pub fn search_shards<'a, 'b>(
9263        &'a self,
9264        parts: SearchShardsParts<'b>,
9265    ) -> SearchShards<'a, 'b, ()> {
9266        SearchShards::new(self.transport(), parts)
9267    }
9268    #[doc = "[Search Template API](https://opensearch.org/docs/)\n\nAllows to use the Mustache language to pre-render a search definition."]
9269    pub fn search_template<'a, 'b>(
9270        &'a self,
9271        parts: SearchTemplateParts<'b>,
9272    ) -> SearchTemplate<'a, 'b, ()> {
9273        SearchTemplate::new(self.transport(), parts)
9274    }
9275    #[doc = "[Termvectors API](https://opensearch.org/docs/)\n\nReturns information and statistics about terms in the fields of a particular document."]
9276    pub fn termvectors<'a, 'b>(&'a self, parts: TermvectorsParts<'b>) -> Termvectors<'a, 'b, ()> {
9277        Termvectors::new(self.transport(), parts)
9278    }
9279    #[doc = "[Update API](https://opensearch.org/docs/)\n\nUpdates a document with a script or partial document."]
9280    pub fn update<'a, 'b>(&'a self, parts: UpdateParts<'b>) -> Update<'a, 'b, ()> {
9281        Update::new(self.transport(), parts)
9282    }
9283    #[doc = "[Update By Query API](https://opensearch.org/docs/)\n\nPerforms an update on every document in the index without changing the source,\nfor example to pick up a mapping change."]
9284    pub fn update_by_query<'a, 'b>(
9285        &'a self,
9286        parts: UpdateByQueryParts<'b>,
9287    ) -> UpdateByQuery<'a, 'b, ()> {
9288        UpdateByQuery::new(self.transport(), parts)
9289    }
9290    #[doc = "[Update By Query Rethrottle API](https://opensearch.org/docs/)\n\nChanges the number of requests per second for a particular Update By Query operation."]
9291    pub fn update_by_query_rethrottle<'a, 'b>(
9292        &'a self,
9293        parts: UpdateByQueryRethrottleParts<'b>,
9294    ) -> UpdateByQueryRethrottle<'a, 'b, ()> {
9295        UpdateByQueryRethrottle::new(self.transport(), parts)
9296    }
9297}
9298
9299mod bulk;
9300pub use bulk::*;