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