/* * Licensed to Elasticsearch B.V. under one or more contributor * license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright * ownership. Elasticsearch B.V. licenses this file to you under * the Apache License, Version 2.0 (the "License"); you may * not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ // ----------------------------------------------- // This file is generated, Please do not edit it manually. // Run the following in the root of the repo to regenerate: // // cargo make generate-api // ----------------------------------------------- //! Cat APIs //! //! The [Cat APIs](https://opensearch.org/docs/opensearch/rest-api/cat/index/) aim to //! meet the needs of humans when looking at data returned from OpenSearch, //! formatting it as compact, column aligned text, making it easier on human eyes. //! //! # Plain text responses //! //! By default, all Cat APIs are configured to send requests with `text/plain` content-type //! and accept headers, returning plain text responses //! //! ```rust,no_run //! # use opensearch::{OpenSearch, Error, SearchParts}; //! # use url::Url; //! # use opensearch::auth::Credentials; //! # use serde_json::{json, Value}; //! # async fn doc() -> Result<(), Box> { //! # let client = OpenSearch::default(); //! let response = client //! .cat() //! .nodes() //! .send() //! .await?; //! //! let response_body = response.text().await?; //! # Ok(()) //! # } //! ``` //! //! # JSON responses //! //! JSON responses can be returned from Cat APIs either by using `.format("json")` //! //! ```rust,no_run //! # use opensearch::{OpenSearch, Error, SearchParts}; //! # use url::Url; //! # use opensearch::auth::Credentials; //! # use serde_json::{json, Value}; //! # async fn doc() -> Result<(), Box> { //! # let client = OpenSearch::default(); //! let response = client //! .cat() //! .nodes() //! .format("json") //! .send() //! .await?; //! //! let response_body = response.json::().await?; //! # Ok(()) //! # } //! ``` //! //! Or by setting an accept header using `.headers()` //! //! ```rust,no_run //! # use opensearch::{OpenSearch, Error, SearchParts, http::headers::{HeaderValue, DEFAULT_ACCEPT, ACCEPT}}; //! # use url::Url; //! # use serde_json::{json, Value}; //! # async fn doc() -> Result<(), Box> { //! # let client = OpenSearch::default(); //! let response = client //! .cat() //! .nodes() //! .header(ACCEPT, HeaderValue::from_static(DEFAULT_ACCEPT)) //! .send() //! .await?; //! //! let response_body = response.json::().await?; //! # Ok(()) //! # } //! ``` //! //! # Column Headers //! //! The column headers to return can be controlled with `.h()` //! //! ```rust,no_run //! # use opensearch::{OpenSearch, Error, SearchParts}; //! # use url::Url; //! # use serde_json::{json, Value}; //! # async fn doc() -> Result<(), Box> { //! # let client = OpenSearch::default(); //! let response = client //! .cat() //! .nodes() //! .h(&["ip", "port", "heapPercent", "name"]) //! .send() //! .await?; //! //! let response_body = response.json::().await?; //! # Ok(()) //! # } //! ``` //! #![allow(unused_imports)] use crate::{ client::OpenSearch, error::Error, http::{ headers::{HeaderMap, HeaderName, HeaderValue, ACCEPT, CONTENT_TYPE}, request::{Body, JsonBody, NdBody, PARTS_ENCODED}, response::Response, transport::Transport, Method, }, params::*, }; use percent_encoding::percent_encode; use serde::Serialize; use std::{borrow::Cow, time::Duration}; #[derive(Debug, Clone, PartialEq, Eq)] #[doc = "API parts for the Cat Aliases API"] pub enum CatAliasesParts<'b> { #[doc = "No parts"] None, #[doc = "Name"] Name(&'b [&'b str]), } impl<'b> CatAliasesParts<'b> { #[doc = "Builds a relative URL path to the Cat Aliases API"] pub fn url(self) -> Cow<'static, str> { match self { CatAliasesParts::None => "/_cat/aliases".into(), CatAliasesParts::Name(name) => { let name_str = name.join(","); let encoded_name: Cow = percent_encode(name_str.as_bytes(), PARTS_ENCODED).into(); let mut p = String::with_capacity(14usize + encoded_name.len()); p.push_str("/_cat/aliases/"); p.push_str(encoded_name.as_ref()); p.into() } } } } #[doc = "Builder for the [Cat Aliases API](https://opensearch.org/docs/)\n\nShows information about currently configured aliases to indices including filter and routing infos."] #[derive(Clone, Debug)] pub struct CatAliases<'a, 'b> { transport: &'a Transport, parts: CatAliasesParts<'b>, error_trace: Option, expand_wildcards: Option<&'b [ExpandWildcards]>, filter_path: Option<&'b [&'b str]>, format: Option<&'b str>, h: Option<&'b [&'b str]>, headers: HeaderMap, help: Option, human: Option, local: Option, pretty: Option, request_timeout: Option, s: Option<&'b [&'b str]>, source: Option<&'b str>, v: Option, } impl<'a, 'b> CatAliases<'a, 'b> { #[doc = "Creates a new instance of [CatAliases] with the specified API parts"] pub fn new(transport: &'a Transport, parts: CatAliasesParts<'b>) -> Self { let mut headers = HeaderMap::with_capacity(2); headers.insert(CONTENT_TYPE, HeaderValue::from_static("text/plain")); headers.insert(ACCEPT, HeaderValue::from_static("text/plain")); CatAliases { transport, parts, headers, error_trace: None, expand_wildcards: None, filter_path: None, format: None, h: None, help: None, human: None, local: None, pretty: None, request_timeout: None, s: None, source: None, v: None, } } #[doc = "Include the stack trace of returned errors."] pub fn error_trace(mut self, error_trace: bool) -> Self { self.error_trace = Some(error_trace); self } #[doc = "Whether to expand wildcard expression to concrete indices that are open, closed or both."] pub fn expand_wildcards(mut self, expand_wildcards: &'b [ExpandWildcards]) -> Self { self.expand_wildcards = Some(expand_wildcards); self } #[doc = "A comma-separated list of filters used to reduce the response."] pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self { self.filter_path = Some(filter_path); self } #[doc = "a short version of the Accept header, e.g. json, yaml"] pub fn format(mut self, format: &'b str) -> Self { self.format = Some(format); self } #[doc = "Comma-separated list of column names to display"] pub fn h(mut self, h: &'b [&'b str]) -> Self { self.h = Some(h); self } #[doc = "Adds a HTTP header"] pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { self.headers.insert(key, value); self } #[doc = "Return help information"] pub fn help(mut self, help: bool) -> Self { self.help = Some(help); self } #[doc = "Return human readable values for statistics."] pub fn human(mut self, human: bool) -> Self { self.human = Some(human); self } #[doc = "Return local information, do not retrieve the state from cluster-manager node (default: false)"] pub fn local(mut self, local: bool) -> Self { self.local = Some(local); self } #[doc = "Pretty format the returned JSON response."] pub fn pretty(mut self, pretty: bool) -> Self { self.pretty = Some(pretty); self } #[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."] pub fn request_timeout(mut self, timeout: Duration) -> Self { self.request_timeout = Some(timeout); self } #[doc = "Comma-separated list of column names or column aliases to sort by"] pub fn s(mut self, s: &'b [&'b str]) -> Self { self.s = Some(s); self } #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."] pub fn source(mut self, source: &'b str) -> Self { self.source = Some(source); self } #[doc = "Verbose mode. Display column headers"] pub fn v(mut self, v: bool) -> Self { self.v = Some(v); self } #[doc = "Creates an asynchronous call to the Cat Aliases API that can be awaited"] pub async fn send(self) -> Result { let path = self.parts.url(); let method = Method::Get; let headers = self.headers; let timeout = self.request_timeout; let query_string = { #[serde_with::skip_serializing_none] #[derive(Serialize)] struct QueryParams<'b> { error_trace: Option, #[serde(serialize_with = "crate::client::serialize_coll_qs")] expand_wildcards: Option<&'b [ExpandWildcards]>, #[serde(serialize_with = "crate::client::serialize_coll_qs")] filter_path: Option<&'b [&'b str]>, format: Option<&'b str>, #[serde(serialize_with = "crate::client::serialize_coll_qs")] h: Option<&'b [&'b str]>, help: Option, human: Option, local: Option, pretty: Option, #[serde(serialize_with = "crate::client::serialize_coll_qs")] s: Option<&'b [&'b str]>, source: Option<&'b str>, v: Option, } let query_params = QueryParams { error_trace: self.error_trace, expand_wildcards: self.expand_wildcards, filter_path: self.filter_path, format: self.format, h: self.h, help: self.help, human: self.human, local: self.local, pretty: self.pretty, s: self.s, source: self.source, v: self.v, }; Some(query_params) }; let body = Option::<()>::None; let response = self .transport .send(method, &path, headers, query_string.as_ref(), body, timeout) .await?; Ok(response) } } #[derive(Debug, Clone, PartialEq, Eq)] #[doc = "API parts for the Cat Allocation API"] pub enum CatAllocationParts<'b> { #[doc = "No parts"] None, #[doc = "NodeId"] NodeId(&'b [&'b str]), } impl<'b> CatAllocationParts<'b> { #[doc = "Builds a relative URL path to the Cat Allocation API"] pub fn url(self) -> Cow<'static, str> { match self { CatAllocationParts::None => "/_cat/allocation".into(), CatAllocationParts::NodeId(node_id) => { let node_id_str = node_id.join(","); let encoded_node_id: Cow = percent_encode(node_id_str.as_bytes(), PARTS_ENCODED).into(); let mut p = String::with_capacity(17usize + encoded_node_id.len()); p.push_str("/_cat/allocation/"); p.push_str(encoded_node_id.as_ref()); p.into() } } } } #[doc = "Builder for the [Cat Allocation API](https://opensearch.org/docs/)\n\nProvides a snapshot of how many shards are allocated to each data node and how much disk space they are using."] #[derive(Clone, Debug)] pub struct CatAllocation<'a, 'b> { transport: &'a Transport, parts: CatAllocationParts<'b>, bytes: Option, cluster_manager_timeout: Option<&'b str>, error_trace: Option, filter_path: Option<&'b [&'b str]>, format: Option<&'b str>, h: Option<&'b [&'b str]>, headers: HeaderMap, help: Option, human: Option, local: Option, master_timeout: Option<&'b str>, pretty: Option, request_timeout: Option, s: Option<&'b [&'b str]>, source: Option<&'b str>, v: Option, } impl<'a, 'b> CatAllocation<'a, 'b> { #[doc = "Creates a new instance of [CatAllocation] with the specified API parts"] pub fn new(transport: &'a Transport, parts: CatAllocationParts<'b>) -> Self { let mut headers = HeaderMap::with_capacity(2); headers.insert(CONTENT_TYPE, HeaderValue::from_static("text/plain")); headers.insert(ACCEPT, HeaderValue::from_static("text/plain")); CatAllocation { transport, parts, headers, bytes: None, cluster_manager_timeout: None, error_trace: None, filter_path: None, format: None, h: None, help: None, human: None, local: None, master_timeout: None, pretty: None, request_timeout: None, s: None, source: None, v: None, } } #[doc = "The unit in which to display byte values"] pub fn bytes(mut self, bytes: Bytes) -> Self { self.bytes = Some(bytes); self } #[doc = "Explicit operation timeout for connection to cluster-manager node"] pub fn cluster_manager_timeout(mut self, cluster_manager_timeout: &'b str) -> Self { self.cluster_manager_timeout = Some(cluster_manager_timeout); self } #[doc = "Include the stack trace of returned errors."] pub fn error_trace(mut self, error_trace: bool) -> Self { self.error_trace = Some(error_trace); self } #[doc = "A comma-separated list of filters used to reduce the response."] pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self { self.filter_path = Some(filter_path); self } #[doc = "a short version of the Accept header, e.g. json, yaml"] pub fn format(mut self, format: &'b str) -> Self { self.format = Some(format); self } #[doc = "Comma-separated list of column names to display"] pub fn h(mut self, h: &'b [&'b str]) -> Self { self.h = Some(h); self } #[doc = "Adds a HTTP header"] pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { self.headers.insert(key, value); self } #[doc = "Return help information"] pub fn help(mut self, help: bool) -> Self { self.help = Some(help); self } #[doc = "Return human readable values for statistics."] pub fn human(mut self, human: bool) -> Self { self.human = Some(human); self } #[doc = "Return local information, do not retrieve the state from cluster-manager node (default: false)"] pub fn local(mut self, local: bool) -> Self { self.local = Some(local); self } #[doc = "Explicit operation timeout for connection to cluster-manager node"] #[deprecated = "To promote inclusive language, use 'cluster_manager_timeout' instead."] pub fn master_timeout(mut self, master_timeout: &'b str) -> Self { self.master_timeout = Some(master_timeout); self } #[doc = "Pretty format the returned JSON response."] pub fn pretty(mut self, pretty: bool) -> Self { self.pretty = Some(pretty); self } #[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."] pub fn request_timeout(mut self, timeout: Duration) -> Self { self.request_timeout = Some(timeout); self } #[doc = "Comma-separated list of column names or column aliases to sort by"] pub fn s(mut self, s: &'b [&'b str]) -> Self { self.s = Some(s); self } #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."] pub fn source(mut self, source: &'b str) -> Self { self.source = Some(source); self } #[doc = "Verbose mode. Display column headers"] pub fn v(mut self, v: bool) -> Self { self.v = Some(v); self } #[doc = "Creates an asynchronous call to the Cat Allocation API that can be awaited"] pub async fn send(self) -> Result { let path = self.parts.url(); let method = Method::Get; let headers = self.headers; let timeout = self.request_timeout; let query_string = { #[serde_with::skip_serializing_none] #[derive(Serialize)] struct QueryParams<'b> { bytes: Option, cluster_manager_timeout: Option<&'b str>, error_trace: Option, #[serde(serialize_with = "crate::client::serialize_coll_qs")] filter_path: Option<&'b [&'b str]>, format: Option<&'b str>, #[serde(serialize_with = "crate::client::serialize_coll_qs")] h: Option<&'b [&'b str]>, help: Option, human: Option, local: Option, master_timeout: Option<&'b str>, pretty: Option, #[serde(serialize_with = "crate::client::serialize_coll_qs")] s: Option<&'b [&'b str]>, source: Option<&'b str>, v: Option, } let query_params = QueryParams { bytes: self.bytes, cluster_manager_timeout: self.cluster_manager_timeout, error_trace: self.error_trace, filter_path: self.filter_path, format: self.format, h: self.h, help: self.help, human: self.human, local: self.local, master_timeout: self.master_timeout, pretty: self.pretty, s: self.s, source: self.source, v: self.v, }; Some(query_params) }; let body = Option::<()>::None; let response = self .transport .send(method, &path, headers, query_string.as_ref(), body, timeout) .await?; Ok(response) } } #[derive(Debug, Clone, PartialEq, Eq)] #[doc = "API parts for the Cat Cluster Manager API"] pub enum CatClusterManagerParts { #[doc = "No parts"] None, } impl CatClusterManagerParts { #[doc = "Builds a relative URL path to the Cat Cluster Manager API"] pub fn url(self) -> Cow<'static, str> { match self { CatClusterManagerParts::None => "/_cat/cluster_manager".into(), } } } #[doc = "Builder for the [Cat Cluster Manager API](https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-cluster_manager/)\n\nReturns information about the cluster-manager node."] #[derive(Clone, Debug)] pub struct CatClusterManager<'a, 'b> { transport: &'a Transport, parts: CatClusterManagerParts, cluster_manager_timeout: Option<&'b str>, error_trace: Option, filter_path: Option<&'b [&'b str]>, format: Option<&'b str>, h: Option<&'b [&'b str]>, headers: HeaderMap, help: Option, human: Option, local: Option, master_timeout: Option<&'b str>, pretty: Option, request_timeout: Option, s: Option<&'b [&'b str]>, source: Option<&'b str>, v: Option, } impl<'a, 'b> CatClusterManager<'a, 'b> { #[doc = "Creates a new instance of [CatClusterManager]"] pub fn new(transport: &'a Transport) -> Self { let mut headers = HeaderMap::with_capacity(2); headers.insert(CONTENT_TYPE, HeaderValue::from_static("text/plain")); headers.insert(ACCEPT, HeaderValue::from_static("text/plain")); CatClusterManager { transport, parts: CatClusterManagerParts::None, headers, cluster_manager_timeout: None, error_trace: None, filter_path: None, format: None, h: None, help: None, human: None, local: None, master_timeout: None, pretty: None, request_timeout: None, s: None, source: None, v: None, } } #[doc = "Explicit operation timeout for connection to cluster-manager node"] pub fn cluster_manager_timeout(mut self, cluster_manager_timeout: &'b str) -> Self { self.cluster_manager_timeout = Some(cluster_manager_timeout); self } #[doc = "Include the stack trace of returned errors."] pub fn error_trace(mut self, error_trace: bool) -> Self { self.error_trace = Some(error_trace); self } #[doc = "A comma-separated list of filters used to reduce the response."] pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self { self.filter_path = Some(filter_path); self } #[doc = "a short version of the Accept header, e.g. json, yaml"] pub fn format(mut self, format: &'b str) -> Self { self.format = Some(format); self } #[doc = "Comma-separated list of column names to display"] pub fn h(mut self, h: &'b [&'b str]) -> Self { self.h = Some(h); self } #[doc = "Adds a HTTP header"] pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { self.headers.insert(key, value); self } #[doc = "Return help information"] pub fn help(mut self, help: bool) -> Self { self.help = Some(help); self } #[doc = "Return human readable values for statistics."] pub fn human(mut self, human: bool) -> Self { self.human = Some(human); self } #[doc = "Return local information, do not retrieve the state from cluster-manager node (default: false)"] pub fn local(mut self, local: bool) -> Self { self.local = Some(local); self } #[doc = "Explicit operation timeout for connection to cluster-manager node"] #[deprecated = "To promote inclusive language, use 'cluster_manager_timeout' instead."] pub fn master_timeout(mut self, master_timeout: &'b str) -> Self { self.master_timeout = Some(master_timeout); self } #[doc = "Pretty format the returned JSON response."] pub fn pretty(mut self, pretty: bool) -> Self { self.pretty = Some(pretty); self } #[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."] pub fn request_timeout(mut self, timeout: Duration) -> Self { self.request_timeout = Some(timeout); self } #[doc = "Comma-separated list of column names or column aliases to sort by"] pub fn s(mut self, s: &'b [&'b str]) -> Self { self.s = Some(s); self } #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."] pub fn source(mut self, source: &'b str) -> Self { self.source = Some(source); self } #[doc = "Verbose mode. Display column headers"] pub fn v(mut self, v: bool) -> Self { self.v = Some(v); self } #[doc = "Creates an asynchronous call to the Cat Cluster Manager API that can be awaited"] pub async fn send(self) -> Result { let path = self.parts.url(); let method = Method::Get; let headers = self.headers; let timeout = self.request_timeout; let query_string = { #[serde_with::skip_serializing_none] #[derive(Serialize)] struct QueryParams<'b> { cluster_manager_timeout: Option<&'b str>, error_trace: Option, #[serde(serialize_with = "crate::client::serialize_coll_qs")] filter_path: Option<&'b [&'b str]>, format: Option<&'b str>, #[serde(serialize_with = "crate::client::serialize_coll_qs")] h: Option<&'b [&'b str]>, help: Option, human: Option, local: Option, master_timeout: Option<&'b str>, pretty: Option, #[serde(serialize_with = "crate::client::serialize_coll_qs")] s: Option<&'b [&'b str]>, source: Option<&'b str>, v: Option, } let query_params = QueryParams { cluster_manager_timeout: self.cluster_manager_timeout, error_trace: self.error_trace, filter_path: self.filter_path, format: self.format, h: self.h, help: self.help, human: self.human, local: self.local, master_timeout: self.master_timeout, pretty: self.pretty, s: self.s, source: self.source, v: self.v, }; Some(query_params) }; let body = Option::<()>::None; let response = self .transport .send(method, &path, headers, query_string.as_ref(), body, timeout) .await?; Ok(response) } } #[derive(Debug, Clone, PartialEq, Eq)] #[doc = "API parts for the Cat Count API"] pub enum CatCountParts<'b> { #[doc = "No parts"] None, #[doc = "Index"] Index(&'b [&'b str]), } impl<'b> CatCountParts<'b> { #[doc = "Builds a relative URL path to the Cat Count API"] pub fn url(self) -> Cow<'static, str> { match self { CatCountParts::None => "/_cat/count".into(), CatCountParts::Index(index) => { let index_str = index.join(","); let encoded_index: Cow = percent_encode(index_str.as_bytes(), PARTS_ENCODED).into(); let mut p = String::with_capacity(12usize + encoded_index.len()); p.push_str("/_cat/count/"); p.push_str(encoded_index.as_ref()); p.into() } } } } #[doc = "Builder for the [Cat Count API](https://opensearch.org/docs/)\n\nProvides quick access to the document count of the entire cluster, or individual indices."] #[derive(Clone, Debug)] pub struct CatCount<'a, 'b> { transport: &'a Transport, parts: CatCountParts<'b>, error_trace: Option, filter_path: Option<&'b [&'b str]>, format: Option<&'b str>, h: Option<&'b [&'b str]>, headers: HeaderMap, help: Option, human: Option, pretty: Option, request_timeout: Option, s: Option<&'b [&'b str]>, source: Option<&'b str>, v: Option, } impl<'a, 'b> CatCount<'a, 'b> { #[doc = "Creates a new instance of [CatCount] with the specified API parts"] pub fn new(transport: &'a Transport, parts: CatCountParts<'b>) -> Self { let mut headers = HeaderMap::with_capacity(2); headers.insert(CONTENT_TYPE, HeaderValue::from_static("text/plain")); headers.insert(ACCEPT, HeaderValue::from_static("text/plain")); CatCount { transport, parts, headers, error_trace: None, filter_path: None, format: None, h: None, help: None, human: None, pretty: None, request_timeout: None, s: None, source: None, v: None, } } #[doc = "Include the stack trace of returned errors."] pub fn error_trace(mut self, error_trace: bool) -> Self { self.error_trace = Some(error_trace); self } #[doc = "A comma-separated list of filters used to reduce the response."] pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self { self.filter_path = Some(filter_path); self } #[doc = "a short version of the Accept header, e.g. json, yaml"] pub fn format(mut self, format: &'b str) -> Self { self.format = Some(format); self } #[doc = "Comma-separated list of column names to display"] pub fn h(mut self, h: &'b [&'b str]) -> Self { self.h = Some(h); self } #[doc = "Adds a HTTP header"] pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { self.headers.insert(key, value); self } #[doc = "Return help information"] pub fn help(mut self, help: bool) -> Self { self.help = Some(help); self } #[doc = "Return human readable values for statistics."] pub fn human(mut self, human: bool) -> Self { self.human = Some(human); self } #[doc = "Pretty format the returned JSON response."] pub fn pretty(mut self, pretty: bool) -> Self { self.pretty = Some(pretty); self } #[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."] pub fn request_timeout(mut self, timeout: Duration) -> Self { self.request_timeout = Some(timeout); self } #[doc = "Comma-separated list of column names or column aliases to sort by"] pub fn s(mut self, s: &'b [&'b str]) -> Self { self.s = Some(s); self } #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."] pub fn source(mut self, source: &'b str) -> Self { self.source = Some(source); self } #[doc = "Verbose mode. Display column headers"] pub fn v(mut self, v: bool) -> Self { self.v = Some(v); self } #[doc = "Creates an asynchronous call to the Cat Count API that can be awaited"] pub async fn send(self) -> Result { let path = self.parts.url(); let method = Method::Get; let headers = self.headers; let timeout = self.request_timeout; let query_string = { #[serde_with::skip_serializing_none] #[derive(Serialize)] struct QueryParams<'b> { error_trace: Option, #[serde(serialize_with = "crate::client::serialize_coll_qs")] filter_path: Option<&'b [&'b str]>, format: Option<&'b str>, #[serde(serialize_with = "crate::client::serialize_coll_qs")] h: Option<&'b [&'b str]>, help: Option, human: Option, pretty: Option, #[serde(serialize_with = "crate::client::serialize_coll_qs")] s: Option<&'b [&'b str]>, source: Option<&'b str>, v: Option, } let query_params = QueryParams { error_trace: self.error_trace, filter_path: self.filter_path, format: self.format, h: self.h, help: self.help, human: self.human, pretty: self.pretty, s: self.s, source: self.source, v: self.v, }; Some(query_params) }; let body = Option::<()>::None; let response = self .transport .send(method, &path, headers, query_string.as_ref(), body, timeout) .await?; Ok(response) } } #[derive(Debug, Clone, PartialEq, Eq)] #[doc = "API parts for the Cat Fielddata API"] pub enum CatFielddataParts<'b> { #[doc = "No parts"] None, #[doc = "Fields"] Fields(&'b [&'b str]), } impl<'b> CatFielddataParts<'b> { #[doc = "Builds a relative URL path to the Cat Fielddata API"] pub fn url(self) -> Cow<'static, str> { match self { CatFielddataParts::None => "/_cat/fielddata".into(), CatFielddataParts::Fields(fields) => { let fields_str = fields.join(","); let encoded_fields: Cow = percent_encode(fields_str.as_bytes(), PARTS_ENCODED).into(); let mut p = String::with_capacity(16usize + encoded_fields.len()); p.push_str("/_cat/fielddata/"); p.push_str(encoded_fields.as_ref()); p.into() } } } } #[doc = "Builder for the [Cat Fielddata API](https://opensearch.org/docs/)\n\nShows how much heap memory is currently being used by fielddata on every data node in the cluster."] #[derive(Clone, Debug)] pub struct CatFielddata<'a, 'b> { transport: &'a Transport, parts: CatFielddataParts<'b>, bytes: Option, error_trace: Option, fields: Option<&'b [&'b str]>, filter_path: Option<&'b [&'b str]>, format: Option<&'b str>, h: Option<&'b [&'b str]>, headers: HeaderMap, help: Option, human: Option, pretty: Option, request_timeout: Option, s: Option<&'b [&'b str]>, source: Option<&'b str>, v: Option, } impl<'a, 'b> CatFielddata<'a, 'b> { #[doc = "Creates a new instance of [CatFielddata] with the specified API parts"] pub fn new(transport: &'a Transport, parts: CatFielddataParts<'b>) -> Self { let mut headers = HeaderMap::with_capacity(2); headers.insert(CONTENT_TYPE, HeaderValue::from_static("text/plain")); headers.insert(ACCEPT, HeaderValue::from_static("text/plain")); CatFielddata { transport, parts, headers, bytes: None, error_trace: None, fields: None, filter_path: None, format: None, h: None, help: None, human: None, pretty: None, request_timeout: None, s: None, source: None, v: None, } } #[doc = "The unit in which to display byte values"] pub fn bytes(mut self, bytes: Bytes) -> Self { self.bytes = Some(bytes); self } #[doc = "Include the stack trace of returned errors."] pub fn error_trace(mut self, error_trace: bool) -> Self { self.error_trace = Some(error_trace); self } #[doc = "A comma-separated list of fields to return in the output"] pub fn fields(mut self, fields: &'b [&'b str]) -> Self { self.fields = Some(fields); self } #[doc = "A comma-separated list of filters used to reduce the response."] pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self { self.filter_path = Some(filter_path); self } #[doc = "a short version of the Accept header, e.g. json, yaml"] pub fn format(mut self, format: &'b str) -> Self { self.format = Some(format); self } #[doc = "Comma-separated list of column names to display"] pub fn h(mut self, h: &'b [&'b str]) -> Self { self.h = Some(h); self } #[doc = "Adds a HTTP header"] pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { self.headers.insert(key, value); self } #[doc = "Return help information"] pub fn help(mut self, help: bool) -> Self { self.help = Some(help); self } #[doc = "Return human readable values for statistics."] pub fn human(mut self, human: bool) -> Self { self.human = Some(human); self } #[doc = "Pretty format the returned JSON response."] pub fn pretty(mut self, pretty: bool) -> Self { self.pretty = Some(pretty); self } #[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."] pub fn request_timeout(mut self, timeout: Duration) -> Self { self.request_timeout = Some(timeout); self } #[doc = "Comma-separated list of column names or column aliases to sort by"] pub fn s(mut self, s: &'b [&'b str]) -> Self { self.s = Some(s); self } #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."] pub fn source(mut self, source: &'b str) -> Self { self.source = Some(source); self } #[doc = "Verbose mode. Display column headers"] pub fn v(mut self, v: bool) -> Self { self.v = Some(v); self } #[doc = "Creates an asynchronous call to the Cat Fielddata API that can be awaited"] pub async fn send(self) -> Result { let path = self.parts.url(); let method = Method::Get; let headers = self.headers; let timeout = self.request_timeout; let query_string = { #[serde_with::skip_serializing_none] #[derive(Serialize)] struct QueryParams<'b> { bytes: Option, error_trace: Option, #[serde(serialize_with = "crate::client::serialize_coll_qs")] fields: Option<&'b [&'b str]>, #[serde(serialize_with = "crate::client::serialize_coll_qs")] filter_path: Option<&'b [&'b str]>, format: Option<&'b str>, #[serde(serialize_with = "crate::client::serialize_coll_qs")] h: Option<&'b [&'b str]>, help: Option, human: Option, pretty: Option, #[serde(serialize_with = "crate::client::serialize_coll_qs")] s: Option<&'b [&'b str]>, source: Option<&'b str>, v: Option, } let query_params = QueryParams { bytes: self.bytes, error_trace: self.error_trace, fields: self.fields, filter_path: self.filter_path, format: self.format, h: self.h, help: self.help, human: self.human, pretty: self.pretty, s: self.s, source: self.source, v: self.v, }; Some(query_params) }; let body = Option::<()>::None; let response = self .transport .send(method, &path, headers, query_string.as_ref(), body, timeout) .await?; Ok(response) } } #[derive(Debug, Clone, PartialEq, Eq)] #[doc = "API parts for the Cat Health API"] pub enum CatHealthParts { #[doc = "No parts"] None, } impl CatHealthParts { #[doc = "Builds a relative URL path to the Cat Health API"] pub fn url(self) -> Cow<'static, str> { match self { CatHealthParts::None => "/_cat/health".into(), } } } #[doc = "Builder for the [Cat Health API](https://opensearch.org/docs/)\n\nReturns a concise representation of the cluster health."] #[derive(Clone, Debug)] pub struct CatHealth<'a, 'b> { transport: &'a Transport, parts: CatHealthParts, error_trace: Option, filter_path: Option<&'b [&'b str]>, format: Option<&'b str>, h: Option<&'b [&'b str]>, headers: HeaderMap, help: Option, human: Option, pretty: Option, request_timeout: Option, s: Option<&'b [&'b str]>, source: Option<&'b str>, time: Option