|
| 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 | +//! Features APIs |
| 28 | +//! |
| 29 | +//! Allows [introspecting and managing features](https://www.elastic.co/guide/en/elasticsearch/reference/current/features-apis.html) provided by Elasticsearch and Elasticsearch plugins. |
| 30 | +
|
| 31 | +#![allow(unused_imports)] |
| 32 | +use crate::{ |
| 33 | + client::Elasticsearch, |
| 34 | + error::Error, |
| 35 | + http::{ |
| 36 | + headers::{HeaderMap, HeaderName, HeaderValue, ACCEPT, CONTENT_TYPE}, |
| 37 | + request::{Body, JsonBody, NdBody, PARTS_ENCODED}, |
| 38 | + response::Response, |
| 39 | + transport::Transport, |
| 40 | + Method, |
| 41 | + }, |
| 42 | + params::*, |
| 43 | +}; |
| 44 | +use percent_encoding::percent_encode; |
| 45 | +use serde::Serialize; |
| 46 | +use std::{borrow::Cow, time::Duration}; |
| 47 | +#[derive(Debug, Clone, PartialEq)] |
| 48 | +#[doc = "API parts for the Features Get Features API"] |
| 49 | +pub enum FeaturesGetFeaturesParts { |
| 50 | + #[doc = "No parts"] |
| 51 | + None, |
| 52 | +} |
| 53 | +impl FeaturesGetFeaturesParts { |
| 54 | + #[doc = "Builds a relative URL path to the Features Get Features API"] |
| 55 | + pub fn url(self) -> Cow<'static, str> { |
| 56 | + match self { |
| 57 | + FeaturesGetFeaturesParts::None => "/_features".into(), |
| 58 | + } |
| 59 | + } |
| 60 | +} |
| 61 | +#[doc = "Builder for the [Features Get Features API](https://www.elastic.co/guide/en/elasticsearch/reference/7.11/get-features-api.html)\n\nGets a list of features which can be included in snapshots using the feature_states field when creating a snapshot"] |
| 62 | +#[derive(Clone, Debug)] |
| 63 | +pub struct FeaturesGetFeatures<'a, 'b> { |
| 64 | + transport: &'a Transport, |
| 65 | + parts: FeaturesGetFeaturesParts, |
| 66 | + error_trace: Option<bool>, |
| 67 | + filter_path: Option<&'b [&'b str]>, |
| 68 | + headers: HeaderMap, |
| 69 | + human: Option<bool>, |
| 70 | + master_timeout: Option<&'b str>, |
| 71 | + pretty: Option<bool>, |
| 72 | + request_timeout: Option<Duration>, |
| 73 | + source: Option<&'b str>, |
| 74 | +} |
| 75 | +impl<'a, 'b> FeaturesGetFeatures<'a, 'b> { |
| 76 | + #[doc = "Creates a new instance of [FeaturesGetFeatures]"] |
| 77 | + pub fn new(transport: &'a Transport) -> Self { |
| 78 | + let headers = HeaderMap::new(); |
| 79 | + FeaturesGetFeatures { |
| 80 | + transport, |
| 81 | + parts: FeaturesGetFeaturesParts::None, |
| 82 | + headers, |
| 83 | + error_trace: None, |
| 84 | + filter_path: None, |
| 85 | + human: None, |
| 86 | + master_timeout: None, |
| 87 | + pretty: None, |
| 88 | + request_timeout: None, |
| 89 | + source: None, |
| 90 | + } |
| 91 | + } |
| 92 | + #[doc = "Include the stack trace of returned errors."] |
| 93 | + pub fn error_trace(mut self, error_trace: bool) -> Self { |
| 94 | + self.error_trace = Some(error_trace); |
| 95 | + self |
| 96 | + } |
| 97 | + #[doc = "A comma-separated list of filters used to reduce the response."] |
| 98 | + pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self { |
| 99 | + self.filter_path = Some(filter_path); |
| 100 | + self |
| 101 | + } |
| 102 | + #[doc = "Adds a HTTP header"] |
| 103 | + pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self { |
| 104 | + self.headers.insert(key, value); |
| 105 | + self |
| 106 | + } |
| 107 | + #[doc = "Return human readable values for statistics."] |
| 108 | + pub fn human(mut self, human: bool) -> Self { |
| 109 | + self.human = Some(human); |
| 110 | + self |
| 111 | + } |
| 112 | + #[doc = "Explicit operation timeout for connection to master node"] |
| 113 | + pub fn master_timeout(mut self, master_timeout: &'b str) -> Self { |
| 114 | + self.master_timeout = Some(master_timeout); |
| 115 | + self |
| 116 | + } |
| 117 | + #[doc = "Pretty format the returned JSON response."] |
| 118 | + pub fn pretty(mut self, pretty: bool) -> Self { |
| 119 | + self.pretty = Some(pretty); |
| 120 | + self |
| 121 | + } |
| 122 | + #[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."] |
| 123 | + pub fn request_timeout(mut self, timeout: Duration) -> Self { |
| 124 | + self.request_timeout = Some(timeout); |
| 125 | + self |
| 126 | + } |
| 127 | + #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."] |
| 128 | + pub fn source(mut self, source: &'b str) -> Self { |
| 129 | + self.source = Some(source); |
| 130 | + self |
| 131 | + } |
| 132 | + #[doc = "Creates an asynchronous call to the Features Get Features API that can be awaited"] |
| 133 | + pub async fn send(self) -> Result<Response, Error> { |
| 134 | + let path = self.parts.url(); |
| 135 | + let method = Method::Get; |
| 136 | + let headers = self.headers; |
| 137 | + let timeout = self.request_timeout; |
| 138 | + let query_string = { |
| 139 | + #[serde_with::skip_serializing_none] |
| 140 | + #[derive(Serialize)] |
| 141 | + struct QueryParams<'b> { |
| 142 | + error_trace: Option<bool>, |
| 143 | + #[serde(serialize_with = "crate::client::serialize_coll_qs")] |
| 144 | + filter_path: Option<&'b [&'b str]>, |
| 145 | + human: Option<bool>, |
| 146 | + master_timeout: Option<&'b str>, |
| 147 | + pretty: Option<bool>, |
| 148 | + source: Option<&'b str>, |
| 149 | + } |
| 150 | + let query_params = QueryParams { |
| 151 | + error_trace: self.error_trace, |
| 152 | + filter_path: self.filter_path, |
| 153 | + human: self.human, |
| 154 | + master_timeout: self.master_timeout, |
| 155 | + pretty: self.pretty, |
| 156 | + source: self.source, |
| 157 | + }; |
| 158 | + Some(query_params) |
| 159 | + }; |
| 160 | + let body = Option::<()>::None; |
| 161 | + let response = self |
| 162 | + .transport |
| 163 | + .send(method, &path, headers, query_string.as_ref(), body, timeout) |
| 164 | + .await?; |
| 165 | + Ok(response) |
| 166 | + } |
| 167 | +} |
| 168 | +#[doc = "Namespace client for Features APIs"] |
| 169 | +pub struct Features<'a> { |
| 170 | + transport: &'a Transport, |
| 171 | +} |
| 172 | +impl<'a> Features<'a> { |
| 173 | + #[doc = "Creates a new instance of [Features]"] |
| 174 | + pub fn new(transport: &'a Transport) -> Self { |
| 175 | + Self { transport } |
| 176 | + } |
| 177 | + pub fn transport(&self) -> &Transport { |
| 178 | + self.transport |
| 179 | + } |
| 180 | + #[doc = "[Features Get Features API](https://www.elastic.co/guide/en/elasticsearch/reference/7.11/get-features-api.html)\n\nGets a list of features which can be included in snapshots using the feature_states field when creating a snapshot"] |
| 181 | + pub fn get_features<'b>(&'a self) -> FeaturesGetFeatures<'a, 'b> { |
| 182 | + FeaturesGetFeatures::new(self.transport()) |
| 183 | + } |
| 184 | +} |
| 185 | +impl Elasticsearch { |
| 186 | + #[doc = "Creates a namespace client for Features APIs"] |
| 187 | + pub fn features(&self) -> Features { |
| 188 | + Features::new(self.transport()) |
| 189 | + } |
| 190 | +} |
0 commit comments